@azure/arm-security
Version:
A generated SDK for SecurityCenter.
235 lines (224 loc) • 8.12 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 { IotSecuritySolutionsAnalyticsRecommendation } 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 {
IoTSecurityAggregatedRecommendation,
IotSecuritySolutionsAnalyticsRecommendationListNextOptionalParams,
IotSecuritySolutionsAnalyticsRecommendationListOptionalParams,
IotSecuritySolutionsAnalyticsRecommendationGetOptionalParams,
IotSecuritySolutionsAnalyticsRecommendationGetResponse,
IotSecuritySolutionsAnalyticsRecommendationListResponse,
IotSecuritySolutionsAnalyticsRecommendationListNextResponse
} from "../models";
/// <reference lib="esnext.asynciterable" />
/** Class containing IotSecuritySolutionsAnalyticsRecommendation operations. */
export class IotSecuritySolutionsAnalyticsRecommendationImpl
implements IotSecuritySolutionsAnalyticsRecommendation {
private readonly client: SecurityCenter;
/**
* Initialize a new instance of the class IotSecuritySolutionsAnalyticsRecommendation class.
* @param client Reference to the service client
*/
constructor(client: SecurityCenter) {
this.client = client;
}
/**
* Use this method to get the list of aggregated security analytics recommendations of yours IoT
* Security solution.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param solutionName The name of the IoT Security solution.
* @param options The options parameters.
*/
public list(
resourceGroupName: string,
solutionName: string,
options?: IotSecuritySolutionsAnalyticsRecommendationListOptionalParams
): PagedAsyncIterableIterator<IoTSecurityAggregatedRecommendation> {
const iter = this.listPagingAll(resourceGroupName, solutionName, options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listPagingPage(resourceGroupName, solutionName, options);
}
};
}
private async *listPagingPage(
resourceGroupName: string,
solutionName: string,
options?: IotSecuritySolutionsAnalyticsRecommendationListOptionalParams
): AsyncIterableIterator<IoTSecurityAggregatedRecommendation[]> {
let result = await this._list(resourceGroupName, solutionName, options);
yield result.value || [];
let continuationToken = result.nextLink;
while (continuationToken) {
result = await this._listNext(
resourceGroupName,
solutionName,
continuationToken,
options
);
continuationToken = result.nextLink;
yield result.value || [];
}
}
private async *listPagingAll(
resourceGroupName: string,
solutionName: string,
options?: IotSecuritySolutionsAnalyticsRecommendationListOptionalParams
): AsyncIterableIterator<IoTSecurityAggregatedRecommendation> {
for await (const page of this.listPagingPage(
resourceGroupName,
solutionName,
options
)) {
yield* page;
}
}
/**
* Use this method to get the aggregated security analytics recommendation of yours IoT Security
* solution. This aggregation is performed by recommendation name.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param solutionName The name of the IoT Security solution.
* @param aggregatedRecommendationName Name of the recommendation aggregated for this query.
* @param options The options parameters.
*/
get(
resourceGroupName: string,
solutionName: string,
aggregatedRecommendationName: string,
options?: IotSecuritySolutionsAnalyticsRecommendationGetOptionalParams
): Promise<IotSecuritySolutionsAnalyticsRecommendationGetResponse> {
return this.client.sendOperationRequest(
{
resourceGroupName,
solutionName,
aggregatedRecommendationName,
options
},
getOperationSpec
);
}
/**
* Use this method to get the list of aggregated security analytics recommendations of yours IoT
* Security solution.
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param solutionName The name of the IoT Security solution.
* @param options The options parameters.
*/
private _list(
resourceGroupName: string,
solutionName: string,
options?: IotSecuritySolutionsAnalyticsRecommendationListOptionalParams
): Promise<IotSecuritySolutionsAnalyticsRecommendationListResponse> {
return this.client.sendOperationRequest(
{ resourceGroupName, solutionName, options },
listOperationSpec
);
}
/**
* ListNext
* @param resourceGroupName The name of the resource group within the user's subscription. The name is
* case insensitive.
* @param solutionName The name of the IoT Security solution.
* @param nextLink The nextLink from the previous successful call to the List method.
* @param options The options parameters.
*/
private _listNext(
resourceGroupName: string,
solutionName: string,
nextLink: string,
options?: IotSecuritySolutionsAnalyticsRecommendationListNextOptionalParams
): Promise<IotSecuritySolutionsAnalyticsRecommendationListNextResponse> {
return this.client.sendOperationRequest(
{ resourceGroupName, solutionName, nextLink, options },
listNextOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const getOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations/{aggregatedRecommendationName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.IoTSecurityAggregatedRecommendation
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion5],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.solutionName,
Parameters.aggregatedRecommendationName
],
headerParameters: [Parameters.accept],
serializer
};
const listOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.IoTSecurityAggregatedRecommendationList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion5, Parameters.top],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.solutionName
],
headerParameters: [Parameters.accept],
serializer
};
const listNextOperationSpec: coreClient.OperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.IoTSecurityAggregatedRecommendationList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion5, Parameters.top],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.nextLink,
Parameters.solutionName
],
headerParameters: [Parameters.accept],
serializer
};