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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.kusto.models.ProvisioningState;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** Class representing the Kusto CosmosDb data connection properties. */
@Fluent
public final class CosmosDbDataConnectionProperties {
    /*
     * The case-sensitive name of the existing target table in your cluster. Retrieved data is ingested into this
     * table.
     */
    @JsonProperty(value = "tableName", required = true)
    private String tableName;

    /*
     * The name of an existing mapping rule to use when ingesting the retrieved data.
     */
    @JsonProperty(value = "mappingRuleName")
    private String mappingRuleName;

    /*
     * The resource ID of a managed system or user-assigned identity. The identity is used to authenticate with Cosmos
     * DB.
     */
    @JsonProperty(value = "managedIdentityResourceId", required = true)
    private String managedIdentityResourceId;

    /*
     * The object ID of the managed identity resource.
     */
    @JsonProperty(value = "managedIdentityObjectId", access = JsonProperty.Access.WRITE_ONLY)
    private String managedIdentityObjectId;

    /*
     * The resource ID of the Cosmos DB account used to create the data connection.
     */
    @JsonProperty(value = "cosmosDbAccountResourceId", required = true)
    private String cosmosDbAccountResourceId;

    /*
     * The name of an existing database in the Cosmos DB account.
     */
    @JsonProperty(value = "cosmosDbDatabase", required = true)
    private String cosmosDbDatabase;

    /*
     * The name of an existing container in the Cosmos DB database.
     */
    @JsonProperty(value = "cosmosDbContainer", required = true)
    private String cosmosDbContainer;

    /*
     * Optional. If defined, the data connection retrieves Cosmos DB documents created or updated after the specified
     * retrieval start date.
     */
    @JsonProperty(value = "retrievalStartDate")
    private OffsetDateTime retrievalStartDate;

    /*
     * The provisioned state of the resource.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningState provisioningState;

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

    /**
     * Get the tableName property: The case-sensitive name of the existing target table in your cluster. Retrieved data
     * is ingested into this table.
     *
     * @return the tableName value.
     */
    public String tableName() {
        return this.tableName;
    }

    /**
     * Set the tableName property: The case-sensitive name of the existing target table in your cluster. Retrieved data
     * is ingested into this table.
     *
     * @param tableName the tableName value to set.
     * @return the CosmosDbDataConnectionProperties object itself.
     */
    public CosmosDbDataConnectionProperties withTableName(String tableName) {
        this.tableName = tableName;
        return this;
    }

    /**
     * Get the mappingRuleName property: The name of an existing mapping rule to use when ingesting the retrieved data.
     *
     * @return the mappingRuleName value.
     */
    public String mappingRuleName() {
        return this.mappingRuleName;
    }

    /**
     * Set the mappingRuleName property: The name of an existing mapping rule to use when ingesting the retrieved data.
     *
     * @param mappingRuleName the mappingRuleName value to set.
     * @return the CosmosDbDataConnectionProperties object itself.
     */
    public CosmosDbDataConnectionProperties withMappingRuleName(String mappingRuleName) {
        this.mappingRuleName = mappingRuleName;
        return this;
    }

    /**
     * Get the managedIdentityResourceId property: The resource ID of a managed system or user-assigned identity. The
     * identity is used to authenticate with Cosmos DB.
     *
     * @return the managedIdentityResourceId value.
     */
    public String managedIdentityResourceId() {
        return this.managedIdentityResourceId;
    }

    /**
     * Set the managedIdentityResourceId property: The resource ID of a managed system or user-assigned identity. The
     * identity is used to authenticate with Cosmos DB.
     *
     * @param managedIdentityResourceId the managedIdentityResourceId value to set.
     * @return the CosmosDbDataConnectionProperties object itself.
     */
    public CosmosDbDataConnectionProperties withManagedIdentityResourceId(String managedIdentityResourceId) {
        this.managedIdentityResourceId = managedIdentityResourceId;
        return this;
    }

    /**
     * Get the managedIdentityObjectId property: The object ID of the managed identity resource.
     *
     * @return the managedIdentityObjectId value.
     */
    public String managedIdentityObjectId() {
        return this.managedIdentityObjectId;
    }

    /**
     * Get the cosmosDbAccountResourceId property: The resource ID of the Cosmos DB account used to create the data
     * connection.
     *
     * @return the cosmosDbAccountResourceId value.
     */
    public String cosmosDbAccountResourceId() {
        return this.cosmosDbAccountResourceId;
    }

    /**
     * Set the cosmosDbAccountResourceId property: The resource ID of the Cosmos DB account used to create the data
     * connection.
     *
     * @param cosmosDbAccountResourceId the cosmosDbAccountResourceId value to set.
     * @return the CosmosDbDataConnectionProperties object itself.
     */
    public CosmosDbDataConnectionProperties withCosmosDbAccountResourceId(String cosmosDbAccountResourceId) {
        this.cosmosDbAccountResourceId = cosmosDbAccountResourceId;
        return this;
    }

    /**
     * Get the cosmosDbDatabase property: The name of an existing database in the Cosmos DB account.
     *
     * @return the cosmosDbDatabase value.
     */
    public String cosmosDbDatabase() {
        return this.cosmosDbDatabase;
    }

    /**
     * Set the cosmosDbDatabase property: The name of an existing database in the Cosmos DB account.
     *
     * @param cosmosDbDatabase the cosmosDbDatabase value to set.
     * @return the CosmosDbDataConnectionProperties object itself.
     */
    public CosmosDbDataConnectionProperties withCosmosDbDatabase(String cosmosDbDatabase) {
        this.cosmosDbDatabase = cosmosDbDatabase;
        return this;
    }

    /**
     * Get the cosmosDbContainer property: The name of an existing container in the Cosmos DB database.
     *
     * @return the cosmosDbContainer value.
     */
    public String cosmosDbContainer() {
        return this.cosmosDbContainer;
    }

    /**
     * Set the cosmosDbContainer property: The name of an existing container in the Cosmos DB database.
     *
     * @param cosmosDbContainer the cosmosDbContainer value to set.
     * @return the CosmosDbDataConnectionProperties object itself.
     */
    public CosmosDbDataConnectionProperties withCosmosDbContainer(String cosmosDbContainer) {
        this.cosmosDbContainer = cosmosDbContainer;
        return this;
    }

    /**
     * Get the retrievalStartDate property: Optional. If defined, the data connection retrieves Cosmos DB documents
     * created or updated after the specified retrieval start date.
     *
     * @return the retrievalStartDate value.
     */
    public OffsetDateTime retrievalStartDate() {
        return this.retrievalStartDate;
    }

    /**
     * Set the retrievalStartDate property: Optional. If defined, the data connection retrieves Cosmos DB documents
     * created or updated after the specified retrieval start date.
     *
     * @param retrievalStartDate the retrievalStartDate value to set.
     * @return the CosmosDbDataConnectionProperties object itself.
     */
    public CosmosDbDataConnectionProperties withRetrievalStartDate(OffsetDateTime retrievalStartDate) {
        this.retrievalStartDate = retrievalStartDate;
        return this;
    }

    /**
     * Get the provisioningState property: The provisioned state of the resource.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (tableName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property tableName in model CosmosDbDataConnectionProperties"));
        }
        if (managedIdentityResourceId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property managedIdentityResourceId in model"
                            + " CosmosDbDataConnectionProperties"));
        }
        if (cosmosDbAccountResourceId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property cosmosDbAccountResourceId in model"
                            + " CosmosDbDataConnectionProperties"));
        }
        if (cosmosDbDatabase() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property cosmosDbDatabase in model CosmosDbDataConnectionProperties"));
        }
        if (cosmosDbContainer() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property cosmosDbContainer in model CosmosDbDataConnectionProperties"));
        }
    }

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