@azure/arm-security
Version:
A generated SDK for SecurityCenter.
306 lines • 13.7 kB
JavaScript
/*
* 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, __awaiter } from "tslib";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { LroEngine } from "@azure/core-lro";
import { LroImpl } from "../lroImpl";
/// <reference lib="esnext.asynciterable" />
/** Class containing AdaptiveNetworkHardenings operations. */
export class AdaptiveNetworkHardeningsImpl {
/**
* Initialize a new instance of the class AdaptiveNetworkHardenings class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* Gets a list of Adaptive Network Hardenings resources in scope of an extended resource.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param resourceNamespace The Namespace of the resource.
* @param resourceType The type of the resource.
* @param resourceName Name of the resource.
* @param options The options parameters.
*/
listByExtendedResource(resourceGroupName, resourceNamespace, resourceType, resourceName, options) {
const iter = this.listByExtendedResourcePagingAll(resourceGroupName, resourceNamespace, resourceType, resourceName, options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listByExtendedResourcePagingPage(resourceGroupName, resourceNamespace, resourceType, resourceName, options);
}
};
}
listByExtendedResourcePagingPage(resourceGroupName, resourceNamespace, resourceType, resourceName, options) {
return __asyncGenerator(this, arguments, function* listByExtendedResourcePagingPage_1() {
let result = yield __await(this._listByExtendedResource(resourceGroupName, resourceNamespace, resourceType, resourceName, options));
yield yield __await(result.value || []);
let continuationToken = result.nextLink;
while (continuationToken) {
result = yield __await(this._listByExtendedResourceNext(resourceGroupName, resourceNamespace, resourceType, resourceName, continuationToken, options));
continuationToken = result.nextLink;
yield yield __await(result.value || []);
}
});
}
listByExtendedResourcePagingAll(resourceGroupName, resourceNamespace, resourceType, resourceName, options) {
return __asyncGenerator(this, arguments, function* listByExtendedResourcePagingAll_1() {
var e_1, _a;
try {
for (var _b = __asyncValues(this.listByExtendedResourcePagingPage(resourceGroupName, resourceNamespace, resourceType, resourceName, 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; }
}
});
}
/**
* Gets a list of Adaptive Network Hardenings resources in scope of an extended resource.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param resourceNamespace The Namespace of the resource.
* @param resourceType The type of the resource.
* @param resourceName Name of the resource.
* @param options The options parameters.
*/
_listByExtendedResource(resourceGroupName, resourceNamespace, resourceType, resourceName, options) {
return this.client.sendOperationRequest({
resourceGroupName,
resourceNamespace,
resourceType,
resourceName,
options
}, listByExtendedResourceOperationSpec);
}
/**
* Gets a single Adaptive Network Hardening resource
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param resourceNamespace The Namespace of the resource.
* @param resourceType The type of the resource.
* @param resourceName Name of the resource.
* @param adaptiveNetworkHardeningResourceName The name of the Adaptive Network Hardening resource.
* @param options The options parameters.
*/
get(resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName, options) {
return this.client.sendOperationRequest({
resourceGroupName,
resourceNamespace,
resourceType,
resourceName,
adaptiveNetworkHardeningResourceName,
options
}, getOperationSpec);
}
/**
* Enforces the given rules on the NSG(s) listed in the request
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param resourceNamespace The Namespace of the resource.
* @param resourceType The type of the resource.
* @param resourceName Name of the resource.
* @param adaptiveNetworkHardeningResourceName The name of the Adaptive Network Hardening resource.
* @param body
* @param options The options parameters.
*/
beginEnforce(resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName, body, options) {
return __awaiter(this, void 0, void 0, function* () {
const directSendOperation = (args, spec) => __awaiter(this, void 0, void 0, function* () {
return this.client.sendOperationRequest(args, spec);
});
const sendOperation = (args, spec) => __awaiter(this, void 0, void 0, function* () {
var _a;
let currentRawResponse = undefined;
const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse;
const callback = (rawResponse, flatResponse) => {
currentRawResponse = rawResponse;
providedCallback === null || providedCallback === void 0 ? void 0 : providedCallback(rawResponse, flatResponse);
};
const updatedArgs = Object.assign(Object.assign({}, args), { options: Object.assign(Object.assign({}, args.options), { onResponse: callback }) });
const flatResponse = yield directSendOperation(updatedArgs, spec);
return {
flatResponse,
rawResponse: {
statusCode: currentRawResponse.status,
body: currentRawResponse.parsedBody,
headers: currentRawResponse.headers.toJSON()
}
};
});
const lro = new LroImpl(sendOperation, {
resourceGroupName,
resourceNamespace,
resourceType,
resourceName,
adaptiveNetworkHardeningResourceName,
body,
options
}, enforceOperationSpec);
const poller = new LroEngine(lro, {
resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom,
intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs
});
yield poller.poll();
return poller;
});
}
/**
* Enforces the given rules on the NSG(s) listed in the request
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param resourceNamespace The Namespace of the resource.
* @param resourceType The type of the resource.
* @param resourceName Name of the resource.
* @param adaptiveNetworkHardeningResourceName The name of the Adaptive Network Hardening resource.
* @param body
* @param options The options parameters.
*/
beginEnforceAndWait(resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName, body, options) {
return __awaiter(this, void 0, void 0, function* () {
const poller = yield this.beginEnforce(resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName, body, options);
return poller.pollUntilDone();
});
}
/**
* ListByExtendedResourceNext
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param resourceNamespace The Namespace of the resource.
* @param resourceType The type of the resource.
* @param resourceName Name of the resource.
* @param nextLink The nextLink from the previous successful call to the ListByExtendedResource method.
* @param options The options parameters.
*/
_listByExtendedResourceNext(resourceGroupName, resourceNamespace, resourceType, resourceName, nextLink, options) {
return this.client.sendOperationRequest({
resourceGroupName,
resourceNamespace,
resourceType,
resourceName,
nextLink,
options
}, listByExtendedResourceNextOperationSpec);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listByExtendedResourceOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AdaptiveNetworkHardeningsList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion9],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.resourceNamespace,
Parameters.resourceType,
Parameters.resourceName
],
headerParameters: [Parameters.accept],
serializer
};
const getOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AdaptiveNetworkHardening
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion9],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.resourceNamespace,
Parameters.resourceType,
Parameters.resourceName,
Parameters.adaptiveNetworkHardeningResourceName
],
headerParameters: [Parameters.accept],
serializer
};
const enforceOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}",
httpMethod: "POST",
responses: {
200: {},
201: {},
202: {},
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
requestBody: Parameters.body1,
queryParameters: [Parameters.apiVersion9],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.resourceNamespace,
Parameters.resourceType,
Parameters.resourceName,
Parameters.adaptiveNetworkHardeningResourceName,
Parameters.adaptiveNetworkHardeningEnforceAction
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const listByExtendedResourceNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AdaptiveNetworkHardeningsList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion9],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.nextLink,
Parameters.resourceNamespace,
Parameters.resourceType,
Parameters.resourceName
],
headerParameters: [Parameters.accept],
serializer
};
//# sourceMappingURL=adaptiveNetworkHardenings.js.map