// 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.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Parameters to reconcile to the AzureBlob source kind type. */
@Fluent
public final class AzureBlobDefinition {
    /*
     * The URL to sync for the flux configuration Azure Blob storage account.
     */
    @JsonProperty(value = "url")
    private String url;

    /*
     * The Azure Blob container name to sync from the url endpoint for the flux configuration.
     */
    @JsonProperty(value = "containerName")
    private String containerName;

    /*
     * The maximum time to attempt to reconcile the cluster Azure Blob source with the remote.
     */
    @JsonProperty(value = "timeoutInSeconds")
    private Long timeoutInSeconds;

    /*
     * The interval at which to re-reconcile the cluster Azure Blob source with the remote.
     */
    @JsonProperty(value = "syncIntervalInSeconds")
    private Long syncIntervalInSeconds;

    /*
     * Parameters to authenticate using Service Principal.
     */
    @JsonProperty(value = "servicePrincipal")
    private ServicePrincipalDefinition servicePrincipal;

    /*
     * The account key (shared key) to access the storage account
     */
    @JsonProperty(value = "accountKey")
    private String accountKey;

    /*
     * The Shared Access token to access the storage container
     */
    @JsonProperty(value = "sasToken")
    private String sasToken;

    /*
     * Parameters to authenticate using a Managed Identity.
     */
    @JsonProperty(value = "managedIdentity")
    private ManagedIdentityDefinition managedIdentity;

    /*
     * Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or
     * user-provided configuration secrets.
     */
    @JsonProperty(value = "localAuthRef")
    private String localAuthRef;

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

    /**
     * Get the url property: The URL to sync for the flux configuration Azure Blob storage account.
     *
     * @return the url value.
     */
    public String url() {
        return this.url;
    }

    /**
     * Set the url property: The URL to sync for the flux configuration Azure Blob storage account.
     *
     * @param url the url value to set.
     * @return the AzureBlobDefinition object itself.
     */
    public AzureBlobDefinition withUrl(String url) {
        this.url = url;
        return this;
    }

    /**
     * Get the containerName property: The Azure Blob container name to sync from the url endpoint for the flux
     * configuration.
     *
     * @return the containerName value.
     */
    public String containerName() {
        return this.containerName;
    }

    /**
     * Set the containerName property: The Azure Blob container name to sync from the url endpoint for the flux
     * configuration.
     *
     * @param containerName the containerName value to set.
     * @return the AzureBlobDefinition object itself.
     */
    public AzureBlobDefinition withContainerName(String containerName) {
        this.containerName = containerName;
        return this;
    }

    /**
     * Get the timeoutInSeconds property: The maximum time to attempt to reconcile the cluster Azure Blob source with
     * the remote.
     *
     * @return the timeoutInSeconds value.
     */
    public Long timeoutInSeconds() {
        return this.timeoutInSeconds;
    }

    /**
     * Set the timeoutInSeconds property: The maximum time to attempt to reconcile the cluster Azure Blob source with
     * the remote.
     *
     * @param timeoutInSeconds the timeoutInSeconds value to set.
     * @return the AzureBlobDefinition object itself.
     */
    public AzureBlobDefinition withTimeoutInSeconds(Long timeoutInSeconds) {
        this.timeoutInSeconds = timeoutInSeconds;
        return this;
    }

    /**
     * Get the syncIntervalInSeconds property: The interval at which to re-reconcile the cluster Azure Blob source with
     * the remote.
     *
     * @return the syncIntervalInSeconds value.
     */
    public Long syncIntervalInSeconds() {
        return this.syncIntervalInSeconds;
    }

    /**
     * Set the syncIntervalInSeconds property: The interval at which to re-reconcile the cluster Azure Blob source with
     * the remote.
     *
     * @param syncIntervalInSeconds the syncIntervalInSeconds value to set.
     * @return the AzureBlobDefinition object itself.
     */
    public AzureBlobDefinition withSyncIntervalInSeconds(Long syncIntervalInSeconds) {
        this.syncIntervalInSeconds = syncIntervalInSeconds;
        return this;
    }

    /**
     * Get the servicePrincipal property: Parameters to authenticate using Service Principal.
     *
     * @return the servicePrincipal value.
     */
    public ServicePrincipalDefinition servicePrincipal() {
        return this.servicePrincipal;
    }

    /**
     * Set the servicePrincipal property: Parameters to authenticate using Service Principal.
     *
     * @param servicePrincipal the servicePrincipal value to set.
     * @return the AzureBlobDefinition object itself.
     */
    public AzureBlobDefinition withServicePrincipal(ServicePrincipalDefinition servicePrincipal) {
        this.servicePrincipal = servicePrincipal;
        return this;
    }

    /**
     * Get the accountKey property: The account key (shared key) to access the storage account.
     *
     * @return the accountKey value.
     */
    public String accountKey() {
        return this.accountKey;
    }

    /**
     * Set the accountKey property: The account key (shared key) to access the storage account.
     *
     * @param accountKey the accountKey value to set.
     * @return the AzureBlobDefinition object itself.
     */
    public AzureBlobDefinition withAccountKey(String accountKey) {
        this.accountKey = accountKey;
        return this;
    }

    /**
     * Get the sasToken property: The Shared Access token to access the storage container.
     *
     * @return the sasToken value.
     */
    public String sasToken() {
        return this.sasToken;
    }

    /**
     * Set the sasToken property: The Shared Access token to access the storage container.
     *
     * @param sasToken the sasToken value to set.
     * @return the AzureBlobDefinition object itself.
     */
    public AzureBlobDefinition withSasToken(String sasToken) {
        this.sasToken = sasToken;
        return this;
    }

    /**
     * Get the managedIdentity property: Parameters to authenticate using a Managed Identity.
     *
     * @return the managedIdentity value.
     */
    public ManagedIdentityDefinition managedIdentity() {
        return this.managedIdentity;
    }

    /**
     * Set the managedIdentity property: Parameters to authenticate using a Managed Identity.
     *
     * @param managedIdentity the managedIdentity value to set.
     * @return the AzureBlobDefinition object itself.
     */
    public AzureBlobDefinition withManagedIdentity(ManagedIdentityDefinition managedIdentity) {
        this.managedIdentity = managedIdentity;
        return this;
    }

    /**
     * Get the localAuthRef property: Name of a local secret on the Kubernetes cluster to use as the authentication
     * secret rather than the managed or user-provided configuration secrets.
     *
     * @return the localAuthRef value.
     */
    public String localAuthRef() {
        return this.localAuthRef;
    }

    /**
     * Set the localAuthRef property: Name of a local secret on the Kubernetes cluster to use as the authentication
     * secret rather than the managed or user-provided configuration secrets.
     *
     * @param localAuthRef the localAuthRef value to set.
     * @return the AzureBlobDefinition object itself.
     */
    public AzureBlobDefinition withLocalAuthRef(String localAuthRef) {
        this.localAuthRef = localAuthRef;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (servicePrincipal() != null) {
            servicePrincipal().validate();
        }
        if (managedIdentity() != null) {
            managedIdentity().validate();
        }
    }
}
