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

package com.azure.resourcemanager.streamanalytics.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.streamanalytics.fluent.models.DocumentDbOutputDataSourceProperties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** Describes a DocumentDB output data source. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeName("Microsoft.Storage/DocumentDB")
@Fluent
public final class DocumentDbOutputDataSource extends OutputDataSource {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(DocumentDbOutputDataSource.class);

    /*
     * The properties that are associated with a DocumentDB output. Required on
     * PUT (CreateOrReplace) requests.
     */
    @JsonProperty(value = "properties")
    private DocumentDbOutputDataSourceProperties innerProperties;

    /**
     * Get the innerProperties property: The properties that are associated with a DocumentDB output. Required on PUT
     * (CreateOrReplace) requests.
     *
     * @return the innerProperties value.
     */
    private DocumentDbOutputDataSourceProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the accountId property: The DocumentDB account name or ID. Required on PUT (CreateOrReplace) requests.
     *
     * @return the accountId value.
     */
    public String accountId() {
        return this.innerProperties() == null ? null : this.innerProperties().accountId();
    }

    /**
     * Set the accountId property: The DocumentDB account name or ID. Required on PUT (CreateOrReplace) requests.
     *
     * @param accountId the accountId value to set.
     * @return the DocumentDbOutputDataSource object itself.
     */
    public DocumentDbOutputDataSource withAccountId(String accountId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DocumentDbOutputDataSourceProperties();
        }
        this.innerProperties().withAccountId(accountId);
        return this;
    }

    /**
     * Get the accountKey property: The account key for the DocumentDB account. Required on PUT (CreateOrReplace)
     * requests.
     *
     * @return the accountKey value.
     */
    public String accountKey() {
        return this.innerProperties() == null ? null : this.innerProperties().accountKey();
    }

    /**
     * Set the accountKey property: The account key for the DocumentDB account. Required on PUT (CreateOrReplace)
     * requests.
     *
     * @param accountKey the accountKey value to set.
     * @return the DocumentDbOutputDataSource object itself.
     */
    public DocumentDbOutputDataSource withAccountKey(String accountKey) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DocumentDbOutputDataSourceProperties();
        }
        this.innerProperties().withAccountKey(accountKey);
        return this;
    }

    /**
     * Get the database property: The name of the DocumentDB database. Required on PUT (CreateOrReplace) requests.
     *
     * @return the database value.
     */
    public String database() {
        return this.innerProperties() == null ? null : this.innerProperties().database();
    }

    /**
     * Set the database property: The name of the DocumentDB database. Required on PUT (CreateOrReplace) requests.
     *
     * @param database the database value to set.
     * @return the DocumentDbOutputDataSource object itself.
     */
    public DocumentDbOutputDataSource withDatabase(String database) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DocumentDbOutputDataSourceProperties();
        }
        this.innerProperties().withDatabase(database);
        return this;
    }

    /**
     * Get the collectionNamePattern property: The collection name pattern for the collections to be used. The
     * collection name format can be constructed using the optional {partition} token, where partitions start from 0.
     * See the DocumentDB section of https://docs.microsoft.com/en-us/rest/api/streamanalytics/stream-analytics-output
     * for more information. Required on PUT (CreateOrReplace) requests.
     *
     * @return the collectionNamePattern value.
     */
    public String collectionNamePattern() {
        return this.innerProperties() == null ? null : this.innerProperties().collectionNamePattern();
    }

    /**
     * Set the collectionNamePattern property: The collection name pattern for the collections to be used. The
     * collection name format can be constructed using the optional {partition} token, where partitions start from 0.
     * See the DocumentDB section of https://docs.microsoft.com/en-us/rest/api/streamanalytics/stream-analytics-output
     * for more information. Required on PUT (CreateOrReplace) requests.
     *
     * @param collectionNamePattern the collectionNamePattern value to set.
     * @return the DocumentDbOutputDataSource object itself.
     */
    public DocumentDbOutputDataSource withCollectionNamePattern(String collectionNamePattern) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DocumentDbOutputDataSourceProperties();
        }
        this.innerProperties().withCollectionNamePattern(collectionNamePattern);
        return this;
    }

    /**
     * Get the partitionKey property: The name of the field in output events used to specify the key for partitioning
     * output across collections. If 'collectionNamePattern' contains the {partition} token, this property is required
     * to be specified.
     *
     * @return the partitionKey value.
     */
    public String partitionKey() {
        return this.innerProperties() == null ? null : this.innerProperties().partitionKey();
    }

    /**
     * Set the partitionKey property: The name of the field in output events used to specify the key for partitioning
     * output across collections. If 'collectionNamePattern' contains the {partition} token, this property is required
     * to be specified.
     *
     * @param partitionKey the partitionKey value to set.
     * @return the DocumentDbOutputDataSource object itself.
     */
    public DocumentDbOutputDataSource withPartitionKey(String partitionKey) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DocumentDbOutputDataSourceProperties();
        }
        this.innerProperties().withPartitionKey(partitionKey);
        return this;
    }

    /**
     * Get the documentId property: The name of the field in output events used to specify the primary key which insert
     * or update operations are based on.
     *
     * @return the documentId value.
     */
    public String documentId() {
        return this.innerProperties() == null ? null : this.innerProperties().documentId();
    }

    /**
     * Set the documentId property: The name of the field in output events used to specify the primary key which insert
     * or update operations are based on.
     *
     * @param documentId the documentId value to set.
     * @return the DocumentDbOutputDataSource object itself.
     */
    public DocumentDbOutputDataSource withDocumentId(String documentId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DocumentDbOutputDataSourceProperties();
        }
        this.innerProperties().withDocumentId(documentId);
        return this;
    }

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