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

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.kusto.fluent.models.CosmosDbDataConnectionProperties;
import com.azure.resourcemanager.kusto.fluent.models.DataConnectionInner;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.time.OffsetDateTime;

/** Class representing a CosmosDb data connection. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind")
@JsonTypeName("CosmosDb")
@Fluent
public final class CosmosDbDataConnection extends DataConnectionInner {
    /*
     * The properties of the CosmosDb data connection.
     */
    @JsonProperty(value = "properties")
    private CosmosDbDataConnectionProperties innerProperties;

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

    /**
     * Get the innerProperties property: The properties of the CosmosDb data connection.
     *
     * @return the innerProperties value.
     */
    private CosmosDbDataConnectionProperties innerProperties() {
        return this.innerProperties;
    }

    /** {@inheritDoc} */
    @Override
    public CosmosDbDataConnection withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /**
     * 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.innerProperties() == null ? null : this.innerProperties().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 CosmosDbDataConnection object itself.
     */
    public CosmosDbDataConnection withTableName(String tableName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CosmosDbDataConnectionProperties();
        }
        this.innerProperties().withTableName(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.innerProperties() == null ? null : this.innerProperties().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 CosmosDbDataConnection object itself.
     */
    public CosmosDbDataConnection withMappingRuleName(String mappingRuleName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CosmosDbDataConnectionProperties();
        }
        this.innerProperties().withMappingRuleName(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.innerProperties() == null ? null : this.innerProperties().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 CosmosDbDataConnection object itself.
     */
    public CosmosDbDataConnection withManagedIdentityResourceId(String managedIdentityResourceId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CosmosDbDataConnectionProperties();
        }
        this.innerProperties().withManagedIdentityResourceId(managedIdentityResourceId);
        return this;
    }

    /**
     * Get the managedIdentityObjectId property: The object ID of the managed identity resource.
     *
     * @return the managedIdentityObjectId value.
     */
    public String managedIdentityObjectId() {
        return this.innerProperties() == null ? null : this.innerProperties().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.innerProperties() == null ? null : this.innerProperties().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 CosmosDbDataConnection object itself.
     */
    public CosmosDbDataConnection withCosmosDbAccountResourceId(String cosmosDbAccountResourceId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CosmosDbDataConnectionProperties();
        }
        this.innerProperties().withCosmosDbAccountResourceId(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.innerProperties() == null ? null : this.innerProperties().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 CosmosDbDataConnection object itself.
     */
    public CosmosDbDataConnection withCosmosDbDatabase(String cosmosDbDatabase) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CosmosDbDataConnectionProperties();
        }
        this.innerProperties().withCosmosDbDatabase(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.innerProperties() == null ? null : this.innerProperties().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 CosmosDbDataConnection object itself.
     */
    public CosmosDbDataConnection withCosmosDbContainer(String cosmosDbContainer) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CosmosDbDataConnectionProperties();
        }
        this.innerProperties().withCosmosDbContainer(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.innerProperties() == null ? null : this.innerProperties().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 CosmosDbDataConnection object itself.
     */
    public CosmosDbDataConnection withRetrievalStartDate(OffsetDateTime retrievalStartDate) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CosmosDbDataConnectionProperties();
        }
        this.innerProperties().withRetrievalStartDate(retrievalStartDate);
        return this;
    }

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

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