/* * 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 { TableOperations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { StorageManagementClient } from "../storageManagementClient"; import { Table, TableListNextOptionalParams, TableListOptionalParams, TableCreateOptionalParams, TableCreateResponse, TableUpdateOptionalParams, TableUpdateResponse, TableGetOptionalParams, TableGetResponse, TableDeleteOptionalParams, TableListResponse, TableListNextResponse } from "../models"; /// /** Class containing TableOperations operations. */ export class TableOperationsImpl implements TableOperations { private readonly client: StorageManagementClient; /** * Initialize a new instance of the class TableOperations class. * @param client Reference to the service client */ constructor(client: StorageManagementClient) { this.client = client; } /** * Gets a list of all the tables under the specified storage account * @param resourceGroupName The name of the resource group within the user's subscription. The name is * case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage * account names must be between 3 and 24 characters in length and use numbers and lower-case letters * only. * @param options The options parameters. */ public list( resourceGroupName: string, accountName: string, options?: TableListOptionalParams ): PagedAsyncIterableIterator { const iter = this.listPagingAll(resourceGroupName, accountName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: () => { return this.listPagingPage(resourceGroupName, accountName, options); } }; } private async *listPagingPage( resourceGroupName: string, accountName: string, options?: TableListOptionalParams ): AsyncIterableIterator { let result = await this._list(resourceGroupName, accountName, options); yield result.value || []; let continuationToken = result.nextLink; while (continuationToken) { result = await this._listNext( resourceGroupName, accountName, continuationToken, options ); continuationToken = result.nextLink; yield result.value || []; } } private async *listPagingAll( resourceGroupName: string, accountName: string, options?: TableListOptionalParams ): AsyncIterableIterator
{ for await (const page of this.listPagingPage( resourceGroupName, accountName, options )) { yield* page; } } /** * Creates a new table with the specified table name, under the specified account. * @param resourceGroupName The name of the resource group within the user's subscription. The name is * case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage * account names must be between 3 and 24 characters in length and use numbers and lower-case letters * only. * @param tableName A table name must be unique within a storage account and must be between 3 and 63 * characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric * character. * @param options The options parameters. */ create( resourceGroupName: string, accountName: string, tableName: string, options?: TableCreateOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, accountName, tableName, options }, createOperationSpec ); } /** * Creates a new table with the specified table name, under the specified account. * @param resourceGroupName The name of the resource group within the user's subscription. The name is * case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage * account names must be between 3 and 24 characters in length and use numbers and lower-case letters * only. * @param tableName A table name must be unique within a storage account and must be between 3 and 63 * characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric * character. * @param options The options parameters. */ update( resourceGroupName: string, accountName: string, tableName: string, options?: TableUpdateOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, accountName, tableName, options }, updateOperationSpec ); } /** * Gets the table with the specified table name, under the specified account if it exists. * @param resourceGroupName The name of the resource group within the user's subscription. The name is * case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage * account names must be between 3 and 24 characters in length and use numbers and lower-case letters * only. * @param tableName A table name must be unique within a storage account and must be between 3 and 63 * characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric * character. * @param options The options parameters. */ get( resourceGroupName: string, accountName: string, tableName: string, options?: TableGetOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, accountName, tableName, options }, getOperationSpec ); } /** * Deletes the table with the specified table name, under the specified account if it exists. * @param resourceGroupName The name of the resource group within the user's subscription. The name is * case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage * account names must be between 3 and 24 characters in length and use numbers and lower-case letters * only. * @param tableName A table name must be unique within a storage account and must be between 3 and 63 * characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric * character. * @param options The options parameters. */ delete( resourceGroupName: string, accountName: string, tableName: string, options?: TableDeleteOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, accountName, tableName, options }, deleteOperationSpec ); } /** * Gets a list of all the tables under the specified storage account * @param resourceGroupName The name of the resource group within the user's subscription. The name is * case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage * account names must be between 3 and 24 characters in length and use numbers and lower-case letters * only. * @param options The options parameters. */ private _list( resourceGroupName: string, accountName: string, options?: TableListOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, accountName, options }, listOperationSpec ); } /** * ListNext * @param resourceGroupName The name of the resource group within the user's subscription. The name is * case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage * account names must be between 3 and 24 characters in length and use numbers and lower-case letters * only. * @param nextLink The nextLink from the previous successful call to the List method. * @param options The options parameters. */ private _listNext( resourceGroupName: string, accountName: string, nextLink: string, options?: TableListNextOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, accountName, nextLink, options }, listNextOperationSpec ); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const createOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.Table }, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.parameters12, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.accountName1, Parameters.tableName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const updateOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.Table }, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.parameters12, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.accountName1, Parameters.tableName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const getOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.Table }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.accountName1, Parameters.tableName ], headerParameters: [Parameters.accept], serializer }; const deleteOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", httpMethod: "DELETE", responses: { 204: {}, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.accountName1, Parameters.tableName ], headerParameters: [Parameters.accept], serializer }; const listOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ListTableResource }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.accountName1 ], headerParameters: [Parameters.accept], serializer }; const listNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ListTableResource }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.accountName1, Parameters.nextLink ], headerParameters: [Parameters.accept], serializer };