UNPKG

@azure/arm-compute

Version:
204 lines 7.76 kB
/* * 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. */ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers.js"; import * as Parameters from "../models/parameters.js"; import { createHttpPoller, } from "@azure/core-lro"; import { createLroSpec } from "../lroImpl.js"; /** Class containing LogAnalytics operations. */ export 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 = createLroSpec({ sendOperationFn, args: { location, parameters, options }, spec: exportRequestRateByIntervalOperationSpec, }); const poller = await 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 = createLroSpec({ sendOperationFn, args: { location, parameters, options }, spec: exportThrottledRequestsOperationSpec, }); const poller = await 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(); } } // 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