@azure/arm-security
Version:
A generated SDK for SecurityCenter.
304 lines (290 loc) • 9.02 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 { WorkspaceSettings } 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 {
WorkspaceSetting,
WorkspaceSettingsListNextOptionalParams,
WorkspaceSettingsListOptionalParams,
WorkspaceSettingsListResponse,
WorkspaceSettingsGetOptionalParams,
WorkspaceSettingsGetResponse,
WorkspaceSettingsCreateOptionalParams,
WorkspaceSettingsCreateResponse,
WorkspaceSettingsUpdateOptionalParams,
WorkspaceSettingsUpdateResponse,
WorkspaceSettingsDeleteOptionalParams,
WorkspaceSettingsListNextResponse
} from "../models";
/// <reference lib="esnext.asynciterable" />
/** Class containing WorkspaceSettings operations. */
export class WorkspaceSettingsImpl implements WorkspaceSettings {
private readonly client: SecurityCenter;
/**
* Initialize a new instance of the class WorkspaceSettings class.
* @param client Reference to the service client
*/
constructor(client: SecurityCenter) {
this.client = client;
}
/**
* Settings about where we should store your security data and logs. If the result is empty, it means
* that no custom-workspace configuration was set
* @param options The options parameters.
*/
public list(
options?: WorkspaceSettingsListOptionalParams
): PagedAsyncIterableIterator<WorkspaceSetting> {
const iter = this.listPagingAll(options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listPagingPage(options);
}
};
}
private async *listPagingPage(
options?: WorkspaceSettingsListOptionalParams
): AsyncIterableIterator<WorkspaceSetting[]> {
let result = await this._list(options);
yield result.value || [];
let continuationToken = result.nextLink;
while (continuationToken) {
result = await this._listNext(continuationToken, options);
continuationToken = result.nextLink;
yield result.value || [];
}
}
private async *listPagingAll(
options?: WorkspaceSettingsListOptionalParams
): AsyncIterableIterator<WorkspaceSetting> {
for await (const page of this.listPagingPage(options)) {
yield* page;
}
}
/**
* Settings about where we should store your security data and logs. If the result is empty, it means
* that no custom-workspace configuration was set
* @param options The options parameters.
*/
private _list(
options?: WorkspaceSettingsListOptionalParams
): Promise<WorkspaceSettingsListResponse> {
return this.client.sendOperationRequest({ options }, listOperationSpec);
}
/**
* Settings about where we should store your security data and logs. If the result is empty, it means
* that no custom-workspace configuration was set
* @param workspaceSettingName Name of the security setting
* @param options The options parameters.
*/
get(
workspaceSettingName: string,
options?: WorkspaceSettingsGetOptionalParams
): Promise<WorkspaceSettingsGetResponse> {
return this.client.sendOperationRequest(
{ workspaceSettingName, options },
getOperationSpec
);
}
/**
* creating settings about where we should store your security data and logs
* @param workspaceSettingName Name of the security setting
* @param workspaceSetting Security data setting object
* @param options The options parameters.
*/
create(
workspaceSettingName: string,
workspaceSetting: WorkspaceSetting,
options?: WorkspaceSettingsCreateOptionalParams
): Promise<WorkspaceSettingsCreateResponse> {
return this.client.sendOperationRequest(
{ workspaceSettingName, workspaceSetting, options },
createOperationSpec
);
}
/**
* Settings about where we should store your security data and logs
* @param workspaceSettingName Name of the security setting
* @param workspaceSetting Security data setting object
* @param options The options parameters.
*/
update(
workspaceSettingName: string,
workspaceSetting: WorkspaceSetting,
options?: WorkspaceSettingsUpdateOptionalParams
): Promise<WorkspaceSettingsUpdateResponse> {
return this.client.sendOperationRequest(
{ workspaceSettingName, workspaceSetting, options },
updateOperationSpec
);
}
/**
* Deletes the custom workspace settings for this subscription. new VMs will report to the default
* workspace
* @param workspaceSettingName Name of the security setting
* @param options The options parameters.
*/
delete(
workspaceSettingName: string,
options?: WorkspaceSettingsDeleteOptionalParams
): Promise<void> {
return this.client.sendOperationRequest(
{ workspaceSettingName, options },
deleteOperationSpec
);
}
/**
* ListNext
* @param nextLink The nextLink from the previous successful call to the List method.
* @param options The options parameters.
*/
private _listNext(
nextLink: string,
options?: WorkspaceSettingsListNextOptionalParams
): Promise<WorkspaceSettingsListNextResponse> {
return this.client.sendOperationRequest(
{ nextLink, options },
listNextOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.WorkspaceSettingList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion7],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept],
serializer
};
const getOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.WorkspaceSetting
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion7],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.workspaceSettingName
],
headerParameters: [Parameters.accept],
serializer
};
const createOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.WorkspaceSetting
},
default: {
bodyMapper: Mappers.CloudError
}
},
requestBody: Parameters.workspaceSetting,
queryParameters: [Parameters.apiVersion7],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.workspaceSettingName
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const updateOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}",
httpMethod: "PATCH",
responses: {
200: {
bodyMapper: Mappers.WorkspaceSetting
},
default: {
bodyMapper: Mappers.CloudError
}
},
requestBody: Parameters.workspaceSetting,
queryParameters: [Parameters.apiVersion7],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.workspaceSettingName
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const deleteOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}",
httpMethod: "DELETE",
responses: {
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion7],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.workspaceSettingName
],
headerParameters: [Parameters.accept],
serializer
};
const listNextOperationSpec: coreClient.OperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.WorkspaceSettingList
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion7],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};