// 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.catalog.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Post;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
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.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in Collections. */
public final class CollectionsImpl {
    /** The proxy service used to perform REST calls. */
    private final CollectionsService service;

    /** The service client containing this operation class. */
    private final PurviewCatalogClientImpl client;

    /**
     * Initializes an instance of CollectionsImpl.
     *
     * @param client the instance of the service client containing this operation class.
     */
    CollectionsImpl(PurviewCatalogClientImpl client) {
        this.service =
                RestProxy.create(CollectionsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for PurviewCatalogClientCollections to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{Endpoint}/catalog/api")
    @ServiceInterface(name = "PurviewCatalogClient")
    public interface CollectionsService {
        @Post("/collections/{collection}/entity")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> createOrUpdate(
                @HostParam("Endpoint") String endpoint,
                @PathParam("collection") String collection,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData entity,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/collections/{collection}/entity")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> createOrUpdateSync(
                @HostParam("Endpoint") String endpoint,
                @PathParam("collection") String collection,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData entity,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/collections/{collection}/entity/bulk")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> createOrUpdateBulk(
                @HostParam("Endpoint") String endpoint,
                @PathParam("collection") String collection,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData entities,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/collections/{collection}/entity/bulk")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> createOrUpdateBulkSync(
                @HostParam("Endpoint") String endpoint,
                @PathParam("collection") String collection,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData entities,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/collections/{collection}/entity/moveHere")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> moveEntitiesToCollection(
                @HostParam("Endpoint") String endpoint,
                @PathParam("collection") String collection,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData moveEntitiesRequest,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/collections/{collection}/entity/moveHere")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> moveEntitiesToCollectionSync(
                @HostParam("Endpoint") String endpoint,
                @PathParam("collection") String collection,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData moveEntitiesRequest,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);
    }

    /**
     * Creates or updates an entity to a collection. Existing entity is matched using its unique guid if supplied or by
     * its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g.,
     * array&lt;array&lt;int&gt;&gt;, array&lt;map&lt;string, int&gt;&gt;.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     referredEntities (Optional): {
     *         String (Optional): {
     *             attributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             typeName: String (Optional)
     *             lastModifiedTS: String (Optional)
     *             businessAttributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             classifications (Optional): [
     *                  (Optional){
     *                     attributes (Optional): {
     *                         String: Object (Optional)
     *                     }
     *                     typeName: String (Optional)
     *                     lastModifiedTS: String (Optional)
     *                     entityGuid: String (Optional)
     *                     entityStatus: String(ACTIVE/DELETED) (Optional)
     *                     removePropagationsOnEntityDelete: Boolean (Optional)
     *                     validityPeriods (Optional): [
     *                          (Optional){
     *                             endTime: String (Optional)
     *                             startTime: String (Optional)
     *                             timeZone: String (Optional)
     *                         }
     *                     ]
     *                     source: String (Optional)
     *                     sourceDetails (Optional): {
     *                         String: Object (Optional)
     *                     }
     *                 }
     *             ]
     *             createTime: Float (Optional)
     *             createdBy: String (Optional)
     *             customAttributes (Optional): {
     *                 String: String (Optional)
     *             }
     *             guid: String (Optional)
     *             homeId: String (Optional)
     *             isIncomplete: Boolean (Optional)
     *             labels (Optional): [
     *                 String (Optional)
     *             ]
     *             meanings (Optional): [
     *                  (Optional){
     *                     confidence: Integer (Optional)
     *                     createdBy: String (Optional)
     *                     description: String (Optional)
     *                     displayText: String (Optional)
     *                     expression: String (Optional)
     *                     relationGuid: String (Optional)
     *                     source: String (Optional)
     *                     status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                     steward: String (Optional)
     *                     termGuid: String (Optional)
     *                 }
     *             ]
     *             provenanceType: Float (Optional)
     *             proxy: Boolean (Optional)
     *             relationshipAttributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             status: String(ACTIVE/DELETED) (Optional)
     *             updateTime: Float (Optional)
     *             updatedBy: String (Optional)
     *             version: Float (Optional)
     *             source: String (Optional)
     *             sourceDetails (Optional): {
     *                 String: Object (Optional)
     *             }
     *             contacts (Optional): {
     *                 String (Optional): [
     *                      (Optional){
     *                         id: String (Optional)
     *                         info: String (Optional)
     *                     }
     *                 ]
     *             }
     *         }
     *     }
     *     entity (Optional): (recursive schema, see entity above)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     guidAssignments (Optional): {
     *         String: String (Optional)
     *     }
     *     mutatedEntities (Optional): {
     *         String (Optional): [
     *              (Optional){
     *                 attributes (Optional): {
     *                     String: Object (Optional)
     *                 }
     *                 typeName: String (Optional)
     *                 lastModifiedTS: String (Optional)
     *                 classificationNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 classifications (Optional): [
     *                      (Optional){
     *                         attributes (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                         typeName: String (Optional)
     *                         lastModifiedTS: String (Optional)
     *                         entityGuid: String (Optional)
     *                         entityStatus: String(ACTIVE/DELETED) (Optional)
     *                         removePropagationsOnEntityDelete: Boolean (Optional)
     *                         validityPeriods (Optional): [
     *                              (Optional){
     *                                 endTime: String (Optional)
     *                                 startTime: String (Optional)
     *                                 timeZone: String (Optional)
     *                             }
     *                         ]
     *                         source: String (Optional)
     *                         sourceDetails (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                     }
     *                 ]
     *                 displayText: String (Optional)
     *                 guid: String (Optional)
     *                 isIncomplete: Boolean (Optional)
     *                 labels (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meaningNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meanings (Optional): [
     *                      (Optional){
     *                         confidence: Integer (Optional)
     *                         createdBy: String (Optional)
     *                         description: String (Optional)
     *                         displayText: String (Optional)
     *                         expression: String (Optional)
     *                         relationGuid: String (Optional)
     *                         source: String (Optional)
     *                         status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                         steward: String (Optional)
     *                         termGuid: String (Optional)
     *                     }
     *                 ]
     *                 status: String(ACTIVE/DELETED) (Optional)
     *             }
     *         ]
     *     }
     *     partialUpdatedEntities (Optional): [
     *         (recursive schema, see above)
     *     ]
     * }
     * }</pre>
     *
     * @param collection the collection unique name.
     * @param entity Atlas entity with extended information.
     * @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 entityMutationResponse along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> createOrUpdateWithResponseAsync(
            String collection, BinaryData entity, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createOrUpdate(
                                this.client.getEndpoint(),
                                collection,
                                this.client.getServiceVersion().getVersion(),
                                entity,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Creates or updates an entity to a collection. Existing entity is matched using its unique guid if supplied or by
     * its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g.,
     * array&lt;array&lt;int&gt;&gt;, array&lt;map&lt;string, int&gt;&gt;.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     referredEntities (Optional): {
     *         String (Optional): {
     *             attributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             typeName: String (Optional)
     *             lastModifiedTS: String (Optional)
     *             businessAttributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             classifications (Optional): [
     *                  (Optional){
     *                     attributes (Optional): {
     *                         String: Object (Optional)
     *                     }
     *                     typeName: String (Optional)
     *                     lastModifiedTS: String (Optional)
     *                     entityGuid: String (Optional)
     *                     entityStatus: String(ACTIVE/DELETED) (Optional)
     *                     removePropagationsOnEntityDelete: Boolean (Optional)
     *                     validityPeriods (Optional): [
     *                          (Optional){
     *                             endTime: String (Optional)
     *                             startTime: String (Optional)
     *                             timeZone: String (Optional)
     *                         }
     *                     ]
     *                     source: String (Optional)
     *                     sourceDetails (Optional): {
     *                         String: Object (Optional)
     *                     }
     *                 }
     *             ]
     *             createTime: Float (Optional)
     *             createdBy: String (Optional)
     *             customAttributes (Optional): {
     *                 String: String (Optional)
     *             }
     *             guid: String (Optional)
     *             homeId: String (Optional)
     *             isIncomplete: Boolean (Optional)
     *             labels (Optional): [
     *                 String (Optional)
     *             ]
     *             meanings (Optional): [
     *                  (Optional){
     *                     confidence: Integer (Optional)
     *                     createdBy: String (Optional)
     *                     description: String (Optional)
     *                     displayText: String (Optional)
     *                     expression: String (Optional)
     *                     relationGuid: String (Optional)
     *                     source: String (Optional)
     *                     status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                     steward: String (Optional)
     *                     termGuid: String (Optional)
     *                 }
     *             ]
     *             provenanceType: Float (Optional)
     *             proxy: Boolean (Optional)
     *             relationshipAttributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             status: String(ACTIVE/DELETED) (Optional)
     *             updateTime: Float (Optional)
     *             updatedBy: String (Optional)
     *             version: Float (Optional)
     *             source: String (Optional)
     *             sourceDetails (Optional): {
     *                 String: Object (Optional)
     *             }
     *             contacts (Optional): {
     *                 String (Optional): [
     *                      (Optional){
     *                         id: String (Optional)
     *                         info: String (Optional)
     *                     }
     *                 ]
     *             }
     *         }
     *     }
     *     entity (Optional): (recursive schema, see entity above)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     guidAssignments (Optional): {
     *         String: String (Optional)
     *     }
     *     mutatedEntities (Optional): {
     *         String (Optional): [
     *              (Optional){
     *                 attributes (Optional): {
     *                     String: Object (Optional)
     *                 }
     *                 typeName: String (Optional)
     *                 lastModifiedTS: String (Optional)
     *                 classificationNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 classifications (Optional): [
     *                      (Optional){
     *                         attributes (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                         typeName: String (Optional)
     *                         lastModifiedTS: String (Optional)
     *                         entityGuid: String (Optional)
     *                         entityStatus: String(ACTIVE/DELETED) (Optional)
     *                         removePropagationsOnEntityDelete: Boolean (Optional)
     *                         validityPeriods (Optional): [
     *                              (Optional){
     *                                 endTime: String (Optional)
     *                                 startTime: String (Optional)
     *                                 timeZone: String (Optional)
     *                             }
     *                         ]
     *                         source: String (Optional)
     *                         sourceDetails (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                     }
     *                 ]
     *                 displayText: String (Optional)
     *                 guid: String (Optional)
     *                 isIncomplete: Boolean (Optional)
     *                 labels (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meaningNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meanings (Optional): [
     *                      (Optional){
     *                         confidence: Integer (Optional)
     *                         createdBy: String (Optional)
     *                         description: String (Optional)
     *                         displayText: String (Optional)
     *                         expression: String (Optional)
     *                         relationGuid: String (Optional)
     *                         source: String (Optional)
     *                         status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                         steward: String (Optional)
     *                         termGuid: String (Optional)
     *                     }
     *                 ]
     *                 status: String(ACTIVE/DELETED) (Optional)
     *             }
     *         ]
     *     }
     *     partialUpdatedEntities (Optional): [
     *         (recursive schema, see above)
     *     ]
     * }
     * }</pre>
     *
     * @param collection the collection unique name.
     * @param entity Atlas entity with extended information.
     * @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 entityMutationResponse along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> createOrUpdateWithResponse(
            String collection, BinaryData entity, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.createOrUpdateSync(
                this.client.getEndpoint(),
                collection,
                this.client.getServiceVersion().getVersion(),
                entity,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Creates or updates entities in bulk to a collection. Existing entity is matched using its unique guid if supplied
     * or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g.,
     * array&lt;array&lt;int&gt;&gt;, array&lt;map&lt;string, int&gt;&gt;.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     referredEntities (Optional): {
     *         String (Optional): {
     *             attributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             typeName: String (Optional)
     *             lastModifiedTS: String (Optional)
     *             businessAttributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             classifications (Optional): [
     *                  (Optional){
     *                     attributes (Optional): {
     *                         String: Object (Optional)
     *                     }
     *                     typeName: String (Optional)
     *                     lastModifiedTS: String (Optional)
     *                     entityGuid: String (Optional)
     *                     entityStatus: String(ACTIVE/DELETED) (Optional)
     *                     removePropagationsOnEntityDelete: Boolean (Optional)
     *                     validityPeriods (Optional): [
     *                          (Optional){
     *                             endTime: String (Optional)
     *                             startTime: String (Optional)
     *                             timeZone: String (Optional)
     *                         }
     *                     ]
     *                     source: String (Optional)
     *                     sourceDetails (Optional): {
     *                         String: Object (Optional)
     *                     }
     *                 }
     *             ]
     *             createTime: Float (Optional)
     *             createdBy: String (Optional)
     *             customAttributes (Optional): {
     *                 String: String (Optional)
     *             }
     *             guid: String (Optional)
     *             homeId: String (Optional)
     *             isIncomplete: Boolean (Optional)
     *             labels (Optional): [
     *                 String (Optional)
     *             ]
     *             meanings (Optional): [
     *                  (Optional){
     *                     confidence: Integer (Optional)
     *                     createdBy: String (Optional)
     *                     description: String (Optional)
     *                     displayText: String (Optional)
     *                     expression: String (Optional)
     *                     relationGuid: String (Optional)
     *                     source: String (Optional)
     *                     status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                     steward: String (Optional)
     *                     termGuid: String (Optional)
     *                 }
     *             ]
     *             provenanceType: Float (Optional)
     *             proxy: Boolean (Optional)
     *             relationshipAttributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             status: String(ACTIVE/DELETED) (Optional)
     *             updateTime: Float (Optional)
     *             updatedBy: String (Optional)
     *             version: Float (Optional)
     *             source: String (Optional)
     *             sourceDetails (Optional): {
     *                 String: Object (Optional)
     *             }
     *             contacts (Optional): {
     *                 String (Optional): [
     *                      (Optional){
     *                         id: String (Optional)
     *                         info: String (Optional)
     *                     }
     *                 ]
     *             }
     *         }
     *     }
     *     entities (Optional): [
     *         (recursive schema, see above)
     *     ]
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     guidAssignments (Optional): {
     *         String: String (Optional)
     *     }
     *     mutatedEntities (Optional): {
     *         String (Optional): [
     *              (Optional){
     *                 attributes (Optional): {
     *                     String: Object (Optional)
     *                 }
     *                 typeName: String (Optional)
     *                 lastModifiedTS: String (Optional)
     *                 classificationNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 classifications (Optional): [
     *                      (Optional){
     *                         attributes (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                         typeName: String (Optional)
     *                         lastModifiedTS: String (Optional)
     *                         entityGuid: String (Optional)
     *                         entityStatus: String(ACTIVE/DELETED) (Optional)
     *                         removePropagationsOnEntityDelete: Boolean (Optional)
     *                         validityPeriods (Optional): [
     *                              (Optional){
     *                                 endTime: String (Optional)
     *                                 startTime: String (Optional)
     *                                 timeZone: String (Optional)
     *                             }
     *                         ]
     *                         source: String (Optional)
     *                         sourceDetails (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                     }
     *                 ]
     *                 displayText: String (Optional)
     *                 guid: String (Optional)
     *                 isIncomplete: Boolean (Optional)
     *                 labels (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meaningNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meanings (Optional): [
     *                      (Optional){
     *                         confidence: Integer (Optional)
     *                         createdBy: String (Optional)
     *                         description: String (Optional)
     *                         displayText: String (Optional)
     *                         expression: String (Optional)
     *                         relationGuid: String (Optional)
     *                         source: String (Optional)
     *                         status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                         steward: String (Optional)
     *                         termGuid: String (Optional)
     *                     }
     *                 ]
     *                 status: String(ACTIVE/DELETED) (Optional)
     *             }
     *         ]
     *     }
     *     partialUpdatedEntities (Optional): [
     *         (recursive schema, see above)
     *     ]
     * }
     * }</pre>
     *
     * @param collection the collection unique name.
     * @param entities Atlas entities with extended information.
     * @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 entityMutationResponse along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> createOrUpdateBulkWithResponseAsync(
            String collection, BinaryData entities, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createOrUpdateBulk(
                                this.client.getEndpoint(),
                                collection,
                                this.client.getServiceVersion().getVersion(),
                                entities,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Creates or updates entities in bulk to a collection. Existing entity is matched using its unique guid if supplied
     * or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g.,
     * array&lt;array&lt;int&gt;&gt;, array&lt;map&lt;string, int&gt;&gt;.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     referredEntities (Optional): {
     *         String (Optional): {
     *             attributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             typeName: String (Optional)
     *             lastModifiedTS: String (Optional)
     *             businessAttributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             classifications (Optional): [
     *                  (Optional){
     *                     attributes (Optional): {
     *                         String: Object (Optional)
     *                     }
     *                     typeName: String (Optional)
     *                     lastModifiedTS: String (Optional)
     *                     entityGuid: String (Optional)
     *                     entityStatus: String(ACTIVE/DELETED) (Optional)
     *                     removePropagationsOnEntityDelete: Boolean (Optional)
     *                     validityPeriods (Optional): [
     *                          (Optional){
     *                             endTime: String (Optional)
     *                             startTime: String (Optional)
     *                             timeZone: String (Optional)
     *                         }
     *                     ]
     *                     source: String (Optional)
     *                     sourceDetails (Optional): {
     *                         String: Object (Optional)
     *                     }
     *                 }
     *             ]
     *             createTime: Float (Optional)
     *             createdBy: String (Optional)
     *             customAttributes (Optional): {
     *                 String: String (Optional)
     *             }
     *             guid: String (Optional)
     *             homeId: String (Optional)
     *             isIncomplete: Boolean (Optional)
     *             labels (Optional): [
     *                 String (Optional)
     *             ]
     *             meanings (Optional): [
     *                  (Optional){
     *                     confidence: Integer (Optional)
     *                     createdBy: String (Optional)
     *                     description: String (Optional)
     *                     displayText: String (Optional)
     *                     expression: String (Optional)
     *                     relationGuid: String (Optional)
     *                     source: String (Optional)
     *                     status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                     steward: String (Optional)
     *                     termGuid: String (Optional)
     *                 }
     *             ]
     *             provenanceType: Float (Optional)
     *             proxy: Boolean (Optional)
     *             relationshipAttributes (Optional): {
     *                 String: Object (Optional)
     *             }
     *             status: String(ACTIVE/DELETED) (Optional)
     *             updateTime: Float (Optional)
     *             updatedBy: String (Optional)
     *             version: Float (Optional)
     *             source: String (Optional)
     *             sourceDetails (Optional): {
     *                 String: Object (Optional)
     *             }
     *             contacts (Optional): {
     *                 String (Optional): [
     *                      (Optional){
     *                         id: String (Optional)
     *                         info: String (Optional)
     *                     }
     *                 ]
     *             }
     *         }
     *     }
     *     entities (Optional): [
     *         (recursive schema, see above)
     *     ]
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     guidAssignments (Optional): {
     *         String: String (Optional)
     *     }
     *     mutatedEntities (Optional): {
     *         String (Optional): [
     *              (Optional){
     *                 attributes (Optional): {
     *                     String: Object (Optional)
     *                 }
     *                 typeName: String (Optional)
     *                 lastModifiedTS: String (Optional)
     *                 classificationNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 classifications (Optional): [
     *                      (Optional){
     *                         attributes (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                         typeName: String (Optional)
     *                         lastModifiedTS: String (Optional)
     *                         entityGuid: String (Optional)
     *                         entityStatus: String(ACTIVE/DELETED) (Optional)
     *                         removePropagationsOnEntityDelete: Boolean (Optional)
     *                         validityPeriods (Optional): [
     *                              (Optional){
     *                                 endTime: String (Optional)
     *                                 startTime: String (Optional)
     *                                 timeZone: String (Optional)
     *                             }
     *                         ]
     *                         source: String (Optional)
     *                         sourceDetails (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                     }
     *                 ]
     *                 displayText: String (Optional)
     *                 guid: String (Optional)
     *                 isIncomplete: Boolean (Optional)
     *                 labels (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meaningNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meanings (Optional): [
     *                      (Optional){
     *                         confidence: Integer (Optional)
     *                         createdBy: String (Optional)
     *                         description: String (Optional)
     *                         displayText: String (Optional)
     *                         expression: String (Optional)
     *                         relationGuid: String (Optional)
     *                         source: String (Optional)
     *                         status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                         steward: String (Optional)
     *                         termGuid: String (Optional)
     *                     }
     *                 ]
     *                 status: String(ACTIVE/DELETED) (Optional)
     *             }
     *         ]
     *     }
     *     partialUpdatedEntities (Optional): [
     *         (recursive schema, see above)
     *     ]
     * }
     * }</pre>
     *
     * @param collection the collection unique name.
     * @param entities Atlas entities with extended information.
     * @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 entityMutationResponse along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> createOrUpdateBulkWithResponse(
            String collection, BinaryData entities, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.createOrUpdateBulkSync(
                this.client.getEndpoint(),
                collection,
                this.client.getServiceVersion().getVersion(),
                entities,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Move existing entities to the target collection.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     entityGuids (Optional): [
     *         String (Optional)
     *     ]
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     guidAssignments (Optional): {
     *         String: String (Optional)
     *     }
     *     mutatedEntities (Optional): {
     *         String (Optional): [
     *              (Optional){
     *                 attributes (Optional): {
     *                     String: Object (Optional)
     *                 }
     *                 typeName: String (Optional)
     *                 lastModifiedTS: String (Optional)
     *                 classificationNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 classifications (Optional): [
     *                      (Optional){
     *                         attributes (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                         typeName: String (Optional)
     *                         lastModifiedTS: String (Optional)
     *                         entityGuid: String (Optional)
     *                         entityStatus: String(ACTIVE/DELETED) (Optional)
     *                         removePropagationsOnEntityDelete: Boolean (Optional)
     *                         validityPeriods (Optional): [
     *                              (Optional){
     *                                 endTime: String (Optional)
     *                                 startTime: String (Optional)
     *                                 timeZone: String (Optional)
     *                             }
     *                         ]
     *                         source: String (Optional)
     *                         sourceDetails (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                     }
     *                 ]
     *                 displayText: String (Optional)
     *                 guid: String (Optional)
     *                 isIncomplete: Boolean (Optional)
     *                 labels (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meaningNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meanings (Optional): [
     *                      (Optional){
     *                         confidence: Integer (Optional)
     *                         createdBy: String (Optional)
     *                         description: String (Optional)
     *                         displayText: String (Optional)
     *                         expression: String (Optional)
     *                         relationGuid: String (Optional)
     *                         source: String (Optional)
     *                         status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                         steward: String (Optional)
     *                         termGuid: String (Optional)
     *                     }
     *                 ]
     *                 status: String(ACTIVE/DELETED) (Optional)
     *             }
     *         ]
     *     }
     *     partialUpdatedEntities (Optional): [
     *         (recursive schema, see above)
     *     ]
     * }
     * }</pre>
     *
     * @param collection the collection unique name.
     * @param moveEntitiesRequest Entity guids to be moved to target collection.
     * @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 entityMutationResponse along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> moveEntitiesToCollectionWithResponseAsync(
            String collection, BinaryData moveEntitiesRequest, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.moveEntitiesToCollection(
                                this.client.getEndpoint(),
                                collection,
                                this.client.getServiceVersion().getVersion(),
                                moveEntitiesRequest,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Move existing entities to the target collection.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     entityGuids (Optional): [
     *         String (Optional)
     *     ]
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     guidAssignments (Optional): {
     *         String: String (Optional)
     *     }
     *     mutatedEntities (Optional): {
     *         String (Optional): [
     *              (Optional){
     *                 attributes (Optional): {
     *                     String: Object (Optional)
     *                 }
     *                 typeName: String (Optional)
     *                 lastModifiedTS: String (Optional)
     *                 classificationNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 classifications (Optional): [
     *                      (Optional){
     *                         attributes (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                         typeName: String (Optional)
     *                         lastModifiedTS: String (Optional)
     *                         entityGuid: String (Optional)
     *                         entityStatus: String(ACTIVE/DELETED) (Optional)
     *                         removePropagationsOnEntityDelete: Boolean (Optional)
     *                         validityPeriods (Optional): [
     *                              (Optional){
     *                                 endTime: String (Optional)
     *                                 startTime: String (Optional)
     *                                 timeZone: String (Optional)
     *                             }
     *                         ]
     *                         source: String (Optional)
     *                         sourceDetails (Optional): {
     *                             String: Object (Optional)
     *                         }
     *                     }
     *                 ]
     *                 displayText: String (Optional)
     *                 guid: String (Optional)
     *                 isIncomplete: Boolean (Optional)
     *                 labels (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meaningNames (Optional): [
     *                     String (Optional)
     *                 ]
     *                 meanings (Optional): [
     *                      (Optional){
     *                         confidence: Integer (Optional)
     *                         createdBy: String (Optional)
     *                         description: String (Optional)
     *                         displayText: String (Optional)
     *                         expression: String (Optional)
     *                         relationGuid: String (Optional)
     *                         source: String (Optional)
     *                         status: String(DISCOVERED/PROPOSED/IMPORTED/VALIDATED/DEPRECATED/OBSOLETE/OTHER) (Optional)
     *                         steward: String (Optional)
     *                         termGuid: String (Optional)
     *                     }
     *                 ]
     *                 status: String(ACTIVE/DELETED) (Optional)
     *             }
     *         ]
     *     }
     *     partialUpdatedEntities (Optional): [
     *         (recursive schema, see above)
     *     ]
     * }
     * }</pre>
     *
     * @param collection the collection unique name.
     * @param moveEntitiesRequest Entity guids to be moved to target collection.
     * @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 entityMutationResponse along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> moveEntitiesToCollectionWithResponse(
            String collection, BinaryData moveEntitiesRequest, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.moveEntitiesToCollectionSync(
                this.client.getEndpoint(),
                collection,
                this.client.getServiceVersion().getVersion(),
                moveEntitiesRequest,
                accept,
                requestOptions,
                Context.NONE);
    }
}
