@azure/arm-security
Version:
A generated SDK for SecurityCenter.
371 lines • 14.2 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 } 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 Automations operations. */
export class AutomationsImpl {
/**
* Initialize a new instance of the class Automations class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* Lists all the security automations in the specified subscription. Use the 'nextLink' property in the
* response to get the next page of security automations for the specified subscription.
* @param options The options parameters.
*/
list(options) {
const iter = this.listPagingAll(options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listPagingPage(options);
}
};
}
listPagingPage(options) {
return __asyncGenerator(this, arguments, function* listPagingPage_1() {
let result = yield __await(this._list(options));
yield yield __await(result.value || []);
let continuationToken = result.nextLink;
while (continuationToken) {
result = yield __await(this._listNext(continuationToken, options));
continuationToken = result.nextLink;
yield yield __await(result.value || []);
}
});
}
listPagingAll(options) {
return __asyncGenerator(this, arguments, function* listPagingAll_1() {
var e_1, _a;
try {
for (var _b = __asyncValues(this.listPagingPage(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; }
}
});
}
/**
* Lists all the security automations in the specified resource group. Use the 'nextLink' property in
* the response to get the next page of security automations for the specified resource group.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param options The options parameters.
*/
listByResourceGroup(resourceGroupName, options) {
const iter = this.listByResourceGroupPagingAll(resourceGroupName, options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listByResourceGroupPagingPage(resourceGroupName, options);
}
};
}
listByResourceGroupPagingPage(resourceGroupName, options) {
return __asyncGenerator(this, arguments, function* listByResourceGroupPagingPage_1() {
let result = yield __await(this._listByResourceGroup(resourceGroupName, options));
yield yield __await(result.value || []);
let continuationToken = result.nextLink;
while (continuationToken) {
result = yield __await(this._listByResourceGroupNext(resourceGroupName, continuationToken, options));
continuationToken = result.nextLink;
yield yield __await(result.value || []);
}
});
}
listByResourceGroupPagingAll(resourceGroupName, options) {
return __asyncGenerator(this, arguments, function* listByResourceGroupPagingAll_1() {
var e_2, _a;
try {
for (var _b = __asyncValues(this.listByResourceGroupPagingPage(resourceGroupName, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
const page = _c.value;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
}
finally { if (e_2) throw e_2.error; }
}
});
}
/**
* Lists all the security automations in the specified subscription. Use the 'nextLink' property in the
* response to get the next page of security automations for the specified subscription.
* @param options The options parameters.
*/
_list(options) {
return this.client.sendOperationRequest({ options }, listOperationSpec);
}
/**
* Lists all the security automations in the specified resource group. Use the 'nextLink' property in
* the response to get the next page of security automations for the specified resource group.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param options The options parameters.
*/
_listByResourceGroup(resourceGroupName, options) {
return this.client.sendOperationRequest({ resourceGroupName, options }, listByResourceGroupOperationSpec);
}
/**
* Retrieves information about the model of a security automation.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param automationName The security automation name.
* @param options The options parameters.
*/
get(resourceGroupName, automationName, options) {
return this.client.sendOperationRequest({ resourceGroupName, automationName, options }, getOperationSpec);
}
/**
* Creates or updates a security automation. If a security automation is already created and a
* subsequent request is issued for the same automation id, then it will be updated.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param automationName The security automation name.
* @param automation The security automation resource
* @param options The options parameters.
*/
createOrUpdate(resourceGroupName, automationName, automation, options) {
return this.client.sendOperationRequest({ resourceGroupName, automationName, automation, options }, createOrUpdateOperationSpec);
}
/**
* Deletes a security automation.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param automationName The security automation name.
* @param options The options parameters.
*/
delete(resourceGroupName, automationName, options) {
return this.client.sendOperationRequest({ resourceGroupName, automationName, options }, deleteOperationSpec);
}
/**
* Validates the security automation model before create or update. Any validation errors are returned
* to the client.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param automationName The security automation name.
* @param automation The security automation resource
* @param options The options parameters.
*/
validate(resourceGroupName, automationName, automation, options) {
return this.client.sendOperationRequest({ resourceGroupName, automationName, automation, options }, validateOperationSpec);
}
/**
* ListNext
* @param nextLink The nextLink from the previous successful call to the List method.
* @param options The options parameters.
*/
_listNext(nextLink, options) {
return this.client.sendOperationRequest({ nextLink, options }, listNextOperationSpec);
}
/**
* ListByResourceGroupNext
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method.
* @param options The options parameters.
*/
_listByResourceGroupNext(resourceGroupName, nextLink, options) {
return this.client.sendOperationRequest({ resourceGroupName, nextLink, options }, listByResourceGroupNextOperationSpec);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/automations",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AutomationList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion8],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept],
serializer
};
const listByResourceGroupOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AutomationList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName
],
headerParameters: [Parameters.accept],
serializer
};
const getOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.Automation
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.automationName
],
headerParameters: [Parameters.accept],
serializer
};
const createOrUpdateOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.Automation
},
201: {
bodyMapper: Mappers.Automation
},
default: {
bodyMapper: Mappers.CloudError
}
},
requestBody: Parameters.automation,
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.automationName
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const deleteOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}",
httpMethod: "DELETE",
responses: {
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.automationName
],
headerParameters: [Parameters.accept],
serializer
};
const validateOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}/validate",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.AutomationValidationStatus
},
default: {
bodyMapper: Mappers.CloudError
}
},
requestBody: Parameters.automation,
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.automationName
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const listNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AutomationList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};
const listByResourceGroupNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AutomationList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};
//# sourceMappingURL=automations.js.map