snapshot-20201118/main.tea (223 lines of code) (raw):

/** * */ import Util; import OpenApi; import OpenApiUtil; import EndpointUtil; extends OpenApi; init(config: OpenApi.Config){ super(config); @endpointRule = 'regional'; checkConfig(config); @endpoint = getEndpoint('snapshot', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint); } function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{ if (!Util.empty(endpoint)) { return endpoint; } if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) { return endpointMap[regionId]; } return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix); } model GetSnapshotBlockRequest { clientToken?: string(name='ClientToken', description='幂等参数'), blockIndex?: long(name='BlockIndex', description='待读取的数据块索引,从零开始。从 ListChangedBlocks 或者 ListSnapshotBlocks 返回'), blockToken?: string(name='BlockToken', description='待读取的数据块Token,从零开始。从 ListChangedBlocks 或者 ListSnapshotBlocks 返回'), snapshotId?: string(name='SnapshotId', description='待读取数据的快照名称'), } model GetSnapshotBlockResponse = { headers: map[string]string(name='headers'), body: readable(name='body'), } async function getSnapshotBlock(request: GetSnapshotBlockRequest): GetSnapshotBlockResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return getSnapshotBlockWithOptions(request, headers, runtime); } async function getSnapshotBlockWithOptions(request: GetSnapshotBlockRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetSnapshotBlockResponse { Util.validateModel(request); var query : map[string]any= {}; if (!Util.isUnset(request.clientToken)) { query.ClientToken = request.clientToken; } if (!Util.isUnset(request.blockIndex)) { query.BlockIndex = request.blockIndex; } if (!Util.isUnset(request.blockToken)) { query.BlockToken = request.blockToken; } if (!Util.isUnset(request.snapshotId)) { query.SnapshotId = request.snapshotId; } var req = new OpenApi.OpenApiRequest{ headers = headers, query = OpenApiUtil.query(query), }; var res = new GetSnapshotBlockResponse{}; var tmp = Util.assertAsMap(doROARequest('GetSnapshotBlock', '2020-11-18', 'HTTPS', 'GET', 'AK', `/snapshots/block`, 'binary', req, runtime)); if (!Util.isUnset(tmp.body)) { var respBody = Util.assertAsReadable(tmp.body); res.body = respBody; } if (!Util.isUnset(tmp.headers)) { var respHeaders = Util.assertAsMap(tmp.headers); res.headers = Util.stringifyMapValue(respHeaders); } return res; } model GetSnapshotInfoRequest { clientToken?: string(name='ClientToken', description='幂等参数'), snapshotId?: string(name='SnapshotId', description='待读取数据的快照名称'), showDetail?: boolean(name='ShowDetail', description='是否返回详细信息,详细信息需要更多查询时间'), } model GetSnapshotInfoResponseBody = { volumeSize?: long(name='VolumeSize', description='快照大小,单位 GB,最小 1GB'), blockSize?: long(name='BlockSize', description='快照数据快大小,单位 Bytes'), blockCount?: long(name='BlockCount', description='快照数据块总数量,包含空数据块'), validBlockCount?: long(name='ValidBlockCount', description='快照中非空数据块总数量,仅在 ShowDetail 为 True 时返回'), status?: string(name='Status', description='快照状态'), createTime?: long(name='CreateTime', description='快照创建UTC时间,单位微妙'), encrypted?: boolean(name='Encrypted', description='快照是否为加密快照'), } model GetSnapshotInfoResponse = { headers: map[string]string(name='headers'), body: GetSnapshotInfoResponseBody(name='body'), } async function getSnapshotInfo(request: GetSnapshotInfoRequest): GetSnapshotInfoResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return getSnapshotInfoWithOptions(request, headers, runtime); } async function getSnapshotInfoWithOptions(request: GetSnapshotInfoRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetSnapshotInfoResponse { Util.validateModel(request); var query : map[string]any= {}; if (!Util.isUnset(request.clientToken)) { query.ClientToken = request.clientToken; } if (!Util.isUnset(request.snapshotId)) { query.SnapshotId = request.snapshotId; } if (!Util.isUnset(request.showDetail)) { query.ShowDetail = request.showDetail; } var req = new OpenApi.OpenApiRequest{ headers = headers, query = OpenApiUtil.query(query), }; return doROARequest('GetSnapshotInfo', '2020-11-18', 'HTTPS', 'GET', 'AK', `/snapshots/info`, 'json', req, runtime); } model ListChangedBlocksRequest { nextToken?: string(name='NextToken', description='标记当前开始读取的位置,置空表示从头开始'), maxResults?: long(name='MaxResults', description='本次读取的最大数据记录数量,最小 100,最大 10000'), clientToken?: string(name='ClientToken', description='幂等参数'), firstSnapshotId?: string(name='FirstSnapshotId', description='待比较的第一个快照名称,最大 64 字节'), secondSnapshotId?: string(name='SecondSnapshotId', description='待比较的第二个快照名称,最大 64 字节'), startingBlockIndex?: long(name='StartingBlockIndex', description='两个快照比较的起始数据块 index,从零开始'), } model ListChangedBlocksResponseBody = { nextToken?: string(name='NextToken', description='下一页结果的 token,为空时代表无新增页,最大长度 256 字节'), changedBlocks?: [ { blockIndex?: long(name='BlockIndex', description='数据块的索引值,从零开始'), firstBlockToken?: string(name='FirstBlockToken', description='FirstSnapshotId 中数据块的 Token,用于后续的数据读取,第一个快照未变化时可省略。最大长度 256 字节'), secondBlockToken?: string(name='SecondBlockToken', description='SecondBlockToken指定的快照中相对于 FirstBlockIndex 变化的数据块 Token,用于后续读取数据。最大长度 256 字节'), } ](name='ChangedBlocks', description='两个快照差异的数据块列表'), expiryTime?: long(name='ExpiryTime', description='差异数据块 token 过期时间戳'), volumeSize?: long(name='VolumeSize', description='第二个快照大小,单位 GB,最小 1GB'), blockSize?: long(name='BlockSize', description='数据块大小,单位 Byte'), blockCount?: long(name='BlockCount', description='本次查询中变化数据块数量'), totalBlockCount?: long(name='TotalBlockCount', description='两个快照差异数据块总数量'), } model ListChangedBlocksResponse = { headers: map[string]string(name='headers'), body: ListChangedBlocksResponseBody(name='body'), } async function listChangedBlocks(request: ListChangedBlocksRequest): ListChangedBlocksResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return listChangedBlocksWithOptions(request, headers, runtime); } async function listChangedBlocksWithOptions(request: ListChangedBlocksRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListChangedBlocksResponse { Util.validateModel(request); var query : map[string]any= {}; if (!Util.isUnset(request.nextToken)) { query.NextToken = request.nextToken; } if (!Util.isUnset(request.maxResults)) { query.MaxResults = request.maxResults; } if (!Util.isUnset(request.clientToken)) { query.ClientToken = request.clientToken; } if (!Util.isUnset(request.firstSnapshotId)) { query.FirstSnapshotId = request.firstSnapshotId; } if (!Util.isUnset(request.secondSnapshotId)) { query.SecondSnapshotId = request.secondSnapshotId; } if (!Util.isUnset(request.startingBlockIndex)) { query.StartingBlockIndex = request.startingBlockIndex; } var req = new OpenApi.OpenApiRequest{ headers = headers, query = OpenApiUtil.query(query), }; return doROARequest('ListChangedBlocks', '2020-11-18', 'HTTPS', 'GET', 'AK', `/snapshots/changedblocks`, 'json', req, runtime); } model ListSnapshotBlocksRequest { nextToken?: string(name='NextToken', description='标记当前开始读取的位置,置空表示从头开始'), maxResults?: long(name='MaxResults', description='本次读取的最大数据记录数量,最小 100, 最大 10000'), clientToken?: string(name='ClientToken', description='幂等参数'), snapshotId?: string(name='SnapshotId', description='待列出数据块的快照名称'), startingBlockIndex?: long(name='StartingBlockIndex', description='列出快照中数据块起始索引值,从零开始'), } model ListSnapshotBlocksResponseBody = { nextToken?: string(name='NextToken', description='下一页结果的 token,为空时代表无新增页,最大 256 字节'), blocks?: [ { blockIndex?: long(name='BlockIndex', description='数据块的索引值,从零开始'), blockToken?: string(name='BlockToken', description='数据块的 Token,用于后续的数据读取。最大长度 256 字节'), } ](name='Blocks', description='快照有效数据块信息列表,不包含空数据块'), expiryTime?: long(name='ExpiryTime', description='BlockToken 过期时间戳'), volumeSize?: long(name='VolumeSize', description='快照大小,单位 GB,最小 1GB'), blockSize?: long(name='BlockSize', description='数据块大小,单位 Byte'), blockCount?: long(name='BlockCount', description='本次查询中快照有效数据块数量'), totalBlockCount?: long(name='TotalBlockCount', description='快照有效数据块总数量'), } model ListSnapshotBlocksResponse = { headers: map[string]string(name='headers'), body: ListSnapshotBlocksResponseBody(name='body'), } async function listSnapshotBlocks(request: ListSnapshotBlocksRequest): ListSnapshotBlocksResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return listSnapshotBlocksWithOptions(request, headers, runtime); } async function listSnapshotBlocksWithOptions(request: ListSnapshotBlocksRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListSnapshotBlocksResponse { Util.validateModel(request); var query : map[string]any= {}; if (!Util.isUnset(request.nextToken)) { query.NextToken = request.nextToken; } if (!Util.isUnset(request.maxResults)) { query.MaxResults = request.maxResults; } if (!Util.isUnset(request.clientToken)) { query.ClientToken = request.clientToken; } if (!Util.isUnset(request.snapshotId)) { query.SnapshotId = request.snapshotId; } if (!Util.isUnset(request.startingBlockIndex)) { query.StartingBlockIndex = request.startingBlockIndex; } var req = new OpenApi.OpenApiRequest{ headers = headers, query = OpenApiUtil.query(query), }; return doROARequest('ListSnapshotBlocks', '2020-11-18', 'HTTPS', 'GET', 'AK', `/snapshots/listblocks`, 'json', req, runtime); }