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

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

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.kubernetesconfiguration.models.AzureBlobDefinition;
import com.azure.resourcemanager.kubernetesconfiguration.models.BucketDefinition;
import com.azure.resourcemanager.kubernetesconfiguration.models.FluxComplianceState;
import com.azure.resourcemanager.kubernetesconfiguration.models.GitRepositoryDefinition;
import com.azure.resourcemanager.kubernetesconfiguration.models.KustomizationDefinition;
import com.azure.resourcemanager.kubernetesconfiguration.models.ObjectStatusDefinition;
import com.azure.resourcemanager.kubernetesconfiguration.models.ProvisioningState;
import com.azure.resourcemanager.kubernetesconfiguration.models.ScopeType;
import com.azure.resourcemanager.kubernetesconfiguration.models.SourceKindType;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;

/** Properties to create a Flux Configuration resource. */
@Fluent
public final class FluxConfigurationProperties {
    /*
     * Scope at which the operator will be installed.
     */
    @JsonProperty(value = "scope")
    private ScopeType scope;

    /*
     * The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters,
     * hyphen and period only.
     */
    @JsonProperty(value = "namespace")
    private String namespace;

    /*
     * Source Kind to pull the configuration data from.
     */
    @JsonProperty(value = "sourceKind")
    private SourceKindType sourceKind;

    /*
     * Whether this configuration should suspend its reconciliation of its kustomizations and sources.
     */
    @JsonProperty(value = "suspend")
    private Boolean suspend;

    /*
     * Parameters to reconcile to the GitRepository source kind type.
     */
    @JsonProperty(value = "gitRepository")
    private GitRepositoryDefinition gitRepository;

    /*
     * Parameters to reconcile to the Bucket source kind type.
     */
    @JsonProperty(value = "bucket")
    private BucketDefinition bucket;

    /*
     * Parameters to reconcile to the AzureBlob source kind type.
     */
    @JsonProperty(value = "azureBlob")
    private AzureBlobDefinition azureBlob;

    /*
     * Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster.
     */
    @JsonProperty(value = "kustomizations")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, KustomizationDefinition> kustomizations;

    /*
     * Key-value pairs of protected configuration settings for the configuration
     */
    @JsonProperty(value = "configurationProtectedSettings")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> configurationProtectedSettings;

    /*
     * Statuses of the Flux Kubernetes resources created by the fluxConfiguration or created by the managed objects
     * provisioned by the fluxConfiguration.
     */
    @JsonProperty(value = "statuses", access = JsonProperty.Access.WRITE_ONLY)
    private List<ObjectStatusDefinition> statuses;

    /*
     * Public Key associated with this fluxConfiguration (either generated within the cluster or provided by the user).
     */
    @JsonProperty(value = "repositoryPublicKey", access = JsonProperty.Access.WRITE_ONLY)
    private String repositoryPublicKey;

    /*
     * Branch and/or SHA of the source commit synced with the cluster.
     */
    @JsonProperty(value = "sourceSyncedCommitId", access = JsonProperty.Access.WRITE_ONLY)
    private String sourceSyncedCommitId;

    /*
     * Datetime the fluxConfiguration synced its source on the cluster.
     */
    @JsonProperty(value = "sourceUpdatedAt", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime sourceUpdatedAt;

    /*
     * Datetime the fluxConfiguration synced its status on the cluster with Azure.
     */
    @JsonProperty(value = "statusUpdatedAt", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime statusUpdatedAt;

    /*
     * Combined status of the Flux Kubernetes resources created by the fluxConfiguration or created by the managed
     * objects.
     */
    @JsonProperty(value = "complianceState", access = JsonProperty.Access.WRITE_ONLY)
    private FluxComplianceState complianceState;

    /*
     * Status of the creation of the fluxConfiguration.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningState provisioningState;

    /*
     * Error message returned to the user in the case of provisioning failure.
     */
    @JsonProperty(value = "errorMessage", access = JsonProperty.Access.WRITE_ONLY)
    private String errorMessage;

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

    /**
     * Get the scope property: Scope at which the operator will be installed.
     *
     * @return the scope value.
     */
    public ScopeType scope() {
        return this.scope;
    }

    /**
     * Set the scope property: Scope at which the operator will be installed.
     *
     * @param scope the scope value to set.
     * @return the FluxConfigurationProperties object itself.
     */
    public FluxConfigurationProperties withScope(ScopeType scope) {
        this.scope = scope;
        return this;
    }

    /**
     * Get the namespace property: The namespace to which this configuration is installed to. Maximum of 253 lower case
     * alphanumeric characters, hyphen and period only.
     *
     * @return the namespace value.
     */
    public String namespace() {
        return this.namespace;
    }

    /**
     * Set the namespace property: The namespace to which this configuration is installed to. Maximum of 253 lower case
     * alphanumeric characters, hyphen and period only.
     *
     * @param namespace the namespace value to set.
     * @return the FluxConfigurationProperties object itself.
     */
    public FluxConfigurationProperties withNamespace(String namespace) {
        this.namespace = namespace;
        return this;
    }

    /**
     * Get the sourceKind property: Source Kind to pull the configuration data from.
     *
     * @return the sourceKind value.
     */
    public SourceKindType sourceKind() {
        return this.sourceKind;
    }

    /**
     * Set the sourceKind property: Source Kind to pull the configuration data from.
     *
     * @param sourceKind the sourceKind value to set.
     * @return the FluxConfigurationProperties object itself.
     */
    public FluxConfigurationProperties withSourceKind(SourceKindType sourceKind) {
        this.sourceKind = sourceKind;
        return this;
    }

    /**
     * Get the suspend property: Whether this configuration should suspend its reconciliation of its kustomizations and
     * sources.
     *
     * @return the suspend value.
     */
    public Boolean suspend() {
        return this.suspend;
    }

    /**
     * Set the suspend property: Whether this configuration should suspend its reconciliation of its kustomizations and
     * sources.
     *
     * @param suspend the suspend value to set.
     * @return the FluxConfigurationProperties object itself.
     */
    public FluxConfigurationProperties withSuspend(Boolean suspend) {
        this.suspend = suspend;
        return this;
    }

    /**
     * Get the gitRepository property: Parameters to reconcile to the GitRepository source kind type.
     *
     * @return the gitRepository value.
     */
    public GitRepositoryDefinition gitRepository() {
        return this.gitRepository;
    }

    /**
     * Set the gitRepository property: Parameters to reconcile to the GitRepository source kind type.
     *
     * @param gitRepository the gitRepository value to set.
     * @return the FluxConfigurationProperties object itself.
     */
    public FluxConfigurationProperties withGitRepository(GitRepositoryDefinition gitRepository) {
        this.gitRepository = gitRepository;
        return this;
    }

    /**
     * Get the bucket property: Parameters to reconcile to the Bucket source kind type.
     *
     * @return the bucket value.
     */
    public BucketDefinition bucket() {
        return this.bucket;
    }

    /**
     * Set the bucket property: Parameters to reconcile to the Bucket source kind type.
     *
     * @param bucket the bucket value to set.
     * @return the FluxConfigurationProperties object itself.
     */
    public FluxConfigurationProperties withBucket(BucketDefinition bucket) {
        this.bucket = bucket;
        return this;
    }

    /**
     * Get the azureBlob property: Parameters to reconcile to the AzureBlob source kind type.
     *
     * @return the azureBlob value.
     */
    public AzureBlobDefinition azureBlob() {
        return this.azureBlob;
    }

    /**
     * Set the azureBlob property: Parameters to reconcile to the AzureBlob source kind type.
     *
     * @param azureBlob the azureBlob value to set.
     * @return the FluxConfigurationProperties object itself.
     */
    public FluxConfigurationProperties withAzureBlob(AzureBlobDefinition azureBlob) {
        this.azureBlob = azureBlob;
        return this;
    }

    /**
     * Get the kustomizations property: Array of kustomizations used to reconcile the artifact pulled by the source type
     * on the cluster.
     *
     * @return the kustomizations value.
     */
    public Map<String, KustomizationDefinition> kustomizations() {
        return this.kustomizations;
    }

    /**
     * Set the kustomizations property: Array of kustomizations used to reconcile the artifact pulled by the source type
     * on the cluster.
     *
     * @param kustomizations the kustomizations value to set.
     * @return the FluxConfigurationProperties object itself.
     */
    public FluxConfigurationProperties withKustomizations(Map<String, KustomizationDefinition> kustomizations) {
        this.kustomizations = kustomizations;
        return this;
    }

    /**
     * Get the configurationProtectedSettings property: Key-value pairs of protected configuration settings for the
     * configuration.
     *
     * @return the configurationProtectedSettings value.
     */
    public Map<String, String> configurationProtectedSettings() {
        return this.configurationProtectedSettings;
    }

    /**
     * Set the configurationProtectedSettings property: Key-value pairs of protected configuration settings for the
     * configuration.
     *
     * @param configurationProtectedSettings the configurationProtectedSettings value to set.
     * @return the FluxConfigurationProperties object itself.
     */
    public FluxConfigurationProperties withConfigurationProtectedSettings(
        Map<String, String> configurationProtectedSettings) {
        this.configurationProtectedSettings = configurationProtectedSettings;
        return this;
    }

    /**
     * Get the statuses property: Statuses of the Flux Kubernetes resources created by the fluxConfiguration or created
     * by the managed objects provisioned by the fluxConfiguration.
     *
     * @return the statuses value.
     */
    public List<ObjectStatusDefinition> statuses() {
        return this.statuses;
    }

    /**
     * Get the repositoryPublicKey property: Public Key associated with this fluxConfiguration (either generated within
     * the cluster or provided by the user).
     *
     * @return the repositoryPublicKey value.
     */
    public String repositoryPublicKey() {
        return this.repositoryPublicKey;
    }

    /**
     * Get the sourceSyncedCommitId property: Branch and/or SHA of the source commit synced with the cluster.
     *
     * @return the sourceSyncedCommitId value.
     */
    public String sourceSyncedCommitId() {
        return this.sourceSyncedCommitId;
    }

    /**
     * Get the sourceUpdatedAt property: Datetime the fluxConfiguration synced its source on the cluster.
     *
     * @return the sourceUpdatedAt value.
     */
    public OffsetDateTime sourceUpdatedAt() {
        return this.sourceUpdatedAt;
    }

    /**
     * Get the statusUpdatedAt property: Datetime the fluxConfiguration synced its status on the cluster with Azure.
     *
     * @return the statusUpdatedAt value.
     */
    public OffsetDateTime statusUpdatedAt() {
        return this.statusUpdatedAt;
    }

    /**
     * Get the complianceState property: Combined status of the Flux Kubernetes resources created by the
     * fluxConfiguration or created by the managed objects.
     *
     * @return the complianceState value.
     */
    public FluxComplianceState complianceState() {
        return this.complianceState;
    }

    /**
     * Get the provisioningState property: Status of the creation of the fluxConfiguration.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the errorMessage property: Error message returned to the user in the case of provisioning failure.
     *
     * @return the errorMessage value.
     */
    public String errorMessage() {
        return this.errorMessage;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (gitRepository() != null) {
            gitRepository().validate();
        }
        if (bucket() != null) {
            bucket().validate();
        }
        if (azureBlob() != null) {
            azureBlob().validate();
        }
        if (kustomizations() != null) {
            kustomizations()
                .values()
                .forEach(
                    e -> {
                        if (e != null) {
                            e.validate();
                        }
                    });
        }
        if (statuses() != null) {
            statuses().forEach(e -> e.validate());
        }
    }
}
