// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.deviceupdate.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.core.management.SystemData;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.deviceupdate.models.DiagnosticStorageProperties;
import com.azure.resourcemanager.deviceupdate.models.IotHubSettings;
import com.azure.resourcemanager.deviceupdate.models.ProvisioningState;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** Device Update instance details. */
@Fluent
public final class InstanceInner extends Resource {
    /*
     * Device Update instance properties.
     */
    @JsonProperty(value = "properties", required = true)
    private InstanceProperties innerProperties = new InstanceProperties();

    /*
     * Azure Resource Manager metadata containing createdBy and modifiedBy information.
     */
    @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
    private SystemData systemData;

    /**
     * Get the innerProperties property: Device Update instance properties.
     *
     * @return the innerProperties value.
     */
    private InstanceProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information.
     *
     * @return the systemData value.
     */
    public SystemData systemData() {
        return this.systemData;
    }

    /** {@inheritDoc} */
    @Override
    public InstanceInner withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public InstanceInner withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

    /**
     * Get the provisioningState property: Provisioning state.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().provisioningState();
    }

    /**
     * Get the accountName property: Parent Device Update Account name which Instance belongs to.
     *
     * @return the accountName value.
     */
    public String accountName() {
        return this.innerProperties() == null ? null : this.innerProperties().accountName();
    }

    /**
     * Get the iotHubs property: List of IoT Hubs associated with the account.
     *
     * @return the iotHubs value.
     */
    public List<IotHubSettings> iotHubs() {
        return this.innerProperties() == null ? null : this.innerProperties().iotHubs();
    }

    /**
     * Set the iotHubs property: List of IoT Hubs associated with the account.
     *
     * @param iotHubs the iotHubs value to set.
     * @return the InstanceInner object itself.
     */
    public InstanceInner withIotHubs(List<IotHubSettings> iotHubs) {
        if (this.innerProperties() == null) {
            this.innerProperties = new InstanceProperties();
        }
        this.innerProperties().withIotHubs(iotHubs);
        return this;
    }

    /**
     * Get the enableDiagnostics property: Enables or Disables the diagnostic logs collection.
     *
     * @return the enableDiagnostics value.
     */
    public Boolean enableDiagnostics() {
        return this.innerProperties() == null ? null : this.innerProperties().enableDiagnostics();
    }

    /**
     * Set the enableDiagnostics property: Enables or Disables the diagnostic logs collection.
     *
     * @param enableDiagnostics the enableDiagnostics value to set.
     * @return the InstanceInner object itself.
     */
    public InstanceInner withEnableDiagnostics(Boolean enableDiagnostics) {
        if (this.innerProperties() == null) {
            this.innerProperties = new InstanceProperties();
        }
        this.innerProperties().withEnableDiagnostics(enableDiagnostics);
        return this;
    }

    /**
     * Get the diagnosticStorageProperties property: Customer-initiated diagnostic log collection storage properties.
     *
     * @return the diagnosticStorageProperties value.
     */
    public DiagnosticStorageProperties diagnosticStorageProperties() {
        return this.innerProperties() == null ? null : this.innerProperties().diagnosticStorageProperties();
    }

    /**
     * Set the diagnosticStorageProperties property: Customer-initiated diagnostic log collection storage properties.
     *
     * @param diagnosticStorageProperties the diagnosticStorageProperties value to set.
     * @return the InstanceInner object itself.
     */
    public InstanceInner withDiagnosticStorageProperties(DiagnosticStorageProperties diagnosticStorageProperties) {
        if (this.innerProperties() == null) {
            this.innerProperties = new InstanceProperties();
        }
        this.innerProperties().withDiagnosticStorageProperties(diagnosticStorageProperties);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (innerProperties() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property innerProperties in model InstanceInner"));
        } else {
            innerProperties().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(InstanceInner.class);
}
