UNPKG

@azure/arm-security

Version:
223 lines 8.38 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 { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; /// <reference lib="esnext.asynciterable" /> /** Class containing Assessments operations. */ export class AssessmentsImpl { /** * Initialize a new instance of the class Assessments class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Get security assessments on all your scanned resources inside a scope * @param scope Scope of the query, can be subscription * (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group * (/providers/Microsoft.Management/managementGroups/mgName). * @param options The options parameters. */ list(scope, options) { const iter = this.listPagingAll(scope, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: () => { return this.listPagingPage(scope, options); } }; } listPagingPage(scope, options) { return __asyncGenerator(this, arguments, function* listPagingPage_1() { let result = yield __await(this._list(scope, options)); yield yield __await(result.value || []); let continuationToken = result.nextLink; while (continuationToken) { result = yield __await(this._listNext(scope, continuationToken, options)); continuationToken = result.nextLink; yield yield __await(result.value || []); } }); } listPagingAll(scope, options) { return __asyncGenerator(this, arguments, function* listPagingAll_1() { var e_1, _a; try { for (var _b = __asyncValues(this.listPagingPage(scope, options)), _c; _c = yield __await(_b.next()), !_c.done;) { const page = _c.value; yield __await(yield* __asyncDelegator(__asyncValues(page))); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b)); } finally { if (e_1) throw e_1.error; } } }); } /** * Get security assessments on all your scanned resources inside a scope * @param scope Scope of the query, can be subscription * (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group * (/providers/Microsoft.Management/managementGroups/mgName). * @param options The options parameters. */ _list(scope, options) { return this.client.sendOperationRequest({ scope, options }, listOperationSpec); } /** * Get a security assessment on your scanned resource * @param resourceId The identifier of the resource. * @param assessmentName The Assessment Key - Unique key for the assessment type * @param options The options parameters. */ get(resourceId, assessmentName, options) { return this.client.sendOperationRequest({ resourceId, assessmentName, options }, getOperationSpec); } /** * Create a security assessment on your resource. An assessment metadata that describes this assessment * must be predefined with the same name before inserting the assessment result * @param resourceId The identifier of the resource. * @param assessmentName The Assessment Key - Unique key for the assessment type * @param assessment Calculated assessment on a pre-defined assessment metadata * @param options The options parameters. */ createOrUpdate(resourceId, assessmentName, assessment, options) { return this.client.sendOperationRequest({ resourceId, assessmentName, assessment, options }, createOrUpdateOperationSpec); } /** * Delete a security assessment on your resource. An assessment metadata that describes this assessment * must be predefined with the same name before inserting the assessment result * @param resourceId The identifier of the resource. * @param assessmentName The Assessment Key - Unique key for the assessment type * @param options The options parameters. */ delete(resourceId, assessmentName, options) { return this.client.sendOperationRequest({ resourceId, assessmentName, options }, deleteOperationSpec); } /** * ListNext * @param scope Scope of the query, can be subscription * (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group * (/providers/Microsoft.Management/managementGroups/mgName). * @param nextLink The nextLink from the previous successful call to the List method. * @param options The options parameters. */ _listNext(scope, nextLink, options) { return this.client.sendOperationRequest({ scope, nextLink, options }, listNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listOperationSpec = { path: "/{scope}/providers/Microsoft.Security/assessments", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SecurityAssessmentList }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion10], urlParameters: [Parameters.$host, Parameters.scope], headerParameters: [Parameters.accept], serializer }; const getOperationSpec = { path: "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SecurityAssessmentResponse }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion10, Parameters.expand], urlParameters: [ Parameters.$host, Parameters.resourceId, Parameters.assessmentName ], headerParameters: [Parameters.accept], serializer }; const createOrUpdateOperationSpec = { path: "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.SecurityAssessmentResponse }, 201: { bodyMapper: Mappers.SecurityAssessmentResponse }, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.assessment, queryParameters: [Parameters.apiVersion10], urlParameters: [ Parameters.$host, Parameters.resourceId, Parameters.assessmentName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const deleteOperationSpec = { path: "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}", httpMethod: "DELETE", responses: { 200: {}, 204: {}, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion10], urlParameters: [ Parameters.$host, Parameters.resourceId, Parameters.assessmentName ], headerParameters: [Parameters.accept], serializer }; const listNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SecurityAssessmentList }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion10], urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.scope], headerParameters: [Parameters.accept], serializer }; //# sourceMappingURL=assessments.js.map