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

package com.azure.resourcemanager.machinelearning.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.Map;

/** Azure Data Lake Gen2 datastore configuration. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "datastoreType")
@JsonTypeName("AzureDataLakeGen2")
@Fluent
public final class AzureDataLakeGen2Datastore extends DatastoreProperties {
    /*
     * [Required] Storage account name.
     */
    @JsonProperty(value = "accountName", required = true)
    private String accountName;

    /*
     * Azure cloud endpoint for the storage account.
     */
    @JsonProperty(value = "endpoint")
    private String endpoint;

    /*
     * [Required] The name of the Data Lake Gen2 filesystem.
     */
    @JsonProperty(value = "filesystem", required = true)
    private String filesystem;

    /*
     * Protocol used to communicate with the storage account.
     */
    @JsonProperty(value = "protocol")
    private String protocol;

    /*
     * Indicates which identity to use to authenticate service data access to customer's storage.
     */
    @JsonProperty(value = "serviceDataAccessAuthIdentity")
    private ServiceDataAccessAuthIdentity serviceDataAccessAuthIdentity;

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

    /**
     * Get the accountName property: [Required] Storage account name.
     *
     * @return the accountName value.
     */
    public String accountName() {
        return this.accountName;
    }

    /**
     * Set the accountName property: [Required] Storage account name.
     *
     * @param accountName the accountName value to set.
     * @return the AzureDataLakeGen2Datastore object itself.
     */
    public AzureDataLakeGen2Datastore withAccountName(String accountName) {
        this.accountName = accountName;
        return this;
    }

    /**
     * Get the endpoint property: Azure cloud endpoint for the storage account.
     *
     * @return the endpoint value.
     */
    public String endpoint() {
        return this.endpoint;
    }

    /**
     * Set the endpoint property: Azure cloud endpoint for the storage account.
     *
     * @param endpoint the endpoint value to set.
     * @return the AzureDataLakeGen2Datastore object itself.
     */
    public AzureDataLakeGen2Datastore withEndpoint(String endpoint) {
        this.endpoint = endpoint;
        return this;
    }

    /**
     * Get the filesystem property: [Required] The name of the Data Lake Gen2 filesystem.
     *
     * @return the filesystem value.
     */
    public String filesystem() {
        return this.filesystem;
    }

    /**
     * Set the filesystem property: [Required] The name of the Data Lake Gen2 filesystem.
     *
     * @param filesystem the filesystem value to set.
     * @return the AzureDataLakeGen2Datastore object itself.
     */
    public AzureDataLakeGen2Datastore withFilesystem(String filesystem) {
        this.filesystem = filesystem;
        return this;
    }

    /**
     * Get the protocol property: Protocol used to communicate with the storage account.
     *
     * @return the protocol value.
     */
    public String protocol() {
        return this.protocol;
    }

    /**
     * Set the protocol property: Protocol used to communicate with the storage account.
     *
     * @param protocol the protocol value to set.
     * @return the AzureDataLakeGen2Datastore object itself.
     */
    public AzureDataLakeGen2Datastore withProtocol(String protocol) {
        this.protocol = protocol;
        return this;
    }

    /**
     * Get the serviceDataAccessAuthIdentity property: Indicates which identity to use to authenticate service data
     * access to customer's storage.
     *
     * @return the serviceDataAccessAuthIdentity value.
     */
    public ServiceDataAccessAuthIdentity serviceDataAccessAuthIdentity() {
        return this.serviceDataAccessAuthIdentity;
    }

    /**
     * Set the serviceDataAccessAuthIdentity property: Indicates which identity to use to authenticate service data
     * access to customer's storage.
     *
     * @param serviceDataAccessAuthIdentity the serviceDataAccessAuthIdentity value to set.
     * @return the AzureDataLakeGen2Datastore object itself.
     */
    public AzureDataLakeGen2Datastore withServiceDataAccessAuthIdentity(
        ServiceDataAccessAuthIdentity serviceDataAccessAuthIdentity) {
        this.serviceDataAccessAuthIdentity = serviceDataAccessAuthIdentity;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public AzureDataLakeGen2Datastore withCredentials(DatastoreCredentials credentials) {
        super.withCredentials(credentials);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public AzureDataLakeGen2Datastore withDescription(String description) {
        super.withDescription(description);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public AzureDataLakeGen2Datastore withProperties(Map<String, String> properties) {
        super.withProperties(properties);
        return this;
    }

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

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

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