UNPKG

@azure/arm-compute

Version:
388 lines 14.6 kB
/* * 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 { setContinuationToken } from "../pagingHelper.js"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers.js"; import * as Parameters from "../models/parameters.js"; /// <reference lib="esnext.asynciterable" /> /** Class containing SshPublicKeys operations. */ export class SshPublicKeysImpl { client; /** * Initialize a new instance of the class SshPublicKeys class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to * get the next page of SSH public keys. * @param options The options parameters. */ listBySubscription(options) { const iter = this.listBySubscriptionPagingAll(options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listBySubscriptionPagingPage(options, settings); }, }; } async *listBySubscriptionPagingPage(options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listBySubscription(options); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listBySubscriptionNext(continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listBySubscriptionPagingAll(options) { for await (const page of this.listBySubscriptionPagingPage(options)) { yield* page; } } /** * Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the * response to get the next page of SSH public keys. * @param resourceGroupName The name of the resource group. 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: (settings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listByResourceGroupPagingPage(resourceGroupName, options, settings); }, }; } async *listByResourceGroupPagingPage(resourceGroupName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByResourceGroup(resourceGroupName, options); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByResourceGroupNext(resourceGroupName, continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listByResourceGroupPagingAll(resourceGroupName, options) { for await (const page of this.listByResourceGroupPagingPage(resourceGroupName, options)) { yield* page; } } /** * Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to * get the next page of SSH public keys. * @param options The options parameters. */ _listBySubscription(options) { return this.client.sendOperationRequest({ options }, listBySubscriptionOperationSpec); } /** * Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the * response to get the next page of SSH public keys. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param options The options parameters. */ _listByResourceGroup(resourceGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, options }, listByResourceGroupOperationSpec); } /** * Retrieves information about an SSH public key. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param sshPublicKeyName The name of the SSH public key. * @param options The options parameters. */ get(resourceGroupName, sshPublicKeyName, options) { return this.client.sendOperationRequest({ resourceGroupName, sshPublicKeyName, options }, getOperationSpec); } /** * Creates a new SSH public key resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param sshPublicKeyName The name of the SSH public key. * @param parameters Parameters supplied to create the SSH public key. * @param options The options parameters. */ create(resourceGroupName, sshPublicKeyName, parameters, options) { return this.client.sendOperationRequest({ resourceGroupName, sshPublicKeyName, parameters, options }, createOperationSpec); } /** * Updates a new SSH public key resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param sshPublicKeyName The name of the SSH public key. * @param parameters Parameters supplied to update the SSH public key. * @param options The options parameters. */ update(resourceGroupName, sshPublicKeyName, parameters, options) { return this.client.sendOperationRequest({ resourceGroupName, sshPublicKeyName, parameters, options }, updateOperationSpec); } /** * Delete an SSH public key. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param sshPublicKeyName The name of the SSH public key. * @param options The options parameters. */ delete(resourceGroupName, sshPublicKeyName, options) { return this.client.sendOperationRequest({ resourceGroupName, sshPublicKeyName, options }, deleteOperationSpec); } /** * Generates and returns a public/private key pair and populates the SSH public key resource with the * public key. The length of the key will be 3072 bits. This operation can only be performed once per * SSH public key resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param sshPublicKeyName The name of the SSH public key. * @param options The options parameters. */ generateKeyPair(resourceGroupName, sshPublicKeyName, options) { return this.client.sendOperationRequest({ resourceGroupName, sshPublicKeyName, options }, generateKeyPairOperationSpec); } /** * ListBySubscriptionNext * @param nextLink The nextLink from the previous successful call to the ListBySubscription method. * @param options The options parameters. */ _listBySubscriptionNext(nextLink, options) { return this.client.sendOperationRequest({ nextLink, options }, listBySubscriptionNextOperationSpec); } /** * ListByResourceGroupNext * @param resourceGroupName The name of the resource group. 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 listBySubscriptionOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SshPublicKeysGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer, }; const listByResourceGroupOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SshPublicKeysGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, ], headerParameters: [Parameters.accept], serializer, }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SshPublicKeyResource, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.sshPublicKeyName, ], headerParameters: [Parameters.accept], serializer, }; const createOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.SshPublicKeyResource, }, 201: { bodyMapper: Mappers.SshPublicKeyResource, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters27, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.sshPublicKeyName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.SshPublicKeyResource, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters28, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.sshPublicKeyName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", httpMethod: "DELETE", responses: { 200: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.sshPublicKeyName, ], headerParameters: [Parameters.accept], serializer, }; const generateKeyPairOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.SshPublicKeyGenerateKeyPairResult, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters29, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.sshPublicKeyName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const listBySubscriptionNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SshPublicKeysGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, ], headerParameters: [Parameters.accept], serializer, }; const listByResourceGroupNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SshPublicKeysGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=sshPublicKeys.js.map