@azure/arm-security
Version:
A generated SDK for SecurityCenter.
744 lines • 29.3 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 Alerts operations. */
export class AlertsImpl {
/**
* Initialize a new instance of the class Alerts class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* List all the alerts that are associated with the 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; }
}
});
}
/**
* List all the alerts that are associated with the 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; }
}
});
}
/**
* List all the alerts that are associated with the subscription that are stored in a specific location
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param options The options parameters.
*/
listSubscriptionLevelByRegion(ascLocation, options) {
const iter = this.listSubscriptionLevelByRegionPagingAll(ascLocation, options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listSubscriptionLevelByRegionPagingPage(ascLocation, options);
}
};
}
listSubscriptionLevelByRegionPagingPage(ascLocation, options) {
return __asyncGenerator(this, arguments, function* listSubscriptionLevelByRegionPagingPage_1() {
let result = yield __await(this._listSubscriptionLevelByRegion(ascLocation, options));
yield yield __await(result.value || []);
let continuationToken = result.nextLink;
while (continuationToken) {
result = yield __await(this._listSubscriptionLevelByRegionNext(ascLocation, continuationToken, options));
continuationToken = result.nextLink;
yield yield __await(result.value || []);
}
});
}
listSubscriptionLevelByRegionPagingAll(ascLocation, options) {
return __asyncGenerator(this, arguments, function* listSubscriptionLevelByRegionPagingAll_1() {
var e_3, _a;
try {
for (var _b = __asyncValues(this.listSubscriptionLevelByRegionPagingPage(ascLocation, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
const page = _c.value;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
}
finally { if (e_3) throw e_3.error; }
}
});
}
/**
* List all the alerts that are associated with the resource group that are stored in a specific
* location
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param options The options parameters.
*/
listResourceGroupLevelByRegion(ascLocation, resourceGroupName, options) {
const iter = this.listResourceGroupLevelByRegionPagingAll(ascLocation, resourceGroupName, options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listResourceGroupLevelByRegionPagingPage(ascLocation, resourceGroupName, options);
}
};
}
listResourceGroupLevelByRegionPagingPage(ascLocation, resourceGroupName, options) {
return __asyncGenerator(this, arguments, function* listResourceGroupLevelByRegionPagingPage_1() {
let result = yield __await(this._listResourceGroupLevelByRegion(ascLocation, resourceGroupName, options));
yield yield __await(result.value || []);
let continuationToken = result.nextLink;
while (continuationToken) {
result = yield __await(this._listResourceGroupLevelByRegionNext(ascLocation, resourceGroupName, continuationToken, options));
continuationToken = result.nextLink;
yield yield __await(result.value || []);
}
});
}
listResourceGroupLevelByRegionPagingAll(ascLocation, resourceGroupName, options) {
return __asyncGenerator(this, arguments, function* listResourceGroupLevelByRegionPagingAll_1() {
var e_4, _a;
try {
for (var _b = __asyncValues(this.listResourceGroupLevelByRegionPagingPage(ascLocation, resourceGroupName, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
const page = _c.value;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
}
finally { if (e_4) throw e_4.error; }
}
});
}
/**
* List all the alerts that are associated with the subscription
* @param options The options parameters.
*/
_list(options) {
return this.client.sendOperationRequest({ options }, listOperationSpec);
}
/**
* List all the alerts that are associated with the 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);
}
/**
* List all the alerts that are associated with the subscription that are stored in a specific location
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param options The options parameters.
*/
_listSubscriptionLevelByRegion(ascLocation, options) {
return this.client.sendOperationRequest({ ascLocation, options }, listSubscriptionLevelByRegionOperationSpec);
}
/**
* List all the alerts that are associated with the resource group that are stored in a specific
* location
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param options The options parameters.
*/
_listResourceGroupLevelByRegion(ascLocation, resourceGroupName, options) {
return this.client.sendOperationRequest({ ascLocation, resourceGroupName, options }, listResourceGroupLevelByRegionOperationSpec);
}
/**
* Get an alert that is associated with a subscription
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param alertName Name of the alert object
* @param options The options parameters.
*/
getSubscriptionLevel(ascLocation, alertName, options) {
return this.client.sendOperationRequest({ ascLocation, alertName, options }, getSubscriptionLevelOperationSpec);
}
/**
* Get an alert that is associated a resource group or a resource in a resource group
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param alertName Name of the alert object
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param options The options parameters.
*/
getResourceGroupLevel(ascLocation, alertName, resourceGroupName, options) {
return this.client.sendOperationRequest({ ascLocation, alertName, resourceGroupName, options }, getResourceGroupLevelOperationSpec);
}
/**
* Update the alert's state
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param alertName Name of the alert object
* @param options The options parameters.
*/
updateSubscriptionLevelStateToDismiss(ascLocation, alertName, options) {
return this.client.sendOperationRequest({ ascLocation, alertName, options }, updateSubscriptionLevelStateToDismissOperationSpec);
}
/**
* Update the alert's state
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param alertName Name of the alert object
* @param options The options parameters.
*/
updateSubscriptionLevelStateToResolve(ascLocation, alertName, options) {
return this.client.sendOperationRequest({ ascLocation, alertName, options }, updateSubscriptionLevelStateToResolveOperationSpec);
}
/**
* Update the alert's state
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param alertName Name of the alert object
* @param options The options parameters.
*/
updateSubscriptionLevelStateToActivate(ascLocation, alertName, options) {
return this.client.sendOperationRequest({ ascLocation, alertName, options }, updateSubscriptionLevelStateToActivateOperationSpec);
}
/**
* Update the alert's state
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param alertName Name of the alert object
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param options The options parameters.
*/
updateResourceGroupLevelStateToResolve(ascLocation, alertName, resourceGroupName, options) {
return this.client.sendOperationRequest({ ascLocation, alertName, resourceGroupName, options }, updateResourceGroupLevelStateToResolveOperationSpec);
}
/**
* Update the alert's state
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param alertName Name of the alert object
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param options The options parameters.
*/
updateResourceGroupLevelStateToDismiss(ascLocation, alertName, resourceGroupName, options) {
return this.client.sendOperationRequest({ ascLocation, alertName, resourceGroupName, options }, updateResourceGroupLevelStateToDismissOperationSpec);
}
/**
* Update the alert's state
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param alertName Name of the alert object
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param options The options parameters.
*/
updateResourceGroupLevelStateToActivate(ascLocation, alertName, resourceGroupName, options) {
return this.client.sendOperationRequest({ ascLocation, alertName, resourceGroupName, options }, updateResourceGroupLevelStateToActivateOperationSpec);
}
/**
* Simulate security alerts
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param alertSimulatorRequestBody Alert Simulator Request Properties
* @param options The options parameters.
*/
simulate(ascLocation, alertSimulatorRequestBody, options) {
return this.client.sendOperationRequest({ ascLocation, alertSimulatorRequestBody, options }, simulateOperationSpec);
}
/**
* 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);
}
/**
* ListSubscriptionLevelByRegionNext
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @param nextLink The nextLink from the previous successful call to the ListSubscriptionLevelByRegion
* method.
* @param options The options parameters.
*/
_listSubscriptionLevelByRegionNext(ascLocation, nextLink, options) {
return this.client.sendOperationRequest({ ascLocation, nextLink, options }, listSubscriptionLevelByRegionNextOperationSpec);
}
/**
* ListResourceGroupLevelByRegionNext
* @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from
* Get locations
* @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 ListResourceGroupLevelByRegion
* method.
* @param options The options parameters.
*/
_listResourceGroupLevelByRegionNext(ascLocation, resourceGroupName, nextLink, options) {
return this.client.sendOperationRequest({ ascLocation, resourceGroupName, nextLink, options }, listResourceGroupLevelByRegionNextOperationSpec);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AlertList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept],
serializer
};
const listByResourceGroupOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AlertList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName
],
headerParameters: [Parameters.accept],
serializer
};
const listSubscriptionLevelByRegionOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AlertList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.ascLocation
],
headerParameters: [Parameters.accept],
serializer
};
const listResourceGroupLevelByRegionOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AlertList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.ascLocation
],
headerParameters: [Parameters.accept],
serializer
};
const getSubscriptionLevelOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.Alert
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.ascLocation,
Parameters.alertName
],
headerParameters: [Parameters.accept],
serializer
};
const getResourceGroupLevelOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.Alert
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.ascLocation,
Parameters.alertName
],
headerParameters: [Parameters.accept],
serializer
};
const updateSubscriptionLevelStateToDismissOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss",
httpMethod: "POST",
responses: {
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.ascLocation,
Parameters.alertName
],
headerParameters: [Parameters.accept],
serializer
};
const updateSubscriptionLevelStateToResolveOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve",
httpMethod: "POST",
responses: {
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.ascLocation,
Parameters.alertName
],
headerParameters: [Parameters.accept],
serializer
};
const updateSubscriptionLevelStateToActivateOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate",
httpMethod: "POST",
responses: {
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.ascLocation,
Parameters.alertName
],
headerParameters: [Parameters.accept],
serializer
};
const updateResourceGroupLevelStateToResolveOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve",
httpMethod: "POST",
responses: {
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.ascLocation,
Parameters.alertName
],
headerParameters: [Parameters.accept],
serializer
};
const updateResourceGroupLevelStateToDismissOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss",
httpMethod: "POST",
responses: {
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.ascLocation,
Parameters.alertName
],
headerParameters: [Parameters.accept],
serializer
};
const updateResourceGroupLevelStateToActivateOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate",
httpMethod: "POST",
responses: {
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.ascLocation,
Parameters.alertName
],
headerParameters: [Parameters.accept],
serializer
};
const simulateOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate",
httpMethod: "POST",
responses: {
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
requestBody: Parameters.alertSimulatorRequestBody,
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.ascLocation
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const listNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AlertList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};
const listByResourceGroupNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AlertList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};
const listSubscriptionLevelByRegionNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AlertList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.nextLink,
Parameters.ascLocation
],
headerParameters: [Parameters.accept],
serializer
};
const listResourceGroupLevelByRegionNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AlertList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion13],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.nextLink,
Parameters.ascLocation
],
headerParameters: [Parameters.accept],
serializer
};
//# sourceMappingURL=alerts.js.map