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

package com.azure.analytics.purview.administration;

import com.azure.analytics.purview.administration.implementation.CollectionsImpl;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
import reactor.core.publisher.Mono;

/** Initializes a new instance of the asynchronous PurviewAccountClient type. */
@ServiceClient(builder = CollectionsClientBuilder.class, isAsync = true)
public final class CollectionsAsyncClient {
    @Generated private final CollectionsImpl serviceClient;

    /**
     * Initializes an instance of CollectionsAsyncClient class.
     *
     * @param serviceClient the service client implementation.
     */
    @Generated
    CollectionsAsyncClient(CollectionsImpl serviceClient) {
        this.serviceClient = serviceClient;
    }

    /**
     * Get a collection.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     collectionProvisioningState: String(Unknown/Creating/Moving/Deleting/Failed/Succeeded) (Optional)
     *     description: String (Optional)
     *     friendlyName: String (Optional)
     *     name: String (Optional)
     *     parentCollection (Optional): {
     *         referenceName: String (Optional)
     *         type: String (Optional)
     *     }
     *     systemData (Optional): {
     *         createdAt: OffsetDateTime (Optional)
     *         createdBy: String (Optional)
     *         createdByType: String(User/Application/ManagedIdentity/Key) (Optional)
     *         lastModifiedAt: OffsetDateTime (Optional)
     *         lastModifiedBy: String (Optional)
     *         lastModifiedByType: String(User/Application/ManagedIdentity/Key) (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param collectionName The collectionName parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a collection along with {@link Response} on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getCollectionWithResponse(String collectionName, RequestOptions requestOptions) {
        return this.serviceClient.getCollectionWithResponseAsync(collectionName, requestOptions);
    }

    /**
     * Creates or updates a collection entity.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     collectionProvisioningState: String(Unknown/Creating/Moving/Deleting/Failed/Succeeded) (Optional)
     *     description: String (Optional)
     *     friendlyName: String (Optional)
     *     name: String (Optional)
     *     parentCollection (Optional): {
     *         referenceName: String (Optional)
     *         type: String (Optional)
     *     }
     *     systemData (Optional): {
     *         createdAt: OffsetDateTime (Optional)
     *         createdBy: String (Optional)
     *         createdByType: String(User/Application/ManagedIdentity/Key) (Optional)
     *         lastModifiedAt: OffsetDateTime (Optional)
     *         lastModifiedBy: String (Optional)
     *         lastModifiedByType: String(User/Application/ManagedIdentity/Key) (Optional)
     *     }
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     collectionProvisioningState: String(Unknown/Creating/Moving/Deleting/Failed/Succeeded) (Optional)
     *     description: String (Optional)
     *     friendlyName: String (Optional)
     *     name: String (Optional)
     *     parentCollection (Optional): {
     *         referenceName: String (Optional)
     *         type: String (Optional)
     *     }
     *     systemData (Optional): {
     *         createdAt: OffsetDateTime (Optional)
     *         createdBy: String (Optional)
     *         createdByType: String(User/Application/ManagedIdentity/Key) (Optional)
     *         lastModifiedAt: OffsetDateTime (Optional)
     *         lastModifiedBy: String (Optional)
     *         lastModifiedByType: String(User/Application/ManagedIdentity/Key) (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param collectionName The collectionName parameter.
     * @param collection Collection resource.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return collection resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> createOrUpdateCollectionWithResponse(
            String collectionName, BinaryData collection, RequestOptions requestOptions) {
        return this.serviceClient.createOrUpdateCollectionWithResponseAsync(collectionName, collection, requestOptions);
    }

    /**
     * Deletes a Collection entity.
     *
     * @param collectionName The collectionName parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> deleteCollectionWithResponse(String collectionName, RequestOptions requestOptions) {
        return this.serviceClient.deleteCollectionWithResponseAsync(collectionName, requestOptions);
    }

    /**
     * List the collections in the account.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>$skipToken</td><td>String</td><td>No</td><td>The skipToken parameter</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     collectionProvisioningState: String(Unknown/Creating/Moving/Deleting/Failed/Succeeded) (Optional)
     *     description: String (Optional)
     *     friendlyName: String (Optional)
     *     name: String (Optional)
     *     parentCollection (Optional): {
     *         referenceName: String (Optional)
     *         type: String (Optional)
     *     }
     *     systemData (Optional): {
     *         createdAt: OffsetDateTime (Optional)
     *         createdBy: String (Optional)
     *         createdByType: String(User/Application/ManagedIdentity/Key) (Optional)
     *         lastModifiedAt: OffsetDateTime (Optional)
     *         lastModifiedBy: String (Optional)
     *         lastModifiedByType: String(User/Application/ManagedIdentity/Key) (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return paged list of collections as paginated response with {@link PagedFlux}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listCollections(RequestOptions requestOptions) {
        return this.serviceClient.listCollectionsAsync(requestOptions);
    }

    /**
     * Lists the child collections names in the collection.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>$skipToken</td><td>String</td><td>No</td><td>The skipToken parameter</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     friendlyName: String (Optional)
     *     name: String (Optional)
     * }
     * }</pre>
     *
     * @param collectionName The collectionName parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return paged list of collections as paginated response with {@link PagedFlux}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listChildCollectionNames(String collectionName, RequestOptions requestOptions) {
        return this.serviceClient.listChildCollectionNamesAsync(collectionName, requestOptions);
    }

    /**
     * Gets the parent name and parent friendly name chains that represent the collection path.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     parentFriendlyNameChain (Optional): [
     *         String (Optional)
     *     ]
     *     parentNameChain (Optional): [
     *         String (Optional)
     *     ]
     * }
     * }</pre>
     *
     * @param collectionName The collectionName parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the parent name and parent friendly name chains that represent the collection path along with {@link
     *     Response} on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getCollectionPathWithResponse(
            String collectionName, RequestOptions requestOptions) {
        return this.serviceClient.getCollectionPathWithResponseAsync(collectionName, requestOptions);
    }
}
