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

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
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.Put;
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.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
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 java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import reactor.core.publisher.Mono;

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

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

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

    /**
     * The interface defining all the services for PurviewAccountClientResourceSetRules to be used by the proxy service
     * to perform REST calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "PurviewAccountClient")
    public interface ResourceSetRulesService {
        @Get("/resourceSetRuleConfigs/defaultResourceSetRuleConfig")
        @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>> getResourceSetRule(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/resourceSetRuleConfigs/defaultResourceSetRuleConfig")
        @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> getResourceSetRuleSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Put("/resourceSetRuleConfigs/defaultResourceSetRuleConfig")
        @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>> createOrUpdateResourceSetRule(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData resourceSetRuleConfig,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Put("/resourceSetRuleConfigs/defaultResourceSetRuleConfig")
        @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> createOrUpdateResourceSetRuleSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData resourceSetRuleConfig,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Delete("/resourceSetRuleConfigs/defaultResourceSetRuleConfig")
        @ExpectedResponses({200, 204})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> deleteResourceSetRule(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Delete("/resourceSetRuleConfigs/defaultResourceSetRuleConfig")
        @ExpectedResponses({200, 204})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<Void> deleteResourceSetRuleSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/resourceSetRuleConfigs")
        @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>> listResourceSetRules(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/resourceSetRuleConfigs")
        @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> listResourceSetRulesSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @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>> listResourceSetRulesNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @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> listResourceSetRulesNextSync(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);
    }

    /**
     * Get a resource set config service model.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (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 a resource set config service model along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getResourceSetRuleWithResponseAsync(RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getResourceSetRule(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Get a resource set config service model.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (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 a resource set config service model along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getResourceSetRuleWithResponse(RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.getResourceSetRuleSync(
                this.client.getEndpoint(),
                this.client.getServiceVersion().getVersion(),
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Creates or updates an resource set config.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (Optional)
     *     }
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param resourceSetRuleConfig ResourceSetRuleConfig implementation class.
     * @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 resourceSetRuleConfig implementation class along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> createOrUpdateResourceSetRuleWithResponseAsync(
            BinaryData resourceSetRuleConfig, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createOrUpdateResourceSetRule(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                resourceSetRuleConfig,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Creates or updates an resource set config.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (Optional)
     *     }
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param resourceSetRuleConfig ResourceSetRuleConfig implementation class.
     * @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 resourceSetRuleConfig implementation class along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> createOrUpdateResourceSetRuleWithResponse(
            BinaryData resourceSetRuleConfig, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.createOrUpdateResourceSetRuleSync(
                this.client.getEndpoint(),
                this.client.getServiceVersion().getVersion(),
                resourceSetRuleConfig,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Deletes a ResourceSetRuleConfig 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 the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> deleteResourceSetRuleWithResponseAsync(RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.deleteResourceSetRule(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Deletes a ResourceSetRuleConfig 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 the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteResourceSetRuleWithResponse(RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.deleteResourceSetRuleSync(
                this.client.getEndpoint(),
                this.client.getServiceVersion().getVersion(),
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Get a resource set config service model.
     *
     * <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
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (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 a resource set config service model along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listResourceSetRulesSinglePageAsync(RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listResourceSetRules(
                                        this.client.getEndpoint(),
                                        this.client.getServiceVersion().getVersion(),
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get a resource set config service model.
     *
     * <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
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (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 a resource set config service model as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listResourceSetRulesAsync(RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listResourceSetRulesSinglePageAsync(requestOptions),
                nextLink -> listResourceSetRulesNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Get a resource set config service model.
     *
     * <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
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (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 a resource set config service model along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<BinaryData> listResourceSetRulesSinglePage(RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<BinaryData> res =
                service.listResourceSetRulesSync(
                        this.client.getEndpoint(),
                        this.client.getServiceVersion().getVersion(),
                        accept,
                        requestOptions,
                        Context.NONE);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                getValues(res.getValue(), "value"),
                getNextLink(res.getValue(), "nextLink"),
                null);
    }

    /**
     * Get a resource set config service model.
     *
     * <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
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (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 a resource set config service model as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listResourceSetRules(RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedIterable<>(
                () -> listResourceSetRulesSinglePage(requestOptions),
                nextLink -> listResourceSetRulesNextSinglePage(nextLink, requestOptionsForNextPage));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink 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 account resources along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listResourceSetRulesNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listResourceSetRulesNext(
                                        nextLink, this.client.getEndpoint(), accept, requestOptions, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     advancedResourceSet (Optional): {
     *         modifiedAt: OffsetDateTime (Optional)
     *         resourceSetProcessing: String(Default/Advanced) (Optional)
     *     }
     *     name: String (Optional)
     *     pathPatternConfig (Optional): {
     *         acceptedPatterns (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 filterType: String(Pattern/Regex) (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 path: String (Required)
     *             }
     *         ]
     *         complexReplacers (Optional): [
     *              (Optional){
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Optional)
     *                 typeName: String (Optional)
     *             }
     *         ]
     *         createdBy: String (Required)
     *         enableDefaultPatterns: boolean (Required)
     *         lastUpdatedTimestamp: Long (Optional)
     *         modifiedBy: String (Optional)
     *         normalizationRules (Optional): [
     *              (Optional){
     *                 description: String (Optional)
     *                 disabled: Boolean (Optional)
     *                 dynamicReplacement: Boolean (Optional)
     *                 entityTypes (Optional): [
     *                     String (Optional)
     *                 ]
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 name: String (Optional)
     *                 regex (Optional): {
     *                     maxDigits: Integer (Optional)
     *                     maxLetters: Integer (Optional)
     *                     minDashes: Integer (Optional)
     *                     minDigits: Integer (Optional)
     *                     minDigitsOrLetters: Integer (Optional)
     *                     minDots: Integer (Optional)
     *                     minHex: Integer (Optional)
     *                     minLetters: Integer (Optional)
     *                     minUnderscores: Integer (Optional)
     *                     options: Integer (Optional)
     *                     regexStr: String (Optional)
     *                 }
     *                 replaceWith: String (Optional)
     *                 version: Double (Optional)
     *             }
     *         ]
     *         regexReplacers (Optional): [
     *              (Optional){
     *                 condition: String (Optional)
     *                 createdBy: String (Optional)
     *                 description: String (Optional)
     *                 disabled: boolean (Required)
     *                 disableRecursiveReplacerApplication: Boolean (Optional)
     *                 doNotReplaceRegex (Optional): (recursive schema, see doNotReplaceRegex above)
     *                 lastUpdatedTimestamp: Long (Optional)
     *                 modifiedBy: String (Optional)
     *                 name: String (Required)
     *                 regex (Optional): (recursive schema, see regex above)
     *                 replaceWith: String (Optional)
     *             }
     *         ]
     *         rejectedPatterns (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         scopedRules (Optional): [
     *              (Optional){
     *                 bindingUrl: String (Required)
     *                 rules (Optional): [
     *                      (Optional){
     *                         displayName: String (Optional)
     *                         isResourceSet: Boolean (Optional)
     *                         lastUpdatedTimestamp: Long (Optional)
     *                         name: String (Optional)
     *                         qualifiedName: String (Required)
     *                     }
     *                 ]
     *                 storeType: String (Required)
     *             }
     *         ]
     *         version: Integer (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink 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 account resources along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<BinaryData> listResourceSetRulesNextSinglePage(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<BinaryData> res =
                service.listResourceSetRulesNextSync(
                        nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                getValues(res.getValue(), "value"),
                getNextLink(res.getValue(), "nextLink"),
                null);
    }

    private List<BinaryData> getValues(BinaryData binaryData, String path) {
        try {
            Map<?, ?> obj = binaryData.toObject(Map.class);
            List<?> values = (List<?>) obj.get(path);
            return values.stream().map(BinaryData::fromObject).collect(Collectors.toList());
        } catch (RuntimeException e) {
            return null;
        }
    }

    private String getNextLink(BinaryData binaryData, String path) {
        try {
            Map<?, ?> obj = binaryData.toObject(Map.class);
            return (String) obj.get(path);
        } catch (RuntimeException e) {
            return null;
        }
    }
}
