@azure/arm-security
Version:
A generated SDK for SecurityCenter.
422 lines (404 loc) • 14.4 kB
text/typescript
/*
* 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 { PagedAsyncIterableIterator } from "@azure/core-paging";
import { CustomEntityStoreAssignments } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { SecurityCenter } from "../securityCenter";
import {
CustomEntityStoreAssignment,
CustomEntityStoreAssignmentsListByResourceGroupNextOptionalParams,
CustomEntityStoreAssignmentsListByResourceGroupOptionalParams,
CustomEntityStoreAssignmentsListBySubscriptionNextOptionalParams,
CustomEntityStoreAssignmentsListBySubscriptionOptionalParams,
CustomEntityStoreAssignmentsGetOptionalParams,
CustomEntityStoreAssignmentsGetResponse,
CustomEntityStoreAssignmentRequest,
CustomEntityStoreAssignmentsCreateOptionalParams,
CustomEntityStoreAssignmentsCreateResponse,
CustomEntityStoreAssignmentsDeleteOptionalParams,
CustomEntityStoreAssignmentsListByResourceGroupResponse,
CustomEntityStoreAssignmentsListBySubscriptionResponse,
CustomEntityStoreAssignmentsListByResourceGroupNextResponse,
CustomEntityStoreAssignmentsListBySubscriptionNextResponse
} from "../models";
/// <reference lib="esnext.asynciterable" />
/** Class containing CustomEntityStoreAssignments operations. */
export class CustomEntityStoreAssignmentsImpl
implements CustomEntityStoreAssignments {
private readonly client: SecurityCenter;
/**
* Initialize a new instance of the class CustomEntityStoreAssignments class.
* @param client Reference to the service client
*/
constructor(client: SecurityCenter) {
this.client = client;
}
/**
* List custom entity store assignments by a provided subscription and 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.
*/
public listByResourceGroup(
resourceGroupName: string,
options?: CustomEntityStoreAssignmentsListByResourceGroupOptionalParams
): PagedAsyncIterableIterator<CustomEntityStoreAssignment> {
const iter = this.listByResourceGroupPagingAll(resourceGroupName, options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listByResourceGroupPagingPage(resourceGroupName, options);
}
};
}
private async *listByResourceGroupPagingPage(
resourceGroupName: string,
options?: CustomEntityStoreAssignmentsListByResourceGroupOptionalParams
): AsyncIterableIterator<CustomEntityStoreAssignment[]> {
let result = await this._listByResourceGroup(resourceGroupName, options);
yield result.value || [];
let continuationToken = result.nextLink;
while (continuationToken) {
result = await this._listByResourceGroupNext(
resourceGroupName,
continuationToken,
options
);
continuationToken = result.nextLink;
yield result.value || [];
}
}
private async *listByResourceGroupPagingAll(
resourceGroupName: string,
options?: CustomEntityStoreAssignmentsListByResourceGroupOptionalParams
): AsyncIterableIterator<CustomEntityStoreAssignment> {
for await (const page of this.listByResourceGroupPagingPage(
resourceGroupName,
options
)) {
yield* page;
}
}
/**
* List custom entity store assignments by provided subscription
* @param options The options parameters.
*/
public listBySubscription(
options?: CustomEntityStoreAssignmentsListBySubscriptionOptionalParams
): PagedAsyncIterableIterator<CustomEntityStoreAssignment> {
const iter = this.listBySubscriptionPagingAll(options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listBySubscriptionPagingPage(options);
}
};
}
private async *listBySubscriptionPagingPage(
options?: CustomEntityStoreAssignmentsListBySubscriptionOptionalParams
): AsyncIterableIterator<CustomEntityStoreAssignment[]> {
let result = await this._listBySubscription(options);
yield result.value || [];
let continuationToken = result.nextLink;
while (continuationToken) {
result = await this._listBySubscriptionNext(continuationToken, options);
continuationToken = result.nextLink;
yield result.value || [];
}
}
private async *listBySubscriptionPagingAll(
options?: CustomEntityStoreAssignmentsListBySubscriptionOptionalParams
): AsyncIterableIterator<CustomEntityStoreAssignment> {
for await (const page of this.listBySubscriptionPagingPage(options)) {
yield* page;
}
}
/**
* Gets a single custom entity store assignment by name for the provided subscription and resource
* group.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param customEntityStoreAssignmentName Name of the custom entity store assignment. Generated name is
* GUID.
* @param options The options parameters.
*/
get(
resourceGroupName: string,
customEntityStoreAssignmentName: string,
options?: CustomEntityStoreAssignmentsGetOptionalParams
): Promise<CustomEntityStoreAssignmentsGetResponse> {
return this.client.sendOperationRequest(
{ resourceGroupName, customEntityStoreAssignmentName, options },
getOperationSpec
);
}
/**
* Creates a custom entity store assignment for the provided subscription, if not already exists.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param customEntityStoreAssignmentName Name of the custom entity store assignment. Generated name is
* GUID.
* @param customEntityStoreAssignmentRequestBody Custom entity store assignment body
* @param options The options parameters.
*/
create(
resourceGroupName: string,
customEntityStoreAssignmentName: string,
customEntityStoreAssignmentRequestBody: CustomEntityStoreAssignmentRequest,
options?: CustomEntityStoreAssignmentsCreateOptionalParams
): Promise<CustomEntityStoreAssignmentsCreateResponse> {
return this.client.sendOperationRequest(
{
resourceGroupName,
customEntityStoreAssignmentName,
customEntityStoreAssignmentRequestBody,
options
},
createOperationSpec
);
}
/**
* Delete a custom entity store assignment by name for a provided subscription
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param customEntityStoreAssignmentName Name of the custom entity store assignment. Generated name is
* GUID.
* @param options The options parameters.
*/
delete(
resourceGroupName: string,
customEntityStoreAssignmentName: string,
options?: CustomEntityStoreAssignmentsDeleteOptionalParams
): Promise<void> {
return this.client.sendOperationRequest(
{ resourceGroupName, customEntityStoreAssignmentName, options },
deleteOperationSpec
);
}
/**
* List custom entity store assignments by a provided subscription and 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.
*/
private _listByResourceGroup(
resourceGroupName: string,
options?: CustomEntityStoreAssignmentsListByResourceGroupOptionalParams
): Promise<CustomEntityStoreAssignmentsListByResourceGroupResponse> {
return this.client.sendOperationRequest(
{ resourceGroupName, options },
listByResourceGroupOperationSpec
);
}
/**
* List custom entity store assignments by provided subscription
* @param options The options parameters.
*/
private _listBySubscription(
options?: CustomEntityStoreAssignmentsListBySubscriptionOptionalParams
): Promise<CustomEntityStoreAssignmentsListBySubscriptionResponse> {
return this.client.sendOperationRequest(
{ options },
listBySubscriptionOperationSpec
);
}
/**
* 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.
*/
private _listByResourceGroupNext(
resourceGroupName: string,
nextLink: string,
options?: CustomEntityStoreAssignmentsListByResourceGroupNextOptionalParams
): Promise<CustomEntityStoreAssignmentsListByResourceGroupNextResponse> {
return this.client.sendOperationRequest(
{ resourceGroupName, nextLink, options },
listByResourceGroupNextOperationSpec
);
}
/**
* ListBySubscriptionNext
* @param nextLink The nextLink from the previous successful call to the ListBySubscription method.
* @param options The options parameters.
*/
private _listBySubscriptionNext(
nextLink: string,
options?: CustomEntityStoreAssignmentsListBySubscriptionNextOptionalParams
): Promise<CustomEntityStoreAssignmentsListBySubscriptionNextResponse> {
return this.client.sendOperationRequest(
{ nextLink, options },
listBySubscriptionNextOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const getOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments/{customEntityStoreAssignmentName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.CustomEntityStoreAssignment
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.customEntityStoreAssignmentName
],
headerParameters: [Parameters.accept],
serializer
};
const createOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments/{customEntityStoreAssignmentName}",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.CustomEntityStoreAssignment
},
201: {
bodyMapper: Mappers.CustomEntityStoreAssignment
},
default: {
bodyMapper: Mappers.CloudError
}
},
requestBody: Parameters.customEntityStoreAssignmentRequestBody,
queryParameters: [Parameters.apiVersion1],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.customEntityStoreAssignmentName
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const deleteOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments/{customEntityStoreAssignmentName}",
httpMethod: "DELETE",
responses: {
200: {},
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.customEntityStoreAssignmentName
],
headerParameters: [Parameters.accept],
serializer
};
const listByResourceGroupOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.CustomEntityStoreAssignmentsListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName
],
headerParameters: [Parameters.accept],
serializer
};
const listBySubscriptionOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.Security/customEntityStoreAssignments",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.CustomEntityStoreAssignmentsListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept],
serializer
};
const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.CustomEntityStoreAssignmentsListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};
const listBySubscriptionNextOperationSpec: coreClient.OperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.CustomEntityStoreAssignmentsListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};