From bd25eaeb350649e2d9ee939d5d73fba741cc674d Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Fri, 9 Oct 2020 14:33:10 +0800 Subject: [PATCH 1/4] format datalake --- sdk/storage/storage-file-datalake/src/sas/SASQueryParameters.ts | 2 +- sdk/storage/storage-file-datalake/src/transforms.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/storage/storage-file-datalake/src/sas/SASQueryParameters.ts b/sdk/storage/storage-file-datalake/src/sas/SASQueryParameters.ts index caf69cf81d45..541ad7d449ff 100644 --- a/sdk/storage/storage-file-datalake/src/sas/SASQueryParameters.ts +++ b/sdk/storage/storage-file-datalake/src/sas/SASQueryParameters.ts @@ -485,7 +485,7 @@ export class SASQueryParameters { correlationId?: string ); - /** + /** * Creates an instance of SASQueryParameters. * * @param {string} version Representing the storage version diff --git a/sdk/storage/storage-file-datalake/src/transforms.ts b/sdk/storage/storage-file-datalake/src/transforms.ts index d2ce75618b37..1c4a395ff53b 100644 --- a/sdk/storage/storage-file-datalake/src/transforms.ts +++ b/sdk/storage/storage-file-datalake/src/transforms.ts @@ -16,7 +16,7 @@ import { RemovePathAccessControlItem, RolePermissions, ServiceListContainersSegmentResponse, - ServiceListFileSystemsSegmentResponse, + ServiceListFileSystemsSegmentResponse } from "./models"; import { ToBlobEndpointHostMappings, ToDfsEndpointHostMappings } from "./utils/constants"; import { base64encode } from "./utils/utils.common"; From 11856936064b2a1406594266f704d37ad1902b79 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Fri, 9 Oct 2020 15:06:29 +0800 Subject: [PATCH 2/4] re-generate file with de8a4f0 --- .../src/generated/src/models/index.ts | 48 +++++++++++++++---- .../src/generated/src/models/mappers.ts | 45 +++++++++++++++-- .../src/generated/src/models/parameters.ts | 12 +++++ .../src/generated/src/models/shareMappers.ts | 2 +- .../src/generated/src/operations/share.ts | 24 +++++----- 5 files changed, 108 insertions(+), 23 deletions(-) diff --git a/sdk/storage/storage-file-share/src/generated/src/models/index.ts b/sdk/storage/storage-file-share/src/generated/src/models/index.ts index f38fc0e12f46..0a5037282dc7 100644 --- a/sdk/storage/storage-file-share/src/generated/src/models/index.ts +++ b/sdk/storage/storage-file-share/src/generated/src/models/index.ts @@ -175,6 +175,9 @@ export interface ShareProperties { nextAllowedQuotaDowngradeTime?: Date; deletedTime?: Date; remainingRetentionDays?: number; + accessTier?: string; + accessTierChangeTime?: Date; + accessTierTransitionState?: string; /** * Possible values include: 'locked', 'unlocked' */ @@ -540,6 +543,11 @@ export interface ShareCreateOptionalParams extends coreHttp.RequestOptionsBase { * Specifies the maximum size of the share, in gigabytes. */ quota?: number; + /** + * Specifies the access tier of the share. Possible values include: 'TransactionOptimized', + * 'Hot', 'Cool' + */ + accessTier?: ShareAccessTier; } /** @@ -774,7 +782,7 @@ export interface ShareGetPermissionOptionalParams extends coreHttp.RequestOption /** * Optional Parameters. */ -export interface ShareSetQuotaOptionalParams extends coreHttp.RequestOptionsBase { +export interface ShareSetPropertiesOptionalParams extends coreHttp.RequestOptionsBase { /** * The timeout parameter is expressed in seconds. For more information, see Setting @@ -785,6 +793,11 @@ export interface ShareSetQuotaOptionalParams extends coreHttp.RequestOptionsBase * Specifies the maximum size of the share, in gigabytes. */ quota?: number; + /** + * Specifies the access tier of the share. Possible values include: 'TransactionOptimized', + * 'Hot', 'Cool' + */ + accessTier?: ShareAccessTier; /** * Additional parameters for the operation */ @@ -1664,6 +1677,18 @@ export interface ShareGetPropertiesHeaders { * The current lease status of the share. Possible values include: 'locked', 'unlocked' */ leaseStatus?: LeaseStatusType; + /** + * Returns the access tier set on the share. + */ + accessTier?: string; + /** + * Returns the last modified time (in UTC) of the access tier of the share. + */ + accessTierChangeTime?: Date; + /** + * Returns the transition state betweeen access tiers, when present. + */ + accessTierTransitionState?: string; errorCode?: string; } @@ -1837,8 +1862,7 @@ export interface ShareRenewLeaseHeaders { */ version?: string; /** - * UTC date/time value generated by the service that indicates the time at which the response was - * initiated + * Returns the current share next allowed quota downgrade time. */ date?: Date; errorCode?: string; @@ -1979,9 +2003,9 @@ export interface ShareGetPermissionHeaders { } /** - * Defines headers for SetQuota operation. + * Defines headers for SetProperties operation. */ -export interface ShareSetQuotaHeaders { +export interface ShareSetPropertiesHeaders { /** * The ETag contains a value that you can use to perform operations conditionally, in quotes. */ @@ -3435,6 +3459,14 @@ export type LeaseStateType = 'available' | 'leased' | 'expired' | 'breaking' | ' */ export type LeaseStatusType = 'locked' | 'unlocked'; +/** + * Defines values for ShareAccessTier. + * Possible values include: 'TransactionOptimized', 'Hot', 'Cool' + * @readonly + * @enum {string} + */ +export type ShareAccessTier = 'TransactionOptimized' | 'Hot' | 'Cool'; + /** * Defines values for PermissionCopyModeType. * Possible values include: 'source', 'override' @@ -3724,9 +3756,9 @@ export type ShareGetPermissionResponse = SharePermission & ShareGetPermissionHea }; /** - * Contains response data for the setQuota operation. + * Contains response data for the setProperties operation. */ -export type ShareSetQuotaResponse = ShareSetQuotaHeaders & { +export type ShareSetPropertiesResponse = ShareSetPropertiesHeaders & { /** * The underlying HTTP response. */ @@ -3734,7 +3766,7 @@ export type ShareSetQuotaResponse = ShareSetQuotaHeaders & { /** * The parsed HTTP response headers. */ - parsedHeaders: ShareSetQuotaHeaders; + parsedHeaders: ShareSetPropertiesHeaders; }; }; diff --git a/sdk/storage/storage-file-share/src/generated/src/models/mappers.ts b/sdk/storage/storage-file-share/src/generated/src/models/mappers.ts index 84f565862f88..c5b8fb1b0bd9 100644 --- a/sdk/storage/storage-file-share/src/generated/src/models/mappers.ts +++ b/sdk/storage/storage-file-share/src/generated/src/models/mappers.ts @@ -463,6 +463,27 @@ export const ShareProperties: coreHttp.CompositeMapper = { name: "Number" } }, + accessTier: { + xmlName: "AccessTier", + serializedName: "AccessTier", + type: { + name: "String" + } + }, + accessTierChangeTime: { + xmlName: "AccessTierChangeTime", + serializedName: "AccessTierChangeTime", + type: { + name: "DateTimeRfc1123" + } + }, + accessTierTransitionState: { + xmlName: "AccessTierTransitionState", + serializedName: "AccessTierTransitionState", + type: { + name: "String" + } + }, leaseStatus: { xmlName: "LeaseStatus", serializedName: "LeaseStatus", @@ -1347,6 +1368,24 @@ export const ShareGetPropertiesHeaders: coreHttp.CompositeMapper = { ] } }, + accessTier: { + serializedName: "x-ms-access-tier", + type: { + name: "String" + } + }, + accessTierChangeTime: { + serializedName: "x-ms-access-tier-change-time", + type: { + name: "DateTimeRfc1123" + } + }, + accessTierTransitionState: { + serializedName: "x-ms-access-tier-transition-state", + type: { + name: "String" + } + }, errorCode: { serializedName: "x-ms-error-code", type: { @@ -1807,11 +1846,11 @@ export const ShareGetPermissionHeaders: coreHttp.CompositeMapper = { } }; -export const ShareSetQuotaHeaders: coreHttp.CompositeMapper = { - serializedName: "share-setquota-headers", +export const ShareSetPropertiesHeaders: coreHttp.CompositeMapper = { + serializedName: "share-setproperties-headers", type: { name: "Composite", - className: "ShareSetQuotaHeaders", + className: "ShareSetPropertiesHeaders", modelProperties: { etag: { serializedName: "etag", diff --git a/sdk/storage/storage-file-share/src/generated/src/models/parameters.ts b/sdk/storage/storage-file-share/src/generated/src/models/parameters.ts index 72a17ff86b35..3d787212b73c 100644 --- a/sdk/storage/storage-file-share/src/generated/src/models/parameters.ts +++ b/sdk/storage/storage-file-share/src/generated/src/models/parameters.ts @@ -10,6 +10,18 @@ import * as coreHttp from "@azure/core-http"; +export const accessTier: coreHttp.OperationParameter = { + parameterPath: [ + "options", + "accessTier" + ], + mapper: { + serializedName: "x-ms-access-tier", + type: { + name: "String" + } + } +}; export const action0: coreHttp.OperationParameter = { parameterPath: "action", mapper: { diff --git a/sdk/storage/storage-file-share/src/generated/src/models/shareMappers.ts b/sdk/storage/storage-file-share/src/generated/src/models/shareMappers.ts index 6dfc0b033b49..e21c713360e1 100644 --- a/sdk/storage/storage-file-share/src/generated/src/models/shareMappers.ts +++ b/sdk/storage/storage-file-share/src/generated/src/models/shareMappers.ts @@ -25,7 +25,7 @@ export { ShareRestoreHeaders, ShareSetAccessPolicyHeaders, ShareSetMetadataHeaders, - ShareSetQuotaHeaders, + ShareSetPropertiesHeaders, ShareStats, SignedIdentifier, StorageError diff --git a/sdk/storage/storage-file-share/src/generated/src/operations/share.ts b/sdk/storage/storage-file-share/src/generated/src/operations/share.ts index 819b64b2b2cb..4459f676cd01 100644 --- a/sdk/storage/storage-file-share/src/generated/src/operations/share.ts +++ b/sdk/storage/storage-file-share/src/generated/src/operations/share.ts @@ -319,27 +319,27 @@ export class Share { } /** - * Sets quota for the specified share. + * Sets properties for the specified share. * @param [options] The optional parameters - * @returns Promise + * @returns Promise */ - setQuota(options?: Models.ShareSetQuotaOptionalParams): Promise; + setProperties(options?: Models.ShareSetPropertiesOptionalParams): Promise; /** * @param callback The callback */ - setQuota(callback: coreHttp.ServiceCallback): void; + setProperties(callback: coreHttp.ServiceCallback): void; /** * @param options The optional parameters * @param callback The callback */ - setQuota(options: Models.ShareSetQuotaOptionalParams, callback: coreHttp.ServiceCallback): void; - setQuota(options?: Models.ShareSetQuotaOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + setProperties(options: Models.ShareSetPropertiesOptionalParams, callback: coreHttp.ServiceCallback): void; + setProperties(options?: Models.ShareSetPropertiesOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { return this.client.sendOperationRequest( { options }, - setQuotaOperationSpec, - callback) as Promise; + setPropertiesOperationSpec, + callback) as Promise; } /** @@ -478,6 +478,7 @@ const createOperationSpec: coreHttp.OperationSpec = { headerParameters: [ Parameters.metadata, Parameters.quota, + Parameters.accessTier, Parameters.version ], responses: { @@ -800,7 +801,7 @@ const getPermissionOperationSpec: coreHttp.OperationSpec = { serializer }; -const setQuotaOperationSpec: coreHttp.OperationSpec = { +const setPropertiesOperationSpec: coreHttp.OperationSpec = { httpMethod: "PUT", path: "{shareName}", urlParameters: [ @@ -814,15 +815,16 @@ const setQuotaOperationSpec: coreHttp.OperationSpec = { headerParameters: [ Parameters.version, Parameters.quota, + Parameters.accessTier, Parameters.leaseId0 ], responses: { 200: { - headersMapper: Mappers.ShareSetQuotaHeaders + headersMapper: Mappers.ShareSetPropertiesHeaders }, default: { bodyMapper: Mappers.StorageError, - headersMapper: Mappers.ShareSetQuotaHeaders + headersMapper: Mappers.ShareSetPropertiesHeaders } }, isXML: true, From cb0343de191888787b236b94fe6c68063101b09a Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Fri, 9 Oct 2020 16:48:20 +0800 Subject: [PATCH 3/4] add set share tier --- ...e_specifying_accesstier_and_listshare.json | 108 +++++++++++++++++ .../shareclient/recording_setaccesstier.json | 98 ++++++++++++++++ ...are_specifying_accesstier_and_listshare.js | 109 ++++++++++++++++++ .../shareclient/recording_setaccesstier.js | 109 ++++++++++++++++++ .../review/storage-file-share.api.md | 38 +++++- sdk/storage/storage-file-share/src/Clients.ts | 65 ++++++++++- .../storage-file-share/src/generatedModels.ts | 19 ++- .../test/shareclient.spec.ts | 25 ++++ 8 files changed, 561 insertions(+), 10 deletions(-) create mode 100644 sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_create_share_specifying_accesstier_and_listshare.json create mode 100644 sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_setaccesstier.json create mode 100644 sdk/storage/storage-file-share/recordings/node/shareclient/recording_create_share_specifying_accesstier_and_listshare.js create mode 100644 sdk/storage/storage-file-share/recordings/node/shareclient/recording_setaccesstier.js diff --git a/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_create_share_specifying_accesstier_and_listshare.json b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_create_share_specifying_accesstier_and_listshare.json new file mode 100644 index 000000000000..ed7520ca1084 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_create_share_specifying_accesstier_and_listshare.json @@ -0,0 +1,108 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share160223291748509107", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Fri, 09 Oct 2020 08:41:58 GMT", + "etag": "\"0x8D86C2F2F81CAF0\"", + "last-modified": "Fri, 09 Oct 2020 08:41:58 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "95939ed5-05d8-4232-a852-19d4371fe756", + "x-ms-request-id": "cabdd372-901a-0073-1118-9e3635000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/newshare160223291907902683", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Fri, 09 Oct 2020 08:41:58 GMT", + "etag": "\"0x8D86C2F2FE1FDCA\"", + "last-modified": "Fri, 09 Oct 2020 08:41:59 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "8be33499-a83e-4ee4-b0b1-25ca46e8cf00", + "x-ms-request-id": "cabdd376-901a-0073-1418-9e3635000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "GET", + "url": "https://fakestorageaccount.file.core.windows.net/", + "query": { + "prefix": "newshare160223291907902683", + "comp": "list" + }, + "requestBody": null, + "status": 200, + "response": "newshare160223291907902683newshare160223291907902683Fri, 09 Oct 2020 08:41:59 GMT\"0x8D86C2F2FE1FDCA\"unlockedavailable5120HotFri, 09 Oct 2020 08:41:59 GMT$account-encryption-keyfalse", + "responseHeaders": { + "content-type": "application/xml", + "date": "Fri, 09 Oct 2020 08:41:59 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding": "chunked", + "x-ms-client-request-id": "b6d35e5a-ce2c-426b-8f8c-39c0718a53ec", + "x-ms-request-id": "cabdd379-901a-0073-1618-9e3635000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/newshare160223291907902683", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Fri, 09 Oct 2020 08:41:59 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "c9399584-b45d-40eb-b44c-42321039f80e", + "x-ms-request-id": "cabdd37c-901a-0073-1818-9e3635000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share160223291748509107", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Fri, 09 Oct 2020 08:42:00 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "3e7a8cfe-acf5-4d29-985b-80b3eff56157", + "x-ms-request-id": "cabdd37e-901a-0073-1a18-9e3635000000", + "x-ms-version": "2020-02-10" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share160223291748509107", + "newshare": "newshare160223291907902683" + }, + "newDate": {} + }, + "hash": "ecaeea5c0525719df5426fd640a49c35" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_setaccesstier.json b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_setaccesstier.json new file mode 100644 index 000000000000..73a75b0ce203 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_setaccesstier.json @@ -0,0 +1,98 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share160223292153606227", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Fri, 09 Oct 2020 08:42:01 GMT", + "etag": "\"0x8D86C2F31569253\"", + "last-modified": "Fri, 09 Oct 2020 08:42:01 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "f326ea15-b033-40d5-a6ad-1a89055ff503", + "x-ms-request-id": "cabdd380-901a-0073-1c18-9e3635000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share160223292153606227", + "query": { + "restype": "share", + "comp": "properties" + }, + "requestBody": null, + "status": 200, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Fri, 09 Oct 2020 08:42:01 GMT", + "etag": "\"0x8D86C2F31B22508\"", + "last-modified": "Fri, 09 Oct 2020 08:42:02 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "d56fc850-6721-444d-a95f-8bea4a422ac8", + "x-ms-request-id": "cabdd384-901a-0073-1e18-9e3635000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "GET", + "url": "https://fakestorageaccount.file.core.windows.net/share160223292153606227", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 200, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Fri, 09 Oct 2020 08:42:02 GMT", + "etag": "\"0x8D86C2F31B22508\"", + "last-modified": "Fri, 09 Oct 2020 08:42:02 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-change-time": "Fri, 09 Oct 2020 08:42:02 GMT", + "x-ms-access-tier-transition-state": "pending-from-transactionOptimized", + "x-ms-client-request-id": "1e56ea0d-ac8e-45b4-bada-54ba0e120771", + "x-ms-has-immutability-policy": "false", + "x-ms-has-legal-hold": "false", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-request-id": "cabdd388-901a-0073-2118-9e3635000000", + "x-ms-share-quota": "5120", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share160223292153606227", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Fri, 09 Oct 2020 08:42:02 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "a8daebe7-5e7f-46ab-8243-15fa950bf24b", + "x-ms-request-id": "cabdd38c-901a-0073-2418-9e3635000000", + "x-ms-version": "2020-02-10" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share160223292153606227" + }, + "newDate": {} + }, + "hash": "27122424ce12efd6ef8d210c26be42c2" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/node/shareclient/recording_create_share_specifying_accesstier_and_listshare.js b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_create_share_specifying_accesstier_and_listshare.js new file mode 100644 index 000000000000..a8792c0e453b --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_create_share_specifying_accesstier_and_listshare.js @@ -0,0 +1,109 @@ +let nock = require('nock'); + +module.exports.hash = "696dcf230d6f213e7bcafda589c44963"; + +module.exports.testInfo = {"uniqueName":{"share":"share160223286231007564","newshare":"newshare160223286388702010"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share160223286231007564') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Fri, 09 Oct 2020 08:41:03 GMT', + 'ETag', + '"0x8D86C2F0E95EA45"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '99321ef9-901a-003e-7e17-9ef9d9000000', + 'x-ms-client-request-id', + 'b75fd907-794e-4395-a1af-e3e4d210afbf', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Fri, 09 Oct 2020 08:41:02 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/newshare160223286388702010') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Fri, 09 Oct 2020 08:41:04 GMT', + 'ETag', + '"0x8D86C2F0ECE69AE"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '99321efc-901a-003e-7f17-9ef9d9000000', + 'x-ms-client-request-id', + '9319bdab-9496-43a5-b30b-60bd9deb24c2', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Fri, 09 Oct 2020 08:41:03 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .get('/') + .query(true) + .reply(200, "newshare160223286388702010newshare160223286388702010Fri, 09 Oct 2020 08:41:04 GMT\"0x8D86C2F0ECE69AE\"unlockedavailable5120HotFri, 09 Oct 2020 08:41:04 GMT$account-encryption-keyfalse", [ + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '99321efe-901a-003e-8017-9ef9d9000000', + 'x-ms-client-request-id', + '0364136a-2286-42b0-8ecc-b659911855e1', + 'x-ms-version', + '2020-02-10', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Content-Type,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Fri, 09 Oct 2020 08:41:03 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/newshare160223286388702010') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '99321f00-901a-003e-0217-9ef9d9000000', + 'x-ms-client-request-id', + '082a4bf4-eae5-4924-b189-ace4b20458c5', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Fri, 09 Oct 2020 08:41:03 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share160223286231007564') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '99321f03-901a-003e-0317-9ef9d9000000', + 'x-ms-client-request-id', + '71feaee9-7b0d-4a86-a1bd-ffc4afcf64e7', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Fri, 09 Oct 2020 08:41:04 GMT' +]); diff --git a/sdk/storage/storage-file-share/recordings/node/shareclient/recording_setaccesstier.js b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_setaccesstier.js new file mode 100644 index 000000000000..4fdcc1fd261b --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_setaccesstier.js @@ -0,0 +1,109 @@ +let nock = require('nock'); + +module.exports.hash = "97606f0e609c7dd5b3f6d2632d8e969f"; + +module.exports.testInfo = {"uniqueName":{"share":"share160223286522402314"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share160223286522402314') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Fri, 09 Oct 2020 08:41:05 GMT', + 'ETag', + '"0x8D86C2F0F99CE13"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '99321f04-901a-003e-0417-9ef9d9000000', + 'x-ms-client-request-id', + 'caeb897f-b0ee-4f12-b4c6-7aea17f48b80', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Fri, 09 Oct 2020 08:41:04 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share160223286522402314') + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Fri, 09 Oct 2020 08:41:05 GMT', + 'ETag', + '"0x8D86C2F0FCA822C"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '99321f07-901a-003e-0617-9ef9d9000000', + 'x-ms-client-request-id', + '4c684016-8e01-4c45-b31e-2d32e05936d5', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Fri, 09 Oct 2020 08:41:04 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .get('/share160223286522402314') + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Fri, 09 Oct 2020 08:41:05 GMT', + 'ETag', + '"0x8D86C2F0FCA822C"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '99321f08-901a-003e-0717-9ef9d9000000', + 'x-ms-client-request-id', + '876b515a-7d8e-4f3d-84e3-d7deef1b3a3c', + 'x-ms-version', + '2020-02-10', + 'x-ms-lease-status', + 'unlocked', + 'x-ms-lease-state', + 'available', + 'x-ms-has-immutability-policy', + 'false', + 'x-ms-has-legal-hold', + 'false', + 'x-ms-share-quota', + '5120', + 'x-ms-access-tier', + 'Hot', + 'x-ms-access-tier-change-time', + 'Fri, 09 Oct 2020 08:41:05 GMT', + 'x-ms-access-tier-transition-state', + 'pending-from-transactionOptimized', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Last-Modified,ETag,x-ms-lease-status,x-ms-lease-state,x-ms-has-immutability-policy,x-ms-has-legal-hold,x-ms-share-quota,x-ms-access-tier,x-ms-access-tier-change-time,x-ms-access-tier-transition-state,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Fri, 09 Oct 2020 08:41:05 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share160223286522402314') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '99321f0a-901a-003e-0917-9ef9d9000000', + 'x-ms-client-request-id', + '29dc1124-d0e4-4bdb-9b81-10b487fef1bd', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Fri, 09 Oct 2020 08:41:05 GMT' +]); diff --git a/sdk/storage/storage-file-share/review/storage-file-share.api.md b/sdk/storage/storage-file-share/review/storage-file-share.api.md index 08200fa88502..75491d375576 100644 --- a/sdk/storage/storage-file-share/review/storage-file-share.api.md +++ b/sdk/storage/storage-file-share/review/storage-file-share.api.md @@ -1320,6 +1320,9 @@ export interface ServiceUndeleteShareOptions extends CommonOptions { export interface SetPropertiesResponse extends FileSetHTTPHeadersResponse { } +// @public +export type ShareAccessTier = 'TransactionOptimized' | 'Hot' | 'Cool'; + // Warning: (ae-forgotten-export) The symbol "StorageClient" needs to be exported by the entry point index.d.ts // // @public @@ -1353,6 +1356,7 @@ export class ShareClient extends StorageClient { get name(): string; get rootDirectoryClient(): ShareDirectoryClient; setAccessPolicy(shareAcl?: SignedIdentifier[], options?: ShareSetAccessPolicyOptions): Promise; + setAccessTier(accessTier: ShareAccessTier, options?: ShareSetAccessTierOptions): Promise; setMetadata(metadata?: Metadata, options?: ShareSetMetadataOptions): Promise; setQuota(quotaInGB: number, options?: ShareSetQuotaOptions): Promise; withSnapshot(snapshot: string): ShareClient; @@ -1377,6 +1381,7 @@ export interface ShareCreateIfNotExistsResponse extends ShareCreateResponse { // @public export interface ShareCreateOptions extends CommonOptions { abortSignal?: AbortSignalLike; + accessTier?: ShareAccessTier; metadata?: { [propertyName: string]: string; }; @@ -1610,6 +1615,9 @@ export type ShareGetPermissionResponse = SharePermission & ShareGetPermissionHea // @public export interface ShareGetPropertiesHeaders { + accessTier?: string; + accessTierChangeTime?: Date; + accessTierTransitionState?: string; date?: Date; // (undocumented) errorCode?: string; @@ -1712,6 +1720,12 @@ export interface SharePermission { // @public export interface ShareProperties { + // (undocumented) + accessTier?: string; + // (undocumented) + accessTierChangeTime?: Date; + // (undocumented) + accessTierTransitionState?: string; // (undocumented) deletedTime?: Date; // (undocumented) @@ -1792,6 +1806,12 @@ export type ShareSetAccessPolicyResponse = ShareSetAccessPolicyHeaders & { }; }; +// @public +export interface ShareSetAccessTierOptions extends CommonOptions { + abortSignal?: AbortSignalLike; + leaseAccessConditions?: LeaseAccessConditions; +} + // @public export interface ShareSetMetadataHeaders { date?: Date; @@ -1817,7 +1837,7 @@ export type ShareSetMetadataResponse = ShareSetMetadataHeaders & { }; // @public -export interface ShareSetQuotaHeaders { +export interface ShareSetPropertiesHeaders { date?: Date; // (undocumented) errorCode?: string; @@ -1827,6 +1847,16 @@ export interface ShareSetQuotaHeaders { version?: string; } +// @public +export type ShareSetPropertiesResponse = ShareSetPropertiesHeaders & { + _response: coreHttp.HttpResponse & { + parsedHeaders: ShareSetPropertiesHeaders; + }; +}; + +// @public +export type ShareSetQuotaHeaders = ShareSetPropertiesHeaders; + // @public export interface ShareSetQuotaOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -1834,11 +1864,7 @@ export interface ShareSetQuotaOptions extends CommonOptions { } // @public -export type ShareSetQuotaResponse = ShareSetQuotaHeaders & { - _response: coreHttp.HttpResponse & { - parsedHeaders: ShareSetQuotaHeaders; - }; -}; +export type ShareSetQuotaResponse = ShareSetPropertiesResponse; // @public export interface ShareSmbSettings { diff --git a/sdk/storage/storage-file-share/src/Clients.ts b/sdk/storage/storage-file-share/src/Clients.ts index 104d2987fbb8..19303d7cad40 100644 --- a/sdk/storage/storage-file-share/src/Clients.ts +++ b/sdk/storage/storage-file-share/src/Clients.ts @@ -99,6 +99,7 @@ import { import { StorageClientContext } from "./generated/src/storageClientContext"; import { SERVICE_VERSION } from "./utils/constants"; import { generateUuid } from "@azure/core-http"; +import { ShareAccessTier, ShareSetPropertiesResponse } from "./generated/src/models"; /** * Options to configure the {@link ShareClient.create} operation. @@ -131,6 +132,14 @@ export interface ShareCreateOptions extends CommonOptions { * @memberof ShareCreateOptions */ quota?: number; + + /** + * Specifies the access tier of the share. Possible values include: 'TransactionOptimized', + * 'Hot', 'Cool' + * @type {ShareAccessTier} + * @memberof ShareCreateOptions + */ + accessTier?: ShareAccessTier; } /** @@ -310,6 +319,30 @@ export interface ShareSetQuotaOptions extends CommonOptions { leaseAccessConditions?: LeaseAccessConditions; } +/** + * Options to configure the {@link ShareClient.setAccessTier} operation. + * + * @export + * @interface ShareSetAccessTierOptions + */ +export interface ShareSetAccessTierOptions extends CommonOptions { + /** + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. + * + * @type {AbortSignalLike} + * @memberof ShareSetAccessTierOptions + */ + abortSignal?: AbortSignalLike; + /** + * If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * + * @type {LeaseAccessConditions} + * @memberof ShareSetAccessTierOptions + */ + leaseAccessConditions?: LeaseAccessConditions; +} + /** * Options to configure the {@link ShareClient.getStatistics} operation. * @@ -1219,7 +1252,7 @@ export class ShareClient extends StorageClient { `Share quota must be greater than 0, and less than or equal to 5Tib (5120GB)` ); } - return await this.context.setQuota({ + return await this.context.setProperties({ ...options, quota: quotaInGB, spanOptions @@ -1235,6 +1268,36 @@ export class ShareClient extends StorageClient { } } + /** + * Sets access tier of the share. + * + * @param {ShareAccessTier} accessTier Access tier to set on the share. + * @param {ShareSetAccessTierOptions} [option] Options to Share Set Quota operation. + * @returns {Promise} Response data for the Share Get Quota operation. + * @memberof ShareClient + */ + public async setAccessTier( + accessTier: ShareAccessTier, + options: ShareSetAccessTierOptions = {} + ): Promise { + const { span, spanOptions } = createSpan("ShareClient-setAccessTier", options.tracingOptions); + try { + return await this.context.setProperties({ + ...options, + accessTier, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }); + } catch (e) { + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Retrieves statistics related to the share. * diff --git a/sdk/storage/storage-file-share/src/generatedModels.ts b/sdk/storage/storage-file-share/src/generatedModels.ts index 83bca5b0c112..9a08c0661536 100644 --- a/sdk/storage/storage-file-share/src/generatedModels.ts +++ b/sdk/storage/storage-file-share/src/generatedModels.ts @@ -48,7 +48,7 @@ export { ShareItem, ShareSetAccessPolicyResponse, ShareSetMetadataResponse, - ShareSetQuotaResponse, + ShareSetPropertiesResponse, SignedIdentifier as SignedIdentifierModel, SourceModifiedAccessConditions, FileForceCloseHandlesHeaders, @@ -94,7 +94,7 @@ export { ShareProperties, ShareSetAccessPolicyHeaders, ShareSetMetadataHeaders, - ShareSetQuotaHeaders, + ShareSetPropertiesHeaders, AccessPolicy, LeaseAccessConditions, LeaseDurationType, @@ -106,5 +106,18 @@ export { SmbMultichannel, FileGetRangeListResponse as FileGetRangeListDiffResponse, ShareFileRangeList, - ClearRange + ClearRange, + ShareAccessTier } from "./generated/src/models"; + +import { ShareSetPropertiesResponse, ShareSetPropertiesHeaders } from "./generated/src/models"; + +/** + * Contains response data for the setQuota operation. + */ +export type ShareSetQuotaResponse = ShareSetPropertiesResponse; + +/** + * Defines headers for setQuota operation. + */ +export type ShareSetQuotaHeaders = ShareSetPropertiesHeaders; diff --git a/sdk/storage/storage-file-share/test/shareclient.spec.ts b/sdk/storage/storage-file-share/test/shareclient.spec.ts index f2ca19df128c..09b188256e29 100644 --- a/sdk/storage/storage-file-share/test/shareclient.spec.ts +++ b/sdk/storage/storage-file-share/test/shareclient.spec.ts @@ -229,6 +229,31 @@ describe("ShareClient", () => { assert.ok(createPermResp.requestId!); assert.ok(createPermResp.version!); }); + + it("create share specifying accessTier and listShare", async () => { + const newShareName = recorder.getUniqueName("newshare"); + const newShareClient = serviceClient.getShareClient(newShareName); + await newShareClient.create({ accessTier: "Hot" }); + + for await (const shareItem of serviceClient.listShares({ prefix: newShareName })) { + if (shareItem.name === newShareName) { + assert.deepStrictEqual(shareItem.properties.accessTier, "Hot"); + assert.ok(shareItem.properties.accessTierChangeTime); + break; + } + } + + await newShareClient.delete(); + }); + + it("setAccessTier", async () => { + await shareClient.setAccessTier("Hot"); + const getRes = await shareClient.getProperties(); + + assert.deepStrictEqual(getRes.accessTier, "Hot"); + assert.ok(getRes.accessTierChangeTime); + assert.deepStrictEqual(getRes.accessTierTransitionState, "pending-from-transactionOptimized"); + }); }); describe("ShareDirectoryClient - Verify Name Properties", () => { From 5c77f093007769d1e7ae44ea3121eabe8cf6fd7a Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Fri, 9 Oct 2020 17:43:14 +0800 Subject: [PATCH 4/4] edit import --- sdk/storage/storage-file-share/src/Clients.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/storage/storage-file-share/src/Clients.ts b/sdk/storage/storage-file-share/src/Clients.ts index 19303d7cad40..acd06bd6c049 100644 --- a/sdk/storage/storage-file-share/src/Clients.ts +++ b/sdk/storage/storage-file-share/src/Clients.ts @@ -47,7 +47,9 @@ import { ShareSetMetadataResponse, ShareSetQuotaResponse, SignedIdentifierModel, - SourceModifiedAccessConditions + SourceModifiedAccessConditions, + ShareAccessTier, + ShareSetPropertiesResponse } from "./generatedModels"; import { Share, Directory, File } from "./generated/src/operations"; import { newPipeline, StoragePipelineOptions, Pipeline } from "./Pipeline"; @@ -99,7 +101,6 @@ import { import { StorageClientContext } from "./generated/src/storageClientContext"; import { SERVICE_VERSION } from "./utils/constants"; import { generateUuid } from "@azure/core-http"; -import { ShareAccessTier, ShareSetPropertiesResponse } from "./generated/src/models"; /** * Options to configure the {@link ShareClient.create} operation.