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

package com.azure.resourcemanager.deviceprovisioningservices.models;

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.PrivateEndpointConnectionInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.SharedAccessSignatureAuthorizationRuleInner;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/**
 * the service specific properties of a provisioning service, including keys, linked iot hubs, current state, and system
 * generated properties such as hostname and idScope.
 */
@Fluent
public final class IotDpsPropertiesDescription {
    /*
     * Current state of the provisioning service.
     */
    @JsonProperty(value = "state")
    private State state;

    /*
     * Whether requests from Public Network are allowed
     */
    @JsonProperty(value = "publicNetworkAccess")
    private PublicNetworkAccess publicNetworkAccess;

    /*
     * The IP filter rules.
     */
    @JsonProperty(value = "ipFilterRules")
    private List<IpFilterRule> ipFilterRules;

    /*
     * Private endpoint connections created on this IotHub
     */
    @JsonProperty(value = "privateEndpointConnections")
    private List<PrivateEndpointConnectionInner> privateEndpointConnections;

    /*
     * The ARM provisioning state of the provisioning service.
     */
    @JsonProperty(value = "provisioningState")
    private String provisioningState;

    /*
     * List of IoT hubs associated with this provisioning service.
     */
    @JsonProperty(value = "iotHubs")
    private List<IotHubDefinitionDescription> iotHubs;

    /*
     * Allocation policy to be used by this provisioning service.
     */
    @JsonProperty(value = "allocationPolicy")
    private AllocationPolicy allocationPolicy;

    /*
     * Service endpoint for provisioning service.
     */
    @JsonProperty(value = "serviceOperationsHostName", access = JsonProperty.Access.WRITE_ONLY)
    private String serviceOperationsHostname;

    /*
     * Device endpoint for this provisioning service.
     */
    @JsonProperty(value = "deviceProvisioningHostName", access = JsonProperty.Access.WRITE_ONLY)
    private String deviceProvisioningHostname;

    /*
     * Unique identifier of this provisioning service.
     */
    @JsonProperty(value = "idScope", access = JsonProperty.Access.WRITE_ONLY)
    private String idScope;

    /*
     * List of authorization keys for a provisioning service.
     */
    @JsonProperty(value = "authorizationPolicies")
    private List<SharedAccessSignatureAuthorizationRuleInner> authorizationPolicies;

    /*
     * Optional.
     * Indicates if the DPS instance has Data Residency enabled, removing the
     * cross geo-pair disaster recovery.
     */
    @JsonProperty(value = "enableDataResidency")
    private Boolean enableDataResidency;

    /**
     * Get the state property: Current state of the provisioning service.
     *
     * @return the state value.
     */
    public State state() {
        return this.state;
    }

    /**
     * Set the state property: Current state of the provisioning service.
     *
     * @param state the state value to set.
     * @return the IotDpsPropertiesDescription object itself.
     */
    public IotDpsPropertiesDescription withState(State state) {
        this.state = state;
        return this;
    }

    /**
     * Get the publicNetworkAccess property: Whether requests from Public Network are allowed.
     *
     * @return the publicNetworkAccess value.
     */
    public PublicNetworkAccess publicNetworkAccess() {
        return this.publicNetworkAccess;
    }

    /**
     * Set the publicNetworkAccess property: Whether requests from Public Network are allowed.
     *
     * @param publicNetworkAccess the publicNetworkAccess value to set.
     * @return the IotDpsPropertiesDescription object itself.
     */
    public IotDpsPropertiesDescription withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess) {
        this.publicNetworkAccess = publicNetworkAccess;
        return this;
    }

    /**
     * Get the ipFilterRules property: The IP filter rules.
     *
     * @return the ipFilterRules value.
     */
    public List<IpFilterRule> ipFilterRules() {
        return this.ipFilterRules;
    }

    /**
     * Set the ipFilterRules property: The IP filter rules.
     *
     * @param ipFilterRules the ipFilterRules value to set.
     * @return the IotDpsPropertiesDescription object itself.
     */
    public IotDpsPropertiesDescription withIpFilterRules(List<IpFilterRule> ipFilterRules) {
        this.ipFilterRules = ipFilterRules;
        return this;
    }

    /**
     * Get the privateEndpointConnections property: Private endpoint connections created on this IotHub.
     *
     * @return the privateEndpointConnections value.
     */
    public List<PrivateEndpointConnectionInner> privateEndpointConnections() {
        return this.privateEndpointConnections;
    }

    /**
     * Set the privateEndpointConnections property: Private endpoint connections created on this IotHub.
     *
     * @param privateEndpointConnections the privateEndpointConnections value to set.
     * @return the IotDpsPropertiesDescription object itself.
     */
    public IotDpsPropertiesDescription withPrivateEndpointConnections(
        List<PrivateEndpointConnectionInner> privateEndpointConnections) {
        this.privateEndpointConnections = privateEndpointConnections;
        return this;
    }

    /**
     * Get the provisioningState property: The ARM provisioning state of the provisioning service.
     *
     * @return the provisioningState value.
     */
    public String provisioningState() {
        return this.provisioningState;
    }

    /**
     * Set the provisioningState property: The ARM provisioning state of the provisioning service.
     *
     * @param provisioningState the provisioningState value to set.
     * @return the IotDpsPropertiesDescription object itself.
     */
    public IotDpsPropertiesDescription withProvisioningState(String provisioningState) {
        this.provisioningState = provisioningState;
        return this;
    }

    /**
     * Get the iotHubs property: List of IoT hubs associated with this provisioning service.
     *
     * @return the iotHubs value.
     */
    public List<IotHubDefinitionDescription> iotHubs() {
        return this.iotHubs;
    }

    /**
     * Set the iotHubs property: List of IoT hubs associated with this provisioning service.
     *
     * @param iotHubs the iotHubs value to set.
     * @return the IotDpsPropertiesDescription object itself.
     */
    public IotDpsPropertiesDescription withIotHubs(List<IotHubDefinitionDescription> iotHubs) {
        this.iotHubs = iotHubs;
        return this;
    }

    /**
     * Get the allocationPolicy property: Allocation policy to be used by this provisioning service.
     *
     * @return the allocationPolicy value.
     */
    public AllocationPolicy allocationPolicy() {
        return this.allocationPolicy;
    }

    /**
     * Set the allocationPolicy property: Allocation policy to be used by this provisioning service.
     *
     * @param allocationPolicy the allocationPolicy value to set.
     * @return the IotDpsPropertiesDescription object itself.
     */
    public IotDpsPropertiesDescription withAllocationPolicy(AllocationPolicy allocationPolicy) {
        this.allocationPolicy = allocationPolicy;
        return this;
    }

    /**
     * Get the serviceOperationsHostname property: Service endpoint for provisioning service.
     *
     * @return the serviceOperationsHostname value.
     */
    public String serviceOperationsHostname() {
        return this.serviceOperationsHostname;
    }

    /**
     * Get the deviceProvisioningHostname property: Device endpoint for this provisioning service.
     *
     * @return the deviceProvisioningHostname value.
     */
    public String deviceProvisioningHostname() {
        return this.deviceProvisioningHostname;
    }

    /**
     * Get the idScope property: Unique identifier of this provisioning service.
     *
     * @return the idScope value.
     */
    public String idScope() {
        return this.idScope;
    }

    /**
     * Get the authorizationPolicies property: List of authorization keys for a provisioning service.
     *
     * @return the authorizationPolicies value.
     */
    public List<SharedAccessSignatureAuthorizationRuleInner> authorizationPolicies() {
        return this.authorizationPolicies;
    }

    /**
     * Set the authorizationPolicies property: List of authorization keys for a provisioning service.
     *
     * @param authorizationPolicies the authorizationPolicies value to set.
     * @return the IotDpsPropertiesDescription object itself.
     */
    public IotDpsPropertiesDescription withAuthorizationPolicies(
        List<SharedAccessSignatureAuthorizationRuleInner> authorizationPolicies) {
        this.authorizationPolicies = authorizationPolicies;
        return this;
    }

    /**
     * Get the enableDataResidency property: Optional. Indicates if the DPS instance has Data Residency enabled,
     * removing the cross geo-pair disaster recovery.
     *
     * @return the enableDataResidency value.
     */
    public Boolean enableDataResidency() {
        return this.enableDataResidency;
    }

    /**
     * Set the enableDataResidency property: Optional. Indicates if the DPS instance has Data Residency enabled,
     * removing the cross geo-pair disaster recovery.
     *
     * @param enableDataResidency the enableDataResidency value to set.
     * @return the IotDpsPropertiesDescription object itself.
     */
    public IotDpsPropertiesDescription withEnableDataResidency(Boolean enableDataResidency) {
        this.enableDataResidency = enableDataResidency;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (ipFilterRules() != null) {
            ipFilterRules().forEach(e -> e.validate());
        }
        if (privateEndpointConnections() != null) {
            privateEndpointConnections().forEach(e -> e.validate());
        }
        if (iotHubs() != null) {
            iotHubs().forEach(e -> e.validate());
        }
        if (authorizationPolicies() != null) {
            authorizationPolicies().forEach(e -> e.validate());
        }
    }
}
