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

package com.azure.analytics.purview.administration;

import com.azure.analytics.purview.administration.implementation.MetadataPoliciesImpl;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;

/** Initializes a new instance of the synchronous PurviewMetadataClient type. */
@ServiceClient(builder = MetadataPolicyClientBuilder.class)
public final class MetadataPolicyClient {
    @Generated private final MetadataPoliciesImpl serviceClient;

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

    /**
     * List or Get metadata policies.
     *
     * <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>collectionName</td><td>String</td><td>No</td><td>The name of an existing collection for which one policy needs to be fetched.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     id: String (Optional)
     *     version: Integer (Optional)
     *     properties (Optional): {
     *         description: String (Optional)
     *         decisionRules (Optional): [
     *              (Optional){
     *                 kind: String(decisionrule/attributerule) (Optional)
     *                 effect: String(Deny/Permit) (Optional)
     *                 dnfCondition (Optional): [
     *                      (Optional)[
     *                          (Optional){
     *                             attributeName: String (Optional)
     *                             attributeValueIncludes: String (Optional)
     *                             attributeValueIncludedIn (Optional): [
     *                                 String (Optional)
     *                             ]
     *                             attributeValueExcludes: String (Optional)
     *                             attributeValueExcludedIn (Optional): [
     *                                 String (Optional)
     *                             ]
     *                         }
     *                     ]
     *                 ]
     *             }
     *         ]
     *         attributeRules (Optional): [
     *              (Optional){
     *                 kind: String(decisionrule/attributerule) (Optional)
     *                 id: String (Optional)
     *                 name: String (Optional)
     *                 dnfCondition (Optional): [
     *                      (Optional)[
     *                         (recursive schema, see above)
     *                     ]
     *                 ]
     *             }
     *         ]
     *         collection (Optional): {
     *             type: String (Optional)
     *             referenceName: String (Optional)
     *         }
     *         parentCollectionName: String (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 list of Metadata Policies as paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listAll(RequestOptions requestOptions) {
        return this.serviceClient.listAll(requestOptions);
    }

    /**
     * Updates a metadata policy.
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>Content-Type</td><td>String</td><td>No</td><td>The content type. Allowed values: "application/json".</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     id: String (Optional)
     *     version: Integer (Optional)
     *     properties (Optional): {
     *         description: String (Optional)
     *         decisionRules (Optional): [
     *              (Optional){
     *                 kind: String(decisionrule/attributerule) (Optional)
     *                 effect: String(Deny/Permit) (Optional)
     *                 dnfCondition (Optional): [
     *                      (Optional)[
     *                          (Optional){
     *                             attributeName: String (Optional)
     *                             attributeValueIncludes: String (Optional)
     *                             attributeValueIncludedIn (Optional): [
     *                                 String (Optional)
     *                             ]
     *                             attributeValueExcludes: String (Optional)
     *                             attributeValueExcludedIn (Optional): [
     *                                 String (Optional)
     *                             ]
     *                         }
     *                     ]
     *                 ]
     *             }
     *         ]
     *         attributeRules (Optional): [
     *              (Optional){
     *                 kind: String(decisionrule/attributerule) (Optional)
     *                 id: String (Optional)
     *                 name: String (Optional)
     *                 dnfCondition (Optional): [
     *                      (Optional)[
     *                         (recursive schema, see above)
     *                     ]
     *                 ]
     *             }
     *         ]
     *         collection (Optional): {
     *             type: String (Optional)
     *             referenceName: String (Optional)
     *         }
     *         parentCollectionName: String (Optional)
     *     }
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     id: String (Optional)
     *     version: Integer (Optional)
     *     properties (Optional): {
     *         description: String (Optional)
     *         decisionRules (Optional): [
     *              (Optional){
     *                 kind: String(decisionrule/attributerule) (Optional)
     *                 effect: String(Deny/Permit) (Optional)
     *                 dnfCondition (Optional): [
     *                      (Optional)[
     *                          (Optional){
     *                             attributeName: String (Optional)
     *                             attributeValueIncludes: String (Optional)
     *                             attributeValueIncludedIn (Optional): [
     *                                 String (Optional)
     *                             ]
     *                             attributeValueExcludes: String (Optional)
     *                             attributeValueExcludedIn (Optional): [
     *                                 String (Optional)
     *                             ]
     *                         }
     *                     ]
     *                 ]
     *             }
     *         ]
     *         attributeRules (Optional): [
     *              (Optional){
     *                 kind: String(decisionrule/attributerule) (Optional)
     *                 id: String (Optional)
     *                 name: String (Optional)
     *                 dnfCondition (Optional): [
     *                      (Optional)[
     *                         (recursive schema, see above)
     *                     ]
     *                 ]
     *             }
     *         ]
     *         collection (Optional): {
     *             type: String (Optional)
     *             referenceName: String (Optional)
     *         }
     *         parentCollectionName: String (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param policyId Unique policy id.
     * @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 response body along with {@link Response}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> updateWithResponse(String policyId, RequestOptions requestOptions) {
        return this.serviceClient.updateWithResponse(policyId, requestOptions);
    }

    /**
     * Gets a metadata policy.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     id: String (Optional)
     *     version: Integer (Optional)
     *     properties (Optional): {
     *         description: String (Optional)
     *         decisionRules (Optional): [
     *              (Optional){
     *                 kind: String(decisionrule/attributerule) (Optional)
     *                 effect: String(Deny/Permit) (Optional)
     *                 dnfCondition (Optional): [
     *                      (Optional)[
     *                          (Optional){
     *                             attributeName: String (Optional)
     *                             attributeValueIncludes: String (Optional)
     *                             attributeValueIncludedIn (Optional): [
     *                                 String (Optional)
     *                             ]
     *                             attributeValueExcludes: String (Optional)
     *                             attributeValueExcludedIn (Optional): [
     *                                 String (Optional)
     *                             ]
     *                         }
     *                     ]
     *                 ]
     *             }
     *         ]
     *         attributeRules (Optional): [
     *              (Optional){
     *                 kind: String(decisionrule/attributerule) (Optional)
     *                 id: String (Optional)
     *                 name: String (Optional)
     *                 dnfCondition (Optional): [
     *                      (Optional)[
     *                         (recursive schema, see above)
     *                     ]
     *                 ]
     *             }
     *         ]
     *         collection (Optional): {
     *             type: String (Optional)
     *             referenceName: String (Optional)
     *         }
     *         parentCollectionName: String (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param policyId Id of an existing policy that needs to be fetched.
     * @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 metadata policy along with {@link Response}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getWithResponse(String policyId, RequestOptions requestOptions) {
        return this.serviceClient.getWithResponse(policyId, requestOptions);
    }
}
