Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 7x 7x 7x 7x 7x 2x 2x 7x 7x 3x | import {
StorageTransport,
parseStorageConnectionString,
storageAccountName,
tableProtocol,
} from './internal/storage-request'
import type { StorageClientOptions, StorageCredential } from './internal/storage-request'
import { appendUrlPath, normalizeStorageUrl } from './internal/storage-url'
import { createTable, deleteTable } from './internal/table-requests'
import type { TableCreateIfNotExistsResponse, TableDeleteResponse } from './internal/table-requests'
import { encodeResourceSegment } from './internal/url'
import { TableClient } from './table-client'
export class TableServiceClient {
public readonly accountName: string
public readonly url: string
private readonly credential: StorageCredential | undefined
private readonly options: StorageClientOptions | undefined
private readonly transport: StorageTransport
public constructor(url: string, credential?: StorageCredential, options?: StorageClientOptions) {
this.url = normalizeStorageUrl(url)
this.accountName = storageAccountName(url, credential)
this.credential = credential
this.options = options
this.transport = new StorageTransport(credential, options, tableProtocol)
}
public static fromConnectionString(
connectionString: string,
options?: StorageClientOptions,
): TableServiceClient {
const { url, credential } = parseStorageConnectionString(connectionString, 'table')
return new TableServiceClient(url, credential, options)
}
public getTableClient(tableName: string): TableClient {
const url = appendUrlPath(this.url, encodeResourceSegment(tableName, 'Table name'))
return new TableClient(url, this.credential, this.options)
}
public async createTableIfNotExists(tableName: string): Promise<TableCreateIfNotExistsResponse> {
return await createTable(this.transport, this.url, tableName)
}
public async deleteTableIfExists(tableName: string): Promise<TableDeleteResponse> {
return await deleteTable(this.transport, this.url, tableName)
}
}
|