Added support for get account properties
This commit is contained in:
Родитель
4fc745b1ac
Коммит
34ef0393e6
|
@ -5,6 +5,7 @@ be taken. This is a GA release and the changes described below indicate the chan
|
|||
|
||||
BLOB
|
||||
* Fixed a bug that `DeleteRetentionPolicy.Days` should be `number` instead of `string` when calling `getServiceProperties`.
|
||||
* Added method `getAccountProperties` on `blobService`.
|
||||
|
||||
2018.05 Version 2.9.0-preview
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@ Note: This is the change log file for Azure Storage JavaScript Client Library.
|
|||
|
||||
2018.05 Version 2.9.100-preview
|
||||
|
||||
BLOB
|
||||
* Added method `getAccountProperties` on `blobService`.
|
||||
|
||||
ALL
|
||||
* Generated browser compatible JavaScript files based on Microsoft Azure Storage SDK for Node.js 2.9.0-preview.
|
||||
* Updated storage service version to 2017-11-09.
|
||||
|
@ -18,7 +21,7 @@ BLOB
|
|||
QUEUE
|
||||
* Added `createQueueServiceWithTokenCredential()` to create `QueueService` object with bearer tokens such as OAuth access token (in preview).
|
||||
|
||||
2018.04 Version 2.8.100+2.8.2
|
||||
2018.04 Version 2.8.100
|
||||
|
||||
* Fixed a bug that retry policy will not retry for XHR error in browsers.
|
||||
* Updated README.md under browser folder to make it more clear about the zip file downloading link.
|
||||
|
|
|
@ -314,6 +314,13 @@ exports.generateAccountSharedAccessSignature = function(storageAccountOrConnecti
|
|||
* @property {CorsRule[]} Cors.CorsRules Groups settings for a `[CORS rule]{@link CorsRule}`.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The properties of a storage account.
|
||||
* @typedef {object} AccountProperties
|
||||
* @property {string} SkuName The header that specifies storage SKU, also known as account type.
|
||||
* @property {string} AccountKind The header that describes the flavour of the storage account, also known as account kind.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Azure Analytics logging settings.
|
||||
* @typedef {object} LoggingProperties
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Module dependencies.
|
||||
var Constants = require('../util/constants');
|
||||
var HeaderConstants = Constants.HeaderConstants;
|
||||
|
||||
exports.parse = function (headers) {
|
||||
var accountPropertiesResult = {};
|
||||
|
||||
if (headers[HeaderConstants.SKU_NAME]) {
|
||||
accountPropertiesResult.SkuName = headers[HeaderConstants.SKU_NAME];
|
||||
}
|
||||
|
||||
if (headers[HeaderConstants.ACCOUNT_KIND]) {
|
||||
accountPropertiesResult.AccountKind = headers[HeaderConstants.ACCOUNT_KIND];
|
||||
}
|
||||
|
||||
return accountPropertiesResult;
|
||||
};
|
|
@ -37,7 +37,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
USER_AGENT_PRODUCT_VERSION: '2.9.0-preview',
|
||||
USER_AGENT_PRODUCT_VERSION: '2.10.0',
|
||||
|
||||
/**
|
||||
* The number of default concurrent requests for parallel operation.
|
||||
|
@ -1426,6 +1426,21 @@ var Constants = {
|
|||
*/
|
||||
JSON_CONTENT_TYPE_VALUE: 'application/json;',
|
||||
|
||||
/**
|
||||
* The header that specifies storage SKU, also known as account type.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
SKU_NAME: 'x-ms-sku-name',
|
||||
|
||||
/**
|
||||
* The header that describes the flavour of the storage account, also known as account kind.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ACCOUNT_KIND: 'x-ms-account-kind',
|
||||
|
||||
/**
|
||||
* The header that specifies lease ID.
|
||||
|
@ -1705,7 +1720,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
TARGET_STORAGE_VERSION: '2017-11-09',
|
||||
TARGET_STORAGE_VERSION: '2018-03-28',
|
||||
|
||||
/**
|
||||
* The UserAgent header.
|
||||
|
|
|
@ -49,6 +49,7 @@ var ChunkStreamWithStream = azureCommon.ChunkStreamWithStream;
|
|||
// Models requires
|
||||
var AclResult = azureCommon.AclResult;
|
||||
var ServiceStatsParser = azureCommon.ServiceStatsParser;
|
||||
var AccountPropertiesResult = require('../../common/models/accountpropertiesresult');
|
||||
var BlockListResult = require('./models/blocklistresult');
|
||||
var BlobResult = require('./models/blobresult');
|
||||
var ContainerResult = require('./models/containerresult');
|
||||
|
@ -216,6 +217,60 @@ BlobService.prototype.getServiceProperties = function (optionsOrCallback, callba
|
|||
return this.getAccountServiceProperties(optionsOrCallback, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the properties of a storage account.
|
||||
*
|
||||
* @this {BlobService}
|
||||
* @param {string} [container] Optional. Name of an existing container. Required when using a SAS token to a specific container or blob.
|
||||
* @param {string} [blob] Optional. Name of an existing blob. Required when using a SAS token to a specific blob.
|
||||
* @param {object} [options] The request options.
|
||||
* @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to.
|
||||
* Please see StorageUtilities.LocationMode for the possible values.
|
||||
* @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request.
|
||||
* @param {int} [options.clientRequestTimeoutInMs] The timeout of client requests, in milliseconds, to use for the request.
|
||||
* @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request.
|
||||
* The maximum execution time interval begins at the time that the client begins building the request. The maximum
|
||||
* execution time is checked intermittently while performing requests, and before executing retries.
|
||||
* @param {string} [options.clientRequestId] A string that represents the client request ID with a 1KB character limit.
|
||||
* @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false.
|
||||
* The default value is false.
|
||||
* @param {errorOrResult} callback `error` will contain information if an error occurs; otherwise, `[result]{@link ServiceProperties}` will contain the properties
|
||||
* and `response` will contain information related to this operation.
|
||||
*/
|
||||
BlobService.prototype.getAccountProperties = function (container, blob, optionsOrCallback, callback) {
|
||||
var userOptions;
|
||||
azureutil.normalizeArgs(optionsOrCallback, callback, function (o, c) { userOptions = o; callback = c; });
|
||||
|
||||
validate.validateArgs('getAccountProperties', function (v) {
|
||||
v.callback(callback);
|
||||
});
|
||||
|
||||
var options = extend(true, {}, userOptions);
|
||||
|
||||
var webResource = WebResource.head(createResourceName(container, blob))
|
||||
.withQueryOption(QueryStringConstants.COMP, 'properties')
|
||||
.withQueryOption(QueryStringConstants.RESTYPE, 'account');
|
||||
|
||||
options.requestLocationMode = RequestLocationMode.PRIMARY_OR_SECONDARY;
|
||||
|
||||
var processResponseCallback = function (responseObject, next) {
|
||||
responseObject.accountPropertiesResult = null;
|
||||
if (!responseObject.error) {
|
||||
responseObject.accountPropertiesResult = AccountPropertiesResult.parse(responseObject.response.headers);
|
||||
}
|
||||
|
||||
// function to be called after all filters
|
||||
var finalCallback = function (returnObject) {
|
||||
callback(returnObject.error, returnObject.accountPropertiesResult, returnObject.response);
|
||||
};
|
||||
|
||||
// call the first filter
|
||||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the properties of a storage account's Blob service, including Azure Storage Analytics.
|
||||
* You can also use this operation to set the default request version for all incoming requests that do not have a version specified.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "azure-storage",
|
||||
"author": "Microsoft Corporation",
|
||||
"version": "2.9.0-preview",
|
||||
"version": "2.10.0",
|
||||
"description": "Microsoft Azure Storage Client Library for Node.js",
|
||||
"typings": "typings/azure-storage/azure-storage.d.ts",
|
||||
"tags": [
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1531,7 +1531,7 @@ describe('BlobService', function () {
|
|||
assert.strictEqual(parsedUrl.port, '80');
|
||||
assert.strictEqual(parsedUrl.hostname, 'host.com');
|
||||
assert.strictEqual(parsedUrl.pathname, '/' + containerName + '/' + blobName);
|
||||
assert.strictEqual(parsedUrl.query, 'se=2011-10-12T11%3A53%3A40Z&spr=https&sv=2017-11-09&sr=b&sig=Q9TPDPb4L1Xga4FwRd1XzRqdjZPQP0dDtUD29jryY64%3D');
|
||||
assert.strictEqual(parsedUrl.query, 'se=2011-10-12T11%3A53%3A40Z&spr=https&sv=2018-03-28&sr=b&sig=j6Ubb%2Flpyt9cd55dlfwoEGOog9a%2FyDYWhB8UscVCTo4%3D');
|
||||
|
||||
blobUrl = blobServiceassert.getUrl(containerName, blobName, sasToken, false, '2016-10-11T11:03:40Z');
|
||||
|
||||
|
@ -1540,7 +1540,7 @@ describe('BlobService', function () {
|
|||
assert.strictEqual(parsedUrl.port, '80');
|
||||
assert.strictEqual(parsedUrl.hostname, 'host-secondary.com');
|
||||
assert.strictEqual(parsedUrl.pathname, '/' + containerName + '/' + blobName);
|
||||
assert.strictEqual(parsedUrl.query, 'se=2011-10-12T11%3A53%3A40Z&spr=https&sv=2017-11-09&sr=b&sig=Q9TPDPb4L1Xga4FwRd1XzRqdjZPQP0dDtUD29jryY64%3D&snapshot=2016-10-11T11%3A03%3A40Z');
|
||||
assert.strictEqual(parsedUrl.query, 'se=2011-10-12T11%3A53%3A40Z&spr=https&sv=2018-03-28&sr=b&sig=j6Ubb%2Flpyt9cd55dlfwoEGOog9a%2FyDYWhB8UscVCTo4%3D&snapshot=2016-10-11T11%3A03%3A40Z');
|
||||
|
||||
done();
|
||||
});
|
||||
|
@ -1621,7 +1621,7 @@ describe('BlobService', function () {
|
|||
assert.equal(sasQueryString[QueryStringConstants.SIGNED_PERMISSIONS], BlobUtilities.SharedAccessPermissions.READ);
|
||||
assert.equal(sasQueryString[QueryStringConstants.SIGNED_PROTOCOL], 'https');
|
||||
assert.equal(sasQueryString[QueryStringConstants.SIGNED_VERSION], HeaderConstants.TARGET_STORAGE_VERSION);
|
||||
assert.equal(sasQueryString[QueryStringConstants.SIGNATURE], '/BJO5Zfw6k19Abg8YanZuJgx/IuO2ZJmRnb1xX28oGA=');
|
||||
assert.equal(sasQueryString[QueryStringConstants.SIGNATURE], '8rgGI044z+1BGRrVKaxO+u5y/pqjBSPVqC3QDEJvTUA=');
|
||||
|
||||
done();
|
||||
});
|
||||
|
@ -2086,6 +2086,80 @@ describe('BlobService', function () {
|
|||
|
||||
done();
|
||||
});
|
||||
|
||||
describe('getAccountProperties', function () {
|
||||
it('should work without container and blob names', function (done) {
|
||||
blobService.getAccountProperties(null, null, function (err, res) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(typeof res.SkuName, 'string');
|
||||
assert.equal(typeof res.AccountKind, 'string');
|
||||
assert.equal(true, res.SkuName.length > 0);
|
||||
assert.equal(true, res.AccountKind.length > 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
skipMockAndBrowser('should work with container name', function (done) {
|
||||
var containerName = testutil.generateId(containerNamesPrefix, containerNames, suite.isMocked);
|
||||
|
||||
var sharedAccessPolicy = {
|
||||
AccessPolicy: {
|
||||
Permissions: BlobUtilities.SharedAccessPermissions.READ,
|
||||
Expiry: new Date('October 12, 2020 11:53:40 am GMT'),
|
||||
}
|
||||
};
|
||||
|
||||
var sharedAccessSignature = blobService.generateSharedAccessSignature(containerName, null, sharedAccessPolicy);
|
||||
var blobServiceWithSAS = azure.createBlobServiceWithSas(blobService.host.primaryHost, sharedAccessSignature);
|
||||
|
||||
blobService.createContainerIfNotExists(containerName, function (err) {
|
||||
assert.equal(err, null);
|
||||
|
||||
blobServiceWithSAS.getAccountProperties(containerName, null, function (err, res) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(typeof res.SkuName, 'string');
|
||||
assert.equal(typeof res.AccountKind, 'string');
|
||||
assert.equal(true, res.SkuName.length > 0);
|
||||
assert.equal(true, res.AccountKind.length > 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
skipMockAndBrowser('should work with container and blob names', function (done) {
|
||||
var containerName = testutil.generateId(containerNamesPrefix, containerNames, suite.isMocked);
|
||||
var blobName = testutil.generateId(blobNamesPrefix, blobNames, suite.isMocked);
|
||||
|
||||
var sharedAccessPolicy = {
|
||||
AccessPolicy: {
|
||||
Permissions: BlobUtilities.SharedAccessPermissions.READ,
|
||||
Expiry: new Date('October 12, 2020 11:53:40 am GMT'),
|
||||
}
|
||||
};
|
||||
|
||||
var sharedAccessSignature = blobService.generateSharedAccessSignature(containerName, blobName, sharedAccessPolicy);
|
||||
var blobServiceWithSAS = azure.createBlobServiceWithSas(blobService.host.primaryHost, sharedAccessSignature);
|
||||
|
||||
blobService.createContainerIfNotExists(containerName, function (err) {
|
||||
assert.equal(err, null);
|
||||
var blobText = 'Hello World';
|
||||
|
||||
blobService.createBlockBlobFromText(containerName, blobName, blobText, function (uploadError, blob, uploadResponse) {
|
||||
assert.equal(uploadError, null);
|
||||
assert.ok(uploadResponse.isSuccessful);
|
||||
|
||||
blobServiceWithSAS.getAccountProperties(containerName, blobName, function (err, res) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(typeof res.SkuName, 'string');
|
||||
assert.equal(typeof res.AccountKind, 'string');
|
||||
assert.equal(true, res.SkuName.length > 0);
|
||||
assert.equal(true, res.AccountKind.length > 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function repeat (s, n) {
|
||||
|
|
|
@ -161,6 +161,30 @@ declare module azurestorage {
|
|||
*/
|
||||
getServiceProperties(options: common.RequestOptions, callback?: ErrorOrResult<common.models.ServicePropertiesResult.ServiceProperties>): void;
|
||||
getServiceProperties(callback?: ErrorOrResult<common.models.ServicePropertiesResult.ServiceProperties>): void;
|
||||
|
||||
/**
|
||||
* Gets the properties of a storage account.
|
||||
*
|
||||
* @this {BlobService}
|
||||
* @param {string} [container] Optional. Name of an existing container. Required when using a SAS token to a specific container or blob.
|
||||
* @param {string} [blob] Optional. Name of an existing blob. Required when using a SAS token to a specific blob.
|
||||
* @param {Object} [options] The request options.
|
||||
* @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to.
|
||||
* Please see StorageUtilities.LocationMode for the possible values.
|
||||
* @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request.
|
||||
* @param {int} [options.clientRequestTimeoutInMs] The timeout of client requests, in milliseconds, to use for the request.
|
||||
* @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request.
|
||||
* The maximum execution time interval begins at the time that the client begins building the request. The maximum
|
||||
* execution time is checked intermittently while performing requests, and before executing retries.
|
||||
* @param {string} [options.clientRequestId] A string that represents the client request ID with a 1KB character limit.
|
||||
* @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false.
|
||||
* The default value is false.
|
||||
* @param {errorOrResult} callback `error` will contain information if an error occurs; otherwise, `[result]{@link AccountProperties}` will contain the properties
|
||||
* and `response` will contain information related to this operation.
|
||||
*/
|
||||
getAccountProperties(container?:string, blob?:string, options?: common.RequestOptions, callback?: ErrorOrResult<common.models.AccountProperties>): void;
|
||||
getAccountProperties(container?:string, blob?:string, callback?: ErrorOrResult<common.models.AccountProperties>): void;
|
||||
|
||||
/**
|
||||
* Sets the properties of a storage account’s Blob service, including Azure Storage Analytics.
|
||||
* You can also use this operation to set the default request version for all incoming requests that do not have a version specified.
|
||||
|
@ -9045,6 +9069,11 @@ declare module azurestorage {
|
|||
};
|
||||
}
|
||||
|
||||
export interface AccountProperties {
|
||||
SkuName: string;
|
||||
AccountKind: string;
|
||||
}
|
||||
|
||||
module ServicePropertiesResult {
|
||||
export interface RetentionPolicy {
|
||||
Enabled: boolean;
|
||||
|
|
Загрузка…
Ссылка в новой задаче