UNPKG

@azure/arm-compute

Version:
196 lines 7.86 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. Object.defineProperty(exports, "__esModule", { value: true }); exports.LogAnalyticsImpl = 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")); const core_lro_1 = require("@azure/core-lro"); const lroImpl_js_1 = require("../lroImpl.js"); /** Class containing LogAnalytics operations. */ class LogAnalyticsImpl { client; /** * Initialize a new instance of the class LogAnalytics class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Export logs that show Api requests made by this subscription in the given time window to show * throttling activities. * @param location The name of Azure region. * @param parameters Parameters supplied to the LogAnalytics getRequestRateByInterval Api. * @param options The options parameters. */ async beginExportRequestRateByInterval(location, parameters, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { currentRawResponse = rawResponse; providedCallback?.(rawResponse, flatResponse); }; const updatedArgs = { ...args, options: { ...args.options, onResponse: callback, }, }; const flatResponse = await directSendOperation(updatedArgs, spec); return { flatResponse, rawResponse: { statusCode: currentRawResponse.status, body: currentRawResponse.parsedBody, headers: currentRawResponse.headers.toJSON(), }, }; }; const lro = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { location, parameters, options }, spec: exportRequestRateByIntervalOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "azure-async-operation", }); await poller.poll(); return poller; } /** * Export logs that show Api requests made by this subscription in the given time window to show * throttling activities. * @param location The name of Azure region. * @param parameters Parameters supplied to the LogAnalytics getRequestRateByInterval Api. * @param options The options parameters. */ async beginExportRequestRateByIntervalAndWait(location, parameters, options) { const poller = await this.beginExportRequestRateByInterval(location, parameters, options); return poller.pollUntilDone(); } /** * Export logs that show total throttled Api requests for this subscription in the given time window. * @param location The name of Azure region. * @param parameters The request body * @param options The options parameters. */ async beginExportThrottledRequests(location, parameters, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { currentRawResponse = rawResponse; providedCallback?.(rawResponse, flatResponse); }; const updatedArgs = { ...args, options: { ...args.options, onResponse: callback, }, }; const flatResponse = await directSendOperation(updatedArgs, spec); return { flatResponse, rawResponse: { statusCode: currentRawResponse.status, body: currentRawResponse.parsedBody, headers: currentRawResponse.headers.toJSON(), }, }; }; const lro = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { location, parameters, options }, spec: exportThrottledRequestsOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "azure-async-operation", }); await poller.poll(); return poller; } /** * Export logs that show total throttled Api requests for this subscription in the given time window. * @param location The name of Azure region. * @param parameters The request body * @param options The options parameters. */ async beginExportThrottledRequestsAndWait(location, parameters, options) { const poller = await this.beginExportThrottledRequests(location, parameters, options); return poller.pollUntilDone(); } } exports.LogAnalyticsImpl = LogAnalyticsImpl; // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const exportRequestRateByIntervalOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.LogAnalyticsOperationResult, }, 201: { bodyMapper: Mappers.LogAnalyticsOperationResult, }, 202: { bodyMapper: Mappers.LogAnalyticsOperationResult, }, 204: { bodyMapper: Mappers.LogAnalyticsOperationResult, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters10, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.location], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const exportThrottledRequestsOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.LogAnalyticsOperationResult, }, 201: { bodyMapper: Mappers.LogAnalyticsOperationResult, }, 202: { bodyMapper: Mappers.LogAnalyticsOperationResult, }, 204: { bodyMapper: Mappers.LogAnalyticsOperationResult, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters11, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.location], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; //# sourceMappingURL=logAnalytics.js.map