"use strict";
/*
 * Copyright (c) Microsoft Corporation.
 * Licensed under the MIT License.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is regenerated.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiOperationPolicyImpl = void 0;
const tslib_1 = require("tslib");
const coreClient = tslib_1.__importStar(require("@azure/core-client"));
const Mappers = tslib_1.__importStar(require("../models/mappers.js"));
const Parameters = tslib_1.__importStar(require("../models/parameters.js"));
/** Class containing ApiOperationPolicy operations. */
class ApiOperationPolicyImpl {
    /**
     * Initialize a new instance of the class ApiOperationPolicy class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Get the list of policy configuration at the API Operation level.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the current API Management service instance.
     *              Non-current revision has ;rev=n as a suffix where n is the revision number.
     * @param operationId Operation identifier within an API. Must be unique in the current API Management
     *                    service instance.
     * @param options The options parameters.
     */
    listByOperation(resourceGroupName, serviceName, apiId, operationId, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serviceName, apiId, operationId, options }, listByOperationOperationSpec);
    }
    /**
     * Gets the entity state (Etag) version of the API operation policy specified by its identifier.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the current API Management service instance.
     *              Non-current revision has ;rev=n as a suffix where n is the revision number.
     * @param operationId Operation identifier within an API. Must be unique in the current API Management
     *                    service instance.
     * @param policyId The identifier of the Policy.
     * @param options The options parameters.
     */
    getEntityTag(resourceGroupName, serviceName, apiId, operationId, policyId, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serviceName, apiId, operationId, policyId, options }, getEntityTagOperationSpec);
    }
    /**
     * Get the policy configuration at the API Operation level.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the current API Management service instance.
     *              Non-current revision has ;rev=n as a suffix where n is the revision number.
     * @param operationId Operation identifier within an API. Must be unique in the current API Management
     *                    service instance.
     * @param policyId The identifier of the Policy.
     * @param options The options parameters.
     */
    get(resourceGroupName, serviceName, apiId, operationId, policyId, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serviceName, apiId, operationId, policyId, options }, getOperationSpec);
    }
    /**
     * Creates or updates policy configuration for the API Operation level.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the current API Management service instance.
     *              Non-current revision has ;rev=n as a suffix where n is the revision number.
     * @param operationId Operation identifier within an API. Must be unique in the current API Management
     *                    service instance.
     * @param policyId The identifier of the Policy.
     * @param parameters The policy contents to apply.
     * @param options The options parameters.
     */
    createOrUpdate(resourceGroupName, serviceName, apiId, operationId, policyId, parameters, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serviceName,
            apiId,
            operationId,
            policyId,
            parameters,
            options,
        }, createOrUpdateOperationSpec);
    }
    /**
     * Deletes the policy configuration at the Api Operation.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the current API Management service instance.
     *              Non-current revision has ;rev=n as a suffix where n is the revision number.
     * @param operationId Operation identifier within an API. Must be unique in the current API Management
     *                    service instance.
     * @param policyId The identifier of the Policy.
     * @param ifMatch ETag of the Entity. ETag should match the current entity state from the header
     *                response of the GET request or it should be * for unconditional update.
     * @param options The options parameters.
     */
    delete(resourceGroupName, serviceName, apiId, operationId, policyId, ifMatch, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serviceName,
            apiId,
            operationId,
            policyId,
            ifMatch,
            options,
        }, deleteOperationSpec);
    }
}
exports.ApiOperationPolicyImpl = ApiOperationPolicyImpl;
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listByOperationOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.PolicyCollection,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.serviceName,
        Parameters.apiId,
        Parameters.operationId,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const getEntityTagOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}",
    httpMethod: "HEAD",
    responses: {
        200: {
            headersMapper: Mappers.ApiOperationPolicyGetEntityTagHeaders,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.serviceName,
        Parameters.apiId,
        Parameters.operationId,
        Parameters.policyId,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.PolicyContract,
            headersMapper: Mappers.ApiOperationPolicyGetHeaders,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion, Parameters.format],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.serviceName,
        Parameters.apiId,
        Parameters.operationId,
        Parameters.policyId,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const createOrUpdateOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}",
    httpMethod: "PUT",
    responses: {
        200: {
            bodyMapper: Mappers.PolicyContract,
            headersMapper: Mappers.ApiOperationPolicyCreateOrUpdateHeaders,
        },
        201: {
            bodyMapper: Mappers.PolicyContract,
            headersMapper: Mappers.ApiOperationPolicyCreateOrUpdateHeaders,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters7,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.serviceName,
        Parameters.apiId,
        Parameters.operationId,
        Parameters.policyId,
    ],
    headerParameters: [
        Parameters.contentType,
        Parameters.accept,
        Parameters.ifMatch,
    ],
    mediaType: "json",
    serializer,
};
const deleteOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}",
    httpMethod: "DELETE",
    responses: {
        200: {},
        204: {},
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.serviceName,
        Parameters.apiId,
        Parameters.operationId,
        Parameters.policyId,
    ],
    headerParameters: [Parameters.accept, Parameters.ifMatch1],
    serializer,
};
//# sourceMappingURL=apiOperationPolicy.js.map