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

package com.azure.resourcemanager.mobilenetwork.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.mobilenetwork.models.KeyVaultKey;
import com.azure.resourcemanager.mobilenetwork.models.ManagedServiceIdentity;
import com.azure.resourcemanager.mobilenetwork.models.MobileNetworkResourceId;
import com.azure.resourcemanager.mobilenetwork.models.ProvisioningState;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/** SIM group resource. */
@Fluent
public final class SimGroupInner extends Resource {
    /*
     * SIM group Properties.
     */
    @JsonProperty(value = "properties", required = true)
    private SimGroupPropertiesFormat innerProperties = new SimGroupPropertiesFormat();

    /*
     * The identity used to retrieve the encryption key from Azure key vault.
     */
    @JsonProperty(value = "identity")
    private ManagedServiceIdentity identity;

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

    /** Creates an instance of SimGroupInner class. */
    public SimGroupInner() {
    }

    /**
     * Get the innerProperties property: SIM group Properties.
     *
     * @return the innerProperties value.
     */
    private SimGroupPropertiesFormat innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the identity property: The identity used to retrieve the encryption key from Azure key vault.
     *
     * @return the identity value.
     */
    public ManagedServiceIdentity identity() {
        return this.identity;
    }

    /**
     * Set the identity property: The identity used to retrieve the encryption key from Azure key vault.
     *
     * @param identity the identity value to set.
     * @return the SimGroupInner object itself.
     */
    public SimGroupInner withIdentity(ManagedServiceIdentity identity) {
        this.identity = identity;
        return this;
    }

    /**
     * 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 SimGroupInner withLocation(String location) {
        super.withLocation(location);
        return this;
    }

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

    /**
     * Get the provisioningState property: The provisioning state of the SIM group resource.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().provisioningState();
    }

    /**
     * Get the encryptionKey property: A key to encrypt the SIM data that belongs to this SIM group.
     *
     * @return the encryptionKey value.
     */
    public KeyVaultKey encryptionKey() {
        return this.innerProperties() == null ? null : this.innerProperties().encryptionKey();
    }

    /**
     * Set the encryptionKey property: A key to encrypt the SIM data that belongs to this SIM group.
     *
     * @param encryptionKey the encryptionKey value to set.
     * @return the SimGroupInner object itself.
     */
    public SimGroupInner withEncryptionKey(KeyVaultKey encryptionKey) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SimGroupPropertiesFormat();
        }
        this.innerProperties().withEncryptionKey(encryptionKey);
        return this;
    }

    /**
     * Get the mobileNetwork property: Mobile network that this SIM group belongs to. The mobile network must be in the
     * same location as the SIM group.
     *
     * @return the mobileNetwork value.
     */
    public MobileNetworkResourceId mobileNetwork() {
        return this.innerProperties() == null ? null : this.innerProperties().mobileNetwork();
    }

    /**
     * Set the mobileNetwork property: Mobile network that this SIM group belongs to. The mobile network must be in the
     * same location as the SIM group.
     *
     * @param mobileNetwork the mobileNetwork value to set.
     * @return the SimGroupInner object itself.
     */
    public SimGroupInner withMobileNetwork(MobileNetworkResourceId mobileNetwork) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SimGroupPropertiesFormat();
        }
        this.innerProperties().withMobileNetwork(mobileNetwork);
        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 SimGroupInner"));
        } else {
            innerProperties().validate();
        }
        if (identity() != null) {
            identity().validate();
        }
    }

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