[storage-file-share] Migrate to core-rest-pipeline (#26102)
### Packages impacted by this PR `@azure/storage-file-share` ### Issues associated with this PR #15813 ### Describe the problem that is addressed by this PR This PR migrates storage-file-share to the new core pipeline in the same way that storage-blob and storage-file-datalake were migrated. There are no changes to the public surface and existing recorded tests still pass. ### Provide a list of related PRs _(if any)_ #24141, #24835
This commit is contained in:
Родитель
ef3d6277f5
Коммит
e7f9ea36b9
|
@ -2245,7 +2245,7 @@ packages:
|
|||
resolution: {integrity: sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==}
|
||||
dependencies:
|
||||
'@types/connect': 3.4.35
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/chai-as-promised/7.1.5:
|
||||
|
@ -2267,7 +2267,7 @@ packages:
|
|||
/@types/connect/3.4.35:
|
||||
resolution: {integrity: sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/cookie/0.4.1:
|
||||
|
@ -2277,7 +2277,7 @@ packages:
|
|||
/@types/cors/2.8.13:
|
||||
resolution: {integrity: sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/debug/4.1.8:
|
||||
|
@ -2289,7 +2289,7 @@ packages:
|
|||
/@types/decompress/4.2.4:
|
||||
resolution: {integrity: sha512-/C8kTMRTNiNuWGl5nEyKbPiMv6HA+0RbEXzFhFBEzASM6+oa4tJro9b8nj7eRlOFfuLdzUU+DS/GPDlvvzMOhA==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/eslint/8.4.10:
|
||||
|
@ -2310,7 +2310,7 @@ packages:
|
|||
/@types/express-serve-static-core/4.17.35:
|
||||
resolution: {integrity: sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
'@types/qs': 6.9.7
|
||||
'@types/range-parser': 1.2.4
|
||||
'@types/send': 0.17.1
|
||||
|
@ -2328,13 +2328,13 @@ packages:
|
|||
/@types/fs-extra/8.1.2:
|
||||
resolution: {integrity: sha512-SvSrYXfWSc7R4eqnOzbQF4TZmfpNSM9FrSWLU3EUnWBuyZqNBOrv1B1JA3byUDPUl9z4Ab3jeZG2eDdySlgNMg==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/fs-extra/9.0.13:
|
||||
resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/inquirer/8.2.6:
|
||||
|
@ -2347,7 +2347,7 @@ packages:
|
|||
/@types/is-buffer/2.0.0:
|
||||
resolution: {integrity: sha512-0f7N/e3BAz32qDYvgB4d2cqv1DqUwvGxHkXsrucICn8la1Vb6Yl6Eg8mPScGwUiqHJeE7diXlzaK+QMA9m4Gxw==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/json-schema/7.0.12:
|
||||
|
@ -2361,13 +2361,13 @@ packages:
|
|||
/@types/jsonwebtoken/9.0.2:
|
||||
resolution: {integrity: sha512-drE6uz7QBKq1fYqqoFKTDRdFCPHd5TCub75BM+D+cMx7NU9hUz7SESLfC2fSCXVFMO5Yj8sOWHuGqPgjc+fz0Q==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/jws/3.2.5:
|
||||
resolution: {integrity: sha512-xGTxZH34xOryaTN8CMsvhh9lfNqFuHiMoRvsLYWQdBJHqiECyfInXVl2eK8Jz2emxZWMIn5RBlmr3oDVPeWujw==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/linkify-it/3.0.2:
|
||||
|
@ -2418,13 +2418,13 @@ packages:
|
|||
/@types/mysql/2.15.19:
|
||||
resolution: {integrity: sha512-wSRg2QZv14CWcZXkgdvHbbV2ACufNy5EgI8mBBxnJIptchv7DBy/h53VMa2jDhyo0C9MO4iowE6z9vF8Ja1DkQ==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/node-fetch/2.6.4:
|
||||
resolution: {integrity: sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
form-data: 3.0.1
|
||||
dev: false
|
||||
|
||||
|
@ -2449,7 +2449,7 @@ packages:
|
|||
/@types/pg/8.6.1:
|
||||
resolution: {integrity: sha512-1Kc4oAGzAl7uqUStZCDvaLFqZrW9qWSjXOmBfdgyBP5La7Us6Mg4GBvRlSoaZMhQF/zSj1C8CtKMBkoiT8eL8w==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
pg-protocol: 1.6.0
|
||||
pg-types: 2.2.0
|
||||
dev: false
|
||||
|
@ -2477,7 +2477,7 @@ packages:
|
|||
/@types/resolve/1.17.1:
|
||||
resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/semaphore/1.1.1:
|
||||
|
@ -2496,14 +2496,14 @@ packages:
|
|||
resolution: {integrity: sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==}
|
||||
dependencies:
|
||||
'@types/mime': 1.3.2
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/serve-static/1.15.1:
|
||||
resolution: {integrity: sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==}
|
||||
dependencies:
|
||||
'@types/mime': 3.0.1
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/sinon/10.0.15:
|
||||
|
@ -2525,13 +2525,13 @@ packages:
|
|||
/@types/stoppable/1.1.1:
|
||||
resolution: {integrity: sha512-b8N+fCADRIYYrGZOcmOR8ZNBOqhktWTB/bMUl5LvGtT201QKJZOOH5UsFyI3qtteM6ZAJbJqZoBcLqqxKIwjhw==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/through/0.0.30:
|
||||
resolution: {integrity: sha512-FvnCJljyxhPM3gkRgWmxmDZyAQSiBQQWLI0A0VFL0K7W1oRUrPJSqNO0NvTnLkBcotdlp3lKvaT0JrnyRDkzOg==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/tough-cookie/4.0.2:
|
||||
|
@ -2545,7 +2545,7 @@ packages:
|
|||
/@types/tunnel/0.0.3:
|
||||
resolution: {integrity: sha512-sOUTGn6h1SfQ+gbgqC364jLFBw2lnFqkgF3q0WovEHRLMrVD1sd5aufqi/aJObLekJO+Aq5z646U4Oxy6shXMA==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/underscore/1.11.5:
|
||||
|
@ -2563,19 +2563,19 @@ packages:
|
|||
/@types/ws/7.4.7:
|
||||
resolution: {integrity: sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/ws/8.5.4:
|
||||
resolution: {integrity: sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/xml2js/0.4.11:
|
||||
resolution: {integrity: sha512-JdigeAKmCyoJUiQljjr7tQG3if9NkqGUgwEUqBvV0N7LM4HyQk7UXCnusRa1lnvXAEYJ8mw8GtZWioagNztOwA==}
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
|
||||
/@types/yargs-parser/21.0.0:
|
||||
|
@ -2592,7 +2592,7 @@ packages:
|
|||
resolution: {integrity: sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw==}
|
||||
requiresBuild: true
|
||||
dependencies:
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
|
@ -3601,7 +3601,7 @@ packages:
|
|||
resolution: {integrity: sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==}
|
||||
deprecated: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
|
||||
dependencies:
|
||||
ms: 2.1.1
|
||||
ms: 2.1.3
|
||||
dev: false
|
||||
|
||||
/debug/3.2.7:
|
||||
|
@ -3883,7 +3883,7 @@ packages:
|
|||
dependencies:
|
||||
'@types/cookie': 0.4.1
|
||||
'@types/cors': 2.8.13
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
accepts: 1.3.8
|
||||
base64id: 2.0.0
|
||||
cookie: 0.4.2
|
||||
|
@ -4807,7 +4807,7 @@ packages:
|
|||
fs.realpath: 1.0.0
|
||||
inflight: 1.0.6
|
||||
inherits: 2.0.4
|
||||
minimatch: 3.0.4
|
||||
minimatch: 3.1.2
|
||||
once: 1.4.0
|
||||
path-is-absolute: 1.0.1
|
||||
dev: false
|
||||
|
@ -7115,7 +7115,7 @@ packages:
|
|||
'@protobufjs/path': 1.1.2
|
||||
'@protobufjs/pool': 1.1.0
|
||||
'@protobufjs/utf8': 1.1.0
|
||||
'@types/node': 14.18.48
|
||||
'@types/node': 16.18.34
|
||||
long: 5.2.3
|
||||
dev: false
|
||||
|
||||
|
@ -18026,7 +18026,7 @@ packages:
|
|||
dev: false
|
||||
|
||||
file:projects/monitor-query.tgz:
|
||||
resolution: {integrity: sha512-UTfrrypI9UvxkoW1o6zxcIzxJSxXeam5tEzF35ZFa+bJnIOgH45sUvzT2p4n/YA2/blGPYogtQPT81RcWiHgBg==, tarball: file:projects/monitor-query.tgz}
|
||||
resolution: {integrity: sha512-bE/JTLjfj8HMmBTGfK1pTs4Kfsy9GJwXtrvbOjgDH8pYIvzzJ3LjUNRGjVhb3r+FOPkBRbb9fxniy5U3mmmLng==, tarball: file:projects/monitor-query.tgz}
|
||||
name: '@rush-temp/monitor-query'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
|
@ -19316,7 +19316,7 @@ packages:
|
|||
dev: false
|
||||
|
||||
file:projects/storage-file-share.tgz:
|
||||
resolution: {integrity: sha512-5ie5/QK9klG91C+f7GkzlFX+KDKuwVgKyn52dzGylmLr4NCjh/b4OWguq/5kae9OC8qHn4+aJHg2J81P5M4QDA==, tarball: file:projects/storage-file-share.tgz}
|
||||
resolution: {integrity: sha512-Ta2DL1i32tq8YzBuBOpmsMPn5ZwaEkk4UK/PIovIBFkm19A6Pb/TcIsJWYe2IDV6bmz9S4jLLFdRex0krtigYw==, tarball: file:projects/storage-file-share.tgz}
|
||||
name: '@rush-temp/storage-file-share'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
|
@ -19326,6 +19326,8 @@ packages:
|
|||
'@types/chai': 4.3.5
|
||||
'@types/mocha': 7.0.2
|
||||
'@types/node': 14.18.48
|
||||
'@types/sinon': 9.0.11
|
||||
'@types/uuid': 8.3.4
|
||||
chai: 4.3.7
|
||||
cross-env: 7.0.3
|
||||
dotenv: 16.1.4
|
||||
|
@ -19352,11 +19354,13 @@ packages:
|
|||
prettier: 2.8.8
|
||||
puppeteer: 19.11.1_typescript@5.0.4
|
||||
rimraf: 3.0.2
|
||||
sinon: 9.2.4
|
||||
source-map-support: 0.5.21
|
||||
ts-node: 10.9.1_haicren4phfcx6dckkdidh3s3e
|
||||
tslib: 2.5.3
|
||||
typescript: 5.0.4
|
||||
util: 0.12.5
|
||||
uuid: 8.3.2
|
||||
transitivePeerDependencies:
|
||||
- '@swc/core'
|
||||
- '@swc/wasm'
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"plugins": ["@azure/azure-sdk"],
|
||||
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
|
||||
"rules": {
|
||||
"@azure/azure-sdk/ts-package-json-module": "warn"
|
||||
}
|
||||
}
|
|
@ -1,5 +1,17 @@
|
|||
# Release History
|
||||
|
||||
## 12.20.0 (Unreleased)
|
||||
|
||||
### Features Added
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
### Other Changes
|
||||
|
||||
- Migrated dependency on `@azure/core-http` to `@azure/core-rest-pipeline`.
|
||||
|
||||
## 12.13.0 (Unreleased)
|
||||
|
||||
### Features Added
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "types/latest/src/index.d.ts",
|
||||
"mainEntryPointFilePath": "types/latest/storage-file-share/src/index.d.ts",
|
||||
"docModel": {
|
||||
"enabled": true
|
||||
},
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
{
|
||||
"name": "@azure/storage-file-share",
|
||||
"sdk-type": "client",
|
||||
"version": "12.13.0",
|
||||
"version": "12.20.0",
|
||||
"description": "Microsoft Azure Storage SDK for JavaScript - File",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist-esm/src/index.js",
|
||||
"module": "./dist-esm/storage-file-share/src/index.js",
|
||||
"browser": {
|
||||
"./dist-esm/src/index.js": "./dist-esm/src/index.browser.js",
|
||||
"./dist-esm/src/credentials/StorageSharedKeyCredential.js": "./dist-esm/src/credentials/StorageSharedKeyCredential.browser.js",
|
||||
"./dist-esm/src/utils/utils.node.js": "./dist-esm/src/utils/utils.browser.js",
|
||||
"./dist-esm/test/utils/index.js": "./dist-esm/test/utils/index.browser.js",
|
||||
"./dist-esm/src/FileDownloadResponse.js": "./dist-esm/src/FileDownloadResponse.browser.js",
|
||||
"./dist-esm/storage-file-share/src/index.js": "./dist-esm/storage-file-share/src/index.browser.js",
|
||||
"./dist-esm/storage-blob/src/credentials/StorageSharedKeyCredential.js": "./dist-esm/storage-blob/src/credentials/StorageSharedKeyCredential.browser.js",
|
||||
"./dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.js": "./dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.browser.js",
|
||||
"./dist-esm/storage-file-share/src/utils/utils.node.js": "./dist-esm/storage-file-share/src/utils/utils.browser.js",
|
||||
"./dist-esm/storage-file-share/test/utils/index.js": "./dist-esm/storage-file-share/test/utils/index.browser.js",
|
||||
"./dist-esm/storage-file-share/src/FileDownloadResponse.js": "./dist-esm/storage-file-share/src/FileDownloadResponse.browser.js",
|
||||
"fs": false,
|
||||
"os": false,
|
||||
"process": false
|
||||
},
|
||||
"react-native": {
|
||||
"./dist/index.js": "./dist-esm/src/index.js"
|
||||
"./dist/index.js": "./dist-esm/storage-file-share/src/index.js"
|
||||
},
|
||||
"types": "./types/latest/storage-file-share.d.ts",
|
||||
"typesVersions": {
|
||||
|
@ -47,7 +48,7 @@
|
|||
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
||||
"generate:client": "autorest --typescript ./swagger/README.md",
|
||||
"integration-test:browser": "karma start --single-run",
|
||||
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 \"dist-esm/test/*.spec.js\" \"dist-esm/test/node/*.spec.js\"",
|
||||
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 \"dist-esm/storage-file-share/test/*.spec.js\" \"dist-esm/storage-file-share/test/node/*.spec.js\"",
|
||||
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
||||
"lint:fix": "eslint package.json api-extractor.json README.md src test --ext .ts,.javascript,.js --fix",
|
||||
"lint": "eslint package.json api-extractor.json README.md src test --ext .ts,.javascript,.js",
|
||||
|
@ -60,10 +61,9 @@
|
|||
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
||||
},
|
||||
"files": [
|
||||
"BreakingChanges.md",
|
||||
"ThirdPartyNotices.txt",
|
||||
"dist/",
|
||||
"dist-esm/src/",
|
||||
"dist-esm/storage-blob/src/",
|
||||
"dist-esm/storage-file-share/src",
|
||||
"types/latest/storage-file-share.d.ts",
|
||||
"types/3.1/storage-file-share.d.ts",
|
||||
"README.md",
|
||||
|
@ -124,15 +124,21 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"@azure/core-http": "^3.0.0",
|
||||
"@azure/core-auth": "^1.4.0",
|
||||
"@azure/core-client": "^1.6.2",
|
||||
"@azure/core-http-compat": "^2.0.0",
|
||||
"@azure/core-paging": "^1.1.1",
|
||||
"@azure/core-rest-pipeline": "^1.10.1",
|
||||
"@azure/core-tracing": "1.0.0-preview.13",
|
||||
"@azure/core-util": "^1.1.1",
|
||||
"@azure/core-xml": "^1.3.2",
|
||||
"@azure/logger": "^1.0.0",
|
||||
"events": "^3.0.0",
|
||||
"tslib": "^2.2.0"
|
||||
"tslib": "^2.2.0",
|
||||
"uuid": "^8.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@azure/storage-blob": "^12.12.0",
|
||||
"@azure/storage-blob": "^12.20.0",
|
||||
"@azure/dev-tool": "^1.0.0",
|
||||
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
||||
"@azure/test-utils": "^1.0.0",
|
||||
|
@ -142,6 +148,8 @@
|
|||
"@types/chai": "^4.1.6",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/node": "^14.0.0",
|
||||
"@types/sinon": "^9.0.4",
|
||||
"@types/uuid": "^8.0.0",
|
||||
"chai": "^4.2.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"dotenv": "^16.0.0",
|
||||
|
@ -167,6 +175,7 @@
|
|||
"prettier": "^2.5.1",
|
||||
"puppeteer": "^19.2.2",
|
||||
"rimraf": "^3.0.0",
|
||||
"sinon": "^9.0.2",
|
||||
"source-map-support": "^0.5.9",
|
||||
"ts-node": "^10.0.0",
|
||||
"typescript": "~5.0.0",
|
||||
|
|
|
@ -8,27 +8,26 @@
|
|||
|
||||
import { AbortSignalLike } from '@azure/abort-controller';
|
||||
import { AzureLogger } from '@azure/logger';
|
||||
import { BaseRequestPolicy } from '@azure/core-http';
|
||||
import * as coreHttp from '@azure/core-http';
|
||||
import { deserializationPolicy } from '@azure/core-http';
|
||||
import { HttpHeaders } from '@azure/core-http';
|
||||
import { HttpOperationResponse } from '@azure/core-http';
|
||||
import { HttpRequestBody } from '@azure/core-http';
|
||||
import { HttpResponse } from '@azure/core-http';
|
||||
import { HttpClient as IHttpClient } from '@azure/core-http';
|
||||
import { KeepAliveOptions } from '@azure/core-http';
|
||||
import { CompatResponse } from '@azure/core-http-compat';
|
||||
import * as coreClient from '@azure/core-client';
|
||||
import * as coreHttpCompat from '@azure/core-http-compat';
|
||||
import * as coreRestPipeline from '@azure/core-rest-pipeline';
|
||||
import { HttpHeadersLike } from '@azure/core-http-compat';
|
||||
import { HttpPipelineLogLevel } from '@azure/core-http-compat';
|
||||
import { KeepAliveOptions } from '@azure/core-http-compat';
|
||||
import { OperationTracingOptions } from '@azure/core-tracing';
|
||||
import { PagedAsyncIterableIterator } from '@azure/core-paging';
|
||||
import { ProxyOptions } from '@azure/core-http';
|
||||
import { ProxySettings } from '@azure/core-rest-pipeline';
|
||||
import { Readable } from 'stream';
|
||||
import { RequestPolicy } from '@azure/core-http';
|
||||
import { RequestPolicyFactory } from '@azure/core-http';
|
||||
import { RequestPolicyOptions } from '@azure/core-http';
|
||||
import { RestError } from '@azure/core-http';
|
||||
import { ServiceClientOptions } from '@azure/core-http';
|
||||
import { TransferProgressEvent } from '@azure/core-http';
|
||||
import { UserAgentOptions } from '@azure/core-http';
|
||||
import { WebResource } from '@azure/core-http';
|
||||
import { RequestBodyType } from '@azure/core-rest-pipeline';
|
||||
import { RequestPolicy } from '@azure/core-http-compat';
|
||||
import { RequestPolicyFactory } from '@azure/core-http-compat';
|
||||
import { RequestPolicyOptionsLike } from '@azure/core-http-compat';
|
||||
import { RestError } from '@azure/core-rest-pipeline';
|
||||
import { TokenCredential } from '@azure/core-auth';
|
||||
import { TransferProgressEvent } from '@azure/core-rest-pipeline';
|
||||
import { UserAgentPolicyOptions } from '@azure/core-rest-pipeline';
|
||||
import { WebResourceLike } from '@azure/core-http-compat';
|
||||
|
||||
// @public
|
||||
export interface AccessPolicy {
|
||||
|
@ -84,15 +83,25 @@ export interface AccountSASSignatureValues {
|
|||
|
||||
// @public
|
||||
export class AnonymousCredential extends Credential_2 {
|
||||
create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): AnonymousCredentialPolicy;
|
||||
create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): AnonymousCredentialPolicy;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class AnonymousCredentialPolicy extends CredentialPolicy {
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions);
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike);
|
||||
}
|
||||
|
||||
export { BaseRequestPolicy }
|
||||
// @public
|
||||
export abstract class BaseRequestPolicy implements RequestPolicy {
|
||||
protected constructor(
|
||||
_nextPolicy: RequestPolicy,
|
||||
_options: RequestPolicyOptionsLike);
|
||||
log(logLevel: HttpPipelineLogLevel, message: string): void;
|
||||
readonly _nextPolicy: RequestPolicy;
|
||||
readonly _options: RequestPolicyOptionsLike;
|
||||
abstract sendRequest(webResource: WebResourceLike): Promise<CompatResponse>;
|
||||
shouldLog(logLevel: HttpPipelineLogLevel): boolean;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ClearRange {
|
||||
|
@ -155,24 +164,22 @@ export interface CorsRule {
|
|||
|
||||
// @public
|
||||
abstract class Credential_2 implements RequestPolicyFactory {
|
||||
create(_nextPolicy: RequestPolicy, _options: RequestPolicyOptions): RequestPolicy;
|
||||
create(_nextPolicy: RequestPolicy, _options: RequestPolicyOptionsLike): RequestPolicy;
|
||||
}
|
||||
export { Credential_2 as Credential }
|
||||
|
||||
// @public
|
||||
export abstract class CredentialPolicy extends BaseRequestPolicy {
|
||||
sendRequest(request: WebResource): Promise<HttpOperationResponse>;
|
||||
protected signRequest(request: WebResource): WebResource;
|
||||
sendRequest(request: WebResourceLike): Promise<CompatResponse>;
|
||||
protected signRequest(request: WebResourceLike): WebResourceLike;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type CredentialPolicyCreator = (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => CredentialPolicy;
|
||||
export type CredentialPolicyCreator = (nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike) => CredentialPolicy;
|
||||
|
||||
// @public
|
||||
export type DeleteSnapshotsOptionType = "include" | "include-leased";
|
||||
|
||||
export { deserializationPolicy }
|
||||
|
||||
// @public
|
||||
export interface DirectoryCloseHandlesHeaders {
|
||||
date?: Date;
|
||||
|
@ -211,11 +218,7 @@ export interface DirectoryCreateOptions extends FileAndDirectoryCreateCommonOpti
|
|||
}
|
||||
|
||||
// @public
|
||||
export type DirectoryCreateResponse = DirectoryCreateHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: DirectoryCreateHeaders;
|
||||
};
|
||||
};
|
||||
export type DirectoryCreateResponse = WithResponse<DirectoryCreateHeaders, DirectoryCreateHeaders>;
|
||||
|
||||
// @public
|
||||
export interface DirectoryDeleteHeaders {
|
||||
|
@ -236,11 +239,7 @@ export interface DirectoryDeleteOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type DirectoryDeleteResponse = DirectoryDeleteHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: DirectoryDeleteHeaders;
|
||||
};
|
||||
};
|
||||
export type DirectoryDeleteResponse = WithResponse<DirectoryDeleteHeaders, DirectoryDeleteHeaders>;
|
||||
|
||||
// @public
|
||||
export interface DirectoryExistsOptions extends CommonOptions {
|
||||
|
@ -264,11 +263,7 @@ export interface DirectoryForceCloseHandlesOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type DirectoryForceCloseHandlesResponse = CloseHandlesInfo & DirectoryCloseHandlesHeaders & {
|
||||
_response: HttpResponse & {
|
||||
parsedHeaders: DirectoryForceCloseHandlesHeaders;
|
||||
};
|
||||
};
|
||||
export type DirectoryForceCloseHandlesResponse = WithResponse<CloseHandlesInfo & DirectoryCloseHandlesHeaders, DirectoryForceCloseHandlesHeaders>;
|
||||
|
||||
// @public
|
||||
export interface DirectoryForceCloseHandlesSegmentOptions extends CommonOptions {
|
||||
|
@ -303,11 +298,7 @@ export interface DirectoryGetPropertiesOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type DirectoryGetPropertiesResponse = DirectoryGetPropertiesHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: DirectoryGetPropertiesHeaders;
|
||||
};
|
||||
};
|
||||
export type DirectoryGetPropertiesResponse = WithResponse<DirectoryGetPropertiesHeaders, DirectoryGetPropertiesHeaders>;
|
||||
|
||||
// @public
|
||||
export interface DirectoryItem {
|
||||
|
@ -347,13 +338,7 @@ export interface DirectoryListFilesAndDirectoriesSegmentHeaders {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type DirectoryListFilesAndDirectoriesSegmentResponse = DirectoryListFilesAndDirectoriesSegmentHeaders & ListFilesAndDirectoriesSegmentResponse & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
bodyAsText: string;
|
||||
parsedBody: ListFilesAndDirectoriesSegmentResponse;
|
||||
parsedHeaders: DirectoryListFilesAndDirectoriesSegmentHeaders;
|
||||
};
|
||||
};
|
||||
export type DirectoryListFilesAndDirectoriesSegmentResponse = WithResponse<DirectoryListFilesAndDirectoriesSegmentHeaders & ListFilesAndDirectoriesSegmentResponse, DirectoryListFilesAndDirectoriesSegmentHeaders, ListFilesAndDirectoriesSegmentResponse>;
|
||||
|
||||
// @public
|
||||
export interface DirectoryListHandlesHeaders {
|
||||
|
@ -371,13 +356,7 @@ export interface DirectoryListHandlesOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type DirectoryListHandlesResponse = DirectoryListHandlesHeaders & ListHandlesResponse & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
bodyAsText: string;
|
||||
parsedBody: ListHandlesResponse;
|
||||
parsedHeaders: DirectoryListHandlesHeaders;
|
||||
};
|
||||
};
|
||||
export type DirectoryListHandlesResponse = WithResponse<DirectoryListHandlesHeaders & ListHandlesResponse, DirectoryListHandlesHeaders, ListHandlesResponse>;
|
||||
|
||||
// @public
|
||||
export interface DirectoryListHandlesSegmentOptions extends CommonOptions {
|
||||
|
@ -423,11 +402,7 @@ export interface DirectoryRenameOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type DirectoryRenameResponse = DirectoryRenameHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: DirectoryRenameHeaders;
|
||||
};
|
||||
};
|
||||
export type DirectoryRenameResponse = WithResponse<DirectoryRenameHeaders, DirectoryRenameHeaders>;
|
||||
|
||||
// @public
|
||||
export interface DirectorySetMetadataHeaders {
|
||||
|
@ -445,11 +420,7 @@ export interface DirectorySetMetadataOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type DirectorySetMetadataResponse = DirectorySetMetadataHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: DirectorySetMetadataHeaders;
|
||||
};
|
||||
};
|
||||
export type DirectorySetMetadataResponse = WithResponse<DirectorySetMetadataHeaders, DirectorySetMetadataHeaders>;
|
||||
|
||||
// @public
|
||||
export interface DirectorySetPropertiesHeaders {
|
||||
|
@ -470,11 +441,7 @@ export interface DirectorySetPropertiesHeaders {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type DirectorySetPropertiesResponse = DirectorySetPropertiesHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: DirectorySetPropertiesHeaders;
|
||||
};
|
||||
};
|
||||
export type DirectorySetPropertiesResponse = WithResponse<DirectorySetPropertiesHeaders, DirectorySetPropertiesHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileAbortCopyFromURLOptions extends CommonOptions {
|
||||
|
@ -491,11 +458,7 @@ export interface FileAbortCopyHeaders {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileAbortCopyResponse = FileAbortCopyHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileAbortCopyHeaders;
|
||||
};
|
||||
};
|
||||
export type FileAbortCopyResponse = WithResponse<FileAbortCopyHeaders, FileAbortCopyHeaders>;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface FileAndDirectoryCreateCommonOptions {
|
||||
|
@ -562,11 +525,7 @@ export interface FileCreateOptions extends FileAndDirectoryCreateCommonOptions,
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileCreateResponse = FileCreateHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileCreateHeaders;
|
||||
};
|
||||
};
|
||||
export type FileCreateResponse = WithResponse<FileCreateHeaders, FileCreateHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileDeleteHeaders {
|
||||
|
@ -588,11 +547,7 @@ export interface FileDeleteOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileDeleteResponse = FileDeleteHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileDeleteHeaders;
|
||||
};
|
||||
};
|
||||
export type FileDeleteResponse = WithResponse<FileDeleteHeaders, FileDeleteHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileDownloadHeaders {
|
||||
|
@ -635,7 +590,7 @@ export interface FileDownloadHeaders {
|
|||
}
|
||||
|
||||
// @public
|
||||
export interface FileDownloadOptionalParams extends coreHttp.OperationOptions {
|
||||
export interface FileDownloadOptionalParams extends coreClient.OperationOptions {
|
||||
leaseAccessConditions?: LeaseAccessConditions;
|
||||
range?: string;
|
||||
rangeGetContentMD5?: boolean;
|
||||
|
@ -652,13 +607,7 @@ export interface FileDownloadOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileDownloadResponseModel = FileDownloadHeaders & {
|
||||
blobBody?: Promise<Blob>;
|
||||
readableStreamBody?: NodeJS.ReadableStream;
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileDownloadHeaders;
|
||||
};
|
||||
};
|
||||
export type FileDownloadResponseModel = WithResponse<RawFileDownloadResponse, FileDownloadHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileDownloadToBufferOptions extends CommonOptions {
|
||||
|
@ -692,11 +641,7 @@ export interface FileForceCloseHandlesOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileForceCloseHandlesResponse = CloseHandlesInfo & FileCloseHandlesHeaders & {
|
||||
_response: HttpResponse & {
|
||||
parsedHeaders: FileForceCloseHandlesHeaders;
|
||||
};
|
||||
};
|
||||
export type FileForceCloseHandlesResponse = WithResponse<CloseHandlesInfo & FileCloseHandlesHeaders, FileForceCloseHandlesHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileGenerateSasUrlOptions extends CommonGenerateSasUrlOptions {
|
||||
|
@ -748,20 +693,10 @@ export interface FileGetPropertiesOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileGetPropertiesResponse = FileGetPropertiesHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileGetPropertiesHeaders;
|
||||
};
|
||||
};
|
||||
export type FileGetPropertiesResponse = WithResponse<FileGetPropertiesHeaders, FileGetPropertiesHeaders>;
|
||||
|
||||
// @public
|
||||
export type FileGetRangeListDiffResponse = FileGetRangeListHeaders & ShareFileRangeList & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
bodyAsText: string;
|
||||
parsedBody: ShareFileRangeList;
|
||||
parsedHeaders: FileGetRangeListHeaders;
|
||||
};
|
||||
};
|
||||
export type FileGetRangeListDiffResponse = WithResponse<FileGetRangeListHeaders & ShareFileRangeList, FileGetRangeListHeaders, ShareFileRangeList>;
|
||||
|
||||
// @public
|
||||
export interface FileGetRangeListHeaders {
|
||||
|
@ -782,14 +717,9 @@ export interface FileGetRangeListOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileGetRangeListResponse = FileGetRangeListHeaders & {
|
||||
export type FileGetRangeListResponse = WithResponse<FileGetRangeListHeaders & {
|
||||
rangeList: RangeModel[];
|
||||
_response: HttpResponse & {
|
||||
parsedHeaders: FileGetRangeListHeaders;
|
||||
bodyAsText: string;
|
||||
parsedBody: RangeModel[];
|
||||
};
|
||||
};
|
||||
}, FileGetRangeListHeaders, RangeModel[]>;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface FileHttpHeaders {
|
||||
|
@ -832,13 +762,7 @@ export interface FileListHandlesOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileListHandlesResponse = FileListHandlesHeaders & ListHandlesResponse & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
bodyAsText: string;
|
||||
parsedBody: ListHandlesResponse;
|
||||
parsedHeaders: FileListHandlesHeaders;
|
||||
};
|
||||
};
|
||||
export type FileListHandlesResponse = WithResponse<FileListHandlesHeaders & ListHandlesResponse, FileListHandlesHeaders, ListHandlesResponse>;
|
||||
|
||||
// @public
|
||||
export interface FileListHandlesSegmentOptions extends CommonOptions {
|
||||
|
@ -920,11 +844,7 @@ export interface FileRenameOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileRenameResponse = FileRenameHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileRenameHeaders;
|
||||
};
|
||||
};
|
||||
export type FileRenameResponse = WithResponse<FileRenameHeaders, FileRenameHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileResizeOptions extends FileAndDirectorySetPropertiesCommonOptions, CommonOptions {
|
||||
|
@ -1001,11 +921,7 @@ export interface FileSetHttpHeadersOptions extends FileAndDirectorySetProperties
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileSetHTTPHeadersResponse = FileSetHTTPHeadersHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileSetHTTPHeadersHeaders;
|
||||
};
|
||||
};
|
||||
export type FileSetHTTPHeadersResponse = WithResponse<FileSetHTTPHeadersHeaders, FileSetHTTPHeadersHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileSetMetadataHeaders {
|
||||
|
@ -1024,11 +940,7 @@ export interface FileSetMetadataOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileSetMetadataResponse = FileSetMetadataHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileSetMetadataHeaders;
|
||||
};
|
||||
};
|
||||
export type FileSetMetadataResponse = WithResponse<FileSetMetadataHeaders, FileSetMetadataHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileStartCopyHeaders {
|
||||
|
@ -1053,11 +965,7 @@ export interface FileStartCopyOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileStartCopyResponse = FileStartCopyHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileStartCopyHeaders;
|
||||
};
|
||||
};
|
||||
export type FileStartCopyResponse = WithResponse<FileStartCopyHeaders, FileStartCopyHeaders>;
|
||||
|
||||
// @public
|
||||
export class FileSystemAttributes {
|
||||
|
@ -1089,7 +997,7 @@ export interface FileUploadRangeFromURLHeaders {
|
|||
}
|
||||
|
||||
// @public
|
||||
export interface FileUploadRangeFromURLOptionalParams extends coreHttp.OperationOptions {
|
||||
export interface FileUploadRangeFromURLOptionalParams extends coreClient.OperationOptions {
|
||||
copySourceAuthorization?: string;
|
||||
fileLastWrittenMode?: FileLastWrittenMode;
|
||||
leaseAccessConditions?: LeaseAccessConditions;
|
||||
|
@ -1111,11 +1019,7 @@ export interface FileUploadRangeFromURLOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileUploadRangeFromURLResponse = FileUploadRangeFromURLHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileUploadRangeFromURLHeaders;
|
||||
};
|
||||
};
|
||||
export type FileUploadRangeFromURLResponse = WithResponse<FileUploadRangeFromURLHeaders, FileUploadRangeFromURLHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileUploadRangeHeaders {
|
||||
|
@ -1140,11 +1044,7 @@ export interface FileUploadRangeOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type FileUploadRangeResponse = FileUploadRangeHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: FileUploadRangeHeaders;
|
||||
};
|
||||
};
|
||||
export type FileUploadRangeResponse = WithResponse<FileUploadRangeHeaders, FileUploadRangeHeaders>;
|
||||
|
||||
// @public
|
||||
export interface FileUploadStreamOptions extends CommonOptions {
|
||||
|
@ -1179,13 +1079,15 @@ export interface HttpAuthorization {
|
|||
value: string;
|
||||
}
|
||||
|
||||
export { HttpHeaders }
|
||||
// @public
|
||||
export interface HttpResponse {
|
||||
headers: HttpHeadersLike;
|
||||
request: WebResourceLike;
|
||||
status: number;
|
||||
}
|
||||
|
||||
export { HttpOperationResponse }
|
||||
|
||||
export { HttpRequestBody }
|
||||
|
||||
export { IHttpClient }
|
||||
// @public
|
||||
export function isPipelineLike(pipeline: unknown): pipeline is PipelineLike;
|
||||
|
||||
// @public
|
||||
export interface LeaseAccessConditions {
|
||||
|
@ -1201,11 +1103,7 @@ export interface LeaseOperationOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type LeaseOperationResponse = LeaseOperationResponseHeaders & {
|
||||
_response: HttpResponse & {
|
||||
parsedHeaders: LeaseOperationResponseHeaders;
|
||||
};
|
||||
};
|
||||
export type LeaseOperationResponse = WithResponse<LeaseOperationResponseHeaders, LeaseOperationResponseHeaders>;
|
||||
|
||||
// @public
|
||||
export interface LeaseOperationResponseHeaders {
|
||||
|
@ -1310,22 +1208,29 @@ export interface Metrics {
|
|||
}
|
||||
|
||||
// @public
|
||||
export function newPipeline(credential?: Credential_2, pipelineOptions?: StoragePipelineOptions): Pipeline;
|
||||
export function newPipeline(credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, pipelineOptions?: StoragePipelineOptions): Pipeline;
|
||||
|
||||
// @public
|
||||
export type PermissionCopyModeType = "source" | "override";
|
||||
|
||||
// @public
|
||||
export class Pipeline {
|
||||
export class Pipeline implements PipelineLike {
|
||||
constructor(factories: RequestPolicyFactory[], options?: PipelineOptions);
|
||||
readonly factories: RequestPolicyFactory[];
|
||||
readonly options: PipelineOptions;
|
||||
toServiceClientOptions(): ServiceClientOptions;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface PipelineLike {
|
||||
readonly factories: RequestPolicyFactory[];
|
||||
readonly options: PipelineOptions;
|
||||
toServiceClientOptions(): ServiceClientOptions;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface PipelineOptions {
|
||||
httpClient?: IHttpClient;
|
||||
httpClient?: RequestPolicy;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -1341,11 +1246,32 @@ export interface RangeModel {
|
|||
start: number;
|
||||
}
|
||||
|
||||
export { RequestPolicy }
|
||||
// @public
|
||||
export type RawFileDownloadResponse = FileDownloadHeaders & {
|
||||
blobBody?: Promise<Blob>;
|
||||
readableStreamBody?: NodeJS.ReadableStream;
|
||||
};
|
||||
|
||||
export { RequestPolicyFactory }
|
||||
// @public
|
||||
export interface ResponseLike {
|
||||
_response: HttpResponse;
|
||||
}
|
||||
|
||||
export { RequestPolicyOptions }
|
||||
// @public
|
||||
export interface ResponseWithBody<Headers, Body> {
|
||||
_response: HttpResponse & {
|
||||
parsedHeaders: Headers;
|
||||
bodyAsText: string;
|
||||
parsedBody: Body;
|
||||
};
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ResponseWithHeaders<Headers> {
|
||||
_response: HttpResponse & {
|
||||
parsedHeaders: Headers;
|
||||
};
|
||||
}
|
||||
|
||||
export { RestError }
|
||||
|
||||
|
@ -1389,6 +1315,12 @@ export class SASQueryParameters {
|
|||
readonly version: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ServiceClientOptions {
|
||||
httpClient?: RequestPolicy;
|
||||
requestPolicyFactories?: RequestPolicyFactory[] | ((defaultRequestPolicyFactories: RequestPolicyFactory[]) => void | RequestPolicyFactory[]);
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ServiceGenerateAccountSasUrlOptions {
|
||||
ipRange?: SasIPRange;
|
||||
|
@ -1410,13 +1342,7 @@ export interface ServiceGetPropertiesOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ServiceGetPropertiesResponse = ServiceGetPropertiesHeaders & FileServiceProperties & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
bodyAsText: string;
|
||||
parsedBody: FileServiceProperties;
|
||||
parsedHeaders: ServiceGetPropertiesHeaders;
|
||||
};
|
||||
};
|
||||
export type ServiceGetPropertiesResponse = WithResponse<ServiceGetPropertiesHeaders & FileServiceProperties, ServiceGetPropertiesHeaders, FileServiceProperties>;
|
||||
|
||||
// @public
|
||||
export interface ServiceListSharesOptions extends CommonOptions {
|
||||
|
@ -1435,13 +1361,7 @@ export interface ServiceListSharesSegmentHeaders {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ServiceListSharesSegmentResponse = ListSharesResponse & ServiceListSharesSegmentHeaders & {
|
||||
_response: HttpResponse & {
|
||||
parsedHeaders: ServiceListSharesSegmentHeaders;
|
||||
bodyAsText: string;
|
||||
parsedBody: ListSharesResponseModel;
|
||||
};
|
||||
};
|
||||
export type ServiceListSharesSegmentResponse = WithResponse<ListSharesResponse & ServiceListSharesSegmentHeaders, ServiceListSharesSegmentHeaders, ListSharesResponseModel>;
|
||||
|
||||
// @public
|
||||
export interface ServiceSetPropertiesHeaders {
|
||||
|
@ -1456,11 +1376,7 @@ export interface ServiceSetPropertiesOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ServiceSetPropertiesResponse = ServiceSetPropertiesHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: ServiceSetPropertiesHeaders;
|
||||
};
|
||||
};
|
||||
export type ServiceSetPropertiesResponse = WithResponse<ServiceSetPropertiesHeaders, ServiceSetPropertiesHeaders>;
|
||||
|
||||
// @public
|
||||
export interface ServiceUndeleteShareOptions extends CommonOptions {
|
||||
|
@ -1479,7 +1395,7 @@ export type ShareAccessTier = "TransactionOptimized" | "Hot" | "Cool";
|
|||
// @public
|
||||
export class ShareClient extends StorageClient {
|
||||
constructor(connectionString: string, name: string, options?: StoragePipelineOptions);
|
||||
constructor(url: string, credential?: Credential_2, options?: StoragePipelineOptions);
|
||||
constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential, options?: StoragePipelineOptions);
|
||||
constructor(url: string, pipeline: Pipeline);
|
||||
create(options?: ShareCreateOptions): Promise<ShareCreateResponse>;
|
||||
createDirectory(directoryName: string, options?: DirectoryCreateOptions): Promise<{
|
||||
|
@ -1556,18 +1472,10 @@ export interface ShareCreatePermissionOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ShareCreatePermissionResponse = ShareCreatePermissionHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: ShareCreatePermissionHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareCreatePermissionResponse = WithResponse<ShareCreatePermissionHeaders, ShareCreatePermissionHeaders>;
|
||||
|
||||
// @public
|
||||
export type ShareCreateResponse = ShareCreateHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: ShareCreateHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareCreateResponse = WithResponse<ShareCreateHeaders, ShareCreateHeaders>;
|
||||
|
||||
// @public
|
||||
export interface ShareCreateSnapshotHeaders {
|
||||
|
@ -1589,11 +1497,7 @@ export interface ShareCreateSnapshotOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ShareCreateSnapshotResponse = ShareCreateSnapshotHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: ShareCreateSnapshotHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareCreateSnapshotResponse = WithResponse<ShareCreateSnapshotHeaders, ShareCreateSnapshotHeaders>;
|
||||
|
||||
// @public
|
||||
export interface ShareDeleteHeaders {
|
||||
|
@ -1616,15 +1520,11 @@ export interface ShareDeleteMethodOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ShareDeleteResponse = ShareDeleteHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: ShareDeleteHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareDeleteResponse = WithResponse<ShareDeleteHeaders, ShareDeleteHeaders>;
|
||||
|
||||
// @public
|
||||
export class ShareDirectoryClient extends StorageClient {
|
||||
constructor(url: string, credential?: Credential_2, options?: StoragePipelineOptions);
|
||||
constructor(url: string, credential?: AnonymousCredential | StorageSharedKeyCredential, options?: StoragePipelineOptions);
|
||||
constructor(url: string, pipeline: Pipeline);
|
||||
create(options?: DirectoryCreateOptions): Promise<DirectoryCreateResponse>;
|
||||
createFile(fileName: string, size: number, options?: FileCreateOptions): Promise<{
|
||||
|
@ -1671,7 +1571,7 @@ export interface ShareExistsOptions extends CommonOptions {
|
|||
|
||||
// @public
|
||||
export class ShareFileClient extends StorageClient {
|
||||
constructor(url: string, credential?: Credential_2, options?: StoragePipelineOptions);
|
||||
constructor(url: string, credential?: AnonymousCredential | StorageSharedKeyCredential, options?: StoragePipelineOptions);
|
||||
constructor(url: string, pipeline: Pipeline);
|
||||
abortCopyFromURL(copyId: string, options?: FileAbortCopyFromURLOptions): Promise<FileAbortCopyResponse>;
|
||||
clearRange(offset: number, contentLength: number, options?: FileClearRangeOptions): Promise<FileUploadRangeResponse>;
|
||||
|
@ -1705,7 +1605,7 @@ export class ShareFileClient extends StorageClient {
|
|||
startCopyFromURL(copySource: string, options?: FileStartCopyOptions): Promise<FileStartCopyResponse>;
|
||||
uploadData(data: Buffer | Blob | ArrayBuffer | ArrayBufferView, options?: FileParallelUploadOptions): Promise<void>;
|
||||
uploadFile(filePath: string, options?: FileParallelUploadOptions): Promise<void>;
|
||||
uploadRange(body: HttpRequestBody, offset: number, contentLength: number, options?: FileUploadRangeOptions): Promise<FileUploadRangeResponse>;
|
||||
uploadRange(body: RequestBodyType, offset: number, contentLength: number, options?: FileUploadRangeOptions): Promise<FileUploadRangeResponse>;
|
||||
uploadRangeFromURL(sourceURL: string, sourceOffset: number, destOffset: number, count: number, options?: FileUploadRangeFromURLOptions): Promise<FileUploadRangeFromURLResponse>;
|
||||
uploadResetableStream(streamFactory: (offset: number, count?: number) => NodeJS.ReadableStream, size: number, options?: FileParallelUploadOptions): Promise<void>;
|
||||
uploadSeekableBlob(blobFactory: (offset: number, size: number) => Blob, size: number, options?: FileParallelUploadOptions): Promise<void>;
|
||||
|
@ -1743,15 +1643,9 @@ export interface ShareGetAccessPolicyOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type ShareGetAccessPolicyResponse = {
|
||||
export type ShareGetAccessPolicyResponse = WithResponse<{
|
||||
signedIdentifiers: SignedIdentifier[];
|
||||
} & ShareGetAccessPolicyHeaders & {
|
||||
_response: HttpResponse & {
|
||||
parsedHeaders: ShareGetAccessPolicyHeaders;
|
||||
bodyAsText: string;
|
||||
parsedBody: SignedIdentifierModel[];
|
||||
};
|
||||
};
|
||||
} & ShareGetAccessPolicyHeaders, ShareGetAccessPolicyHeaders, SignedIdentifierModel[]>;
|
||||
|
||||
// @public
|
||||
export interface ShareGetPermissionHeaders {
|
||||
|
@ -1767,13 +1661,7 @@ export interface ShareGetPermissionOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ShareGetPermissionResponse = ShareGetPermissionHeaders & SharePermission & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
bodyAsText: string;
|
||||
parsedBody: SharePermission;
|
||||
parsedHeaders: ShareGetPermissionHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareGetPermissionResponse = WithResponse<ShareGetPermissionHeaders & SharePermission, ShareGetPermissionHeaders, SharePermission>;
|
||||
|
||||
// @public
|
||||
export interface ShareGetPropertiesHeaders {
|
||||
|
@ -1814,11 +1702,7 @@ export type ShareGetPropertiesResponse = ShareGetPropertiesResponseModel & {
|
|||
};
|
||||
|
||||
// @public
|
||||
export type ShareGetPropertiesResponseModel = ShareGetPropertiesHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: ShareGetPropertiesHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareGetPropertiesResponseModel = WithResponse<ShareGetPropertiesHeaders, ShareGetPropertiesHeaders>;
|
||||
|
||||
// @public
|
||||
export interface ShareGetStatisticsHeaders {
|
||||
|
@ -1842,13 +1726,7 @@ export type ShareGetStatisticsResponse = ShareGetStatisticsResponseModel & {
|
|||
};
|
||||
|
||||
// @public
|
||||
export type ShareGetStatisticsResponseModel = ShareGetStatisticsHeaders & ShareStats & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
bodyAsText: string;
|
||||
parsedBody: ShareStats;
|
||||
parsedHeaders: ShareGetStatisticsHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareGetStatisticsResponseModel = WithResponse<ShareGetStatisticsHeaders & ShareStats, ShareGetStatisticsHeaders, ShareStats>;
|
||||
|
||||
// @public
|
||||
export interface ShareItem {
|
||||
|
@ -1970,7 +1848,7 @@ export class ShareSASPermissions {
|
|||
|
||||
// @public
|
||||
export class ShareServiceClient extends StorageClient {
|
||||
constructor(url: string, credential?: Credential_2, options?: StoragePipelineOptions);
|
||||
constructor(url: string, credential?: AnonymousCredential | StorageSharedKeyCredential, options?: StoragePipelineOptions);
|
||||
constructor(url: string, pipeline: Pipeline);
|
||||
createShare(shareName: string, options?: ShareCreateOptions): Promise<{
|
||||
shareCreateResponse: ShareCreateResponse;
|
||||
|
@ -2003,11 +1881,7 @@ export interface ShareSetAccessPolicyOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ShareSetAccessPolicyResponse = ShareSetAccessPolicyHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: ShareSetAccessPolicyHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareSetAccessPolicyResponse = WithResponse<ShareSetAccessPolicyHeaders, ShareGetAccessPolicyHeaders>;
|
||||
|
||||
// @public
|
||||
export interface ShareSetMetadataHeaders {
|
||||
|
@ -2026,11 +1900,7 @@ export interface ShareSetMetadataOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ShareSetMetadataResponse = ShareSetMetadataHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: ShareSetMetadataHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareSetMetadataResponse = WithResponse<ShareSetMetadataHeaders, ShareSetMetadataHeaders>;
|
||||
|
||||
// @public
|
||||
export interface ShareSetPropertiesHeaders {
|
||||
|
@ -2052,11 +1922,7 @@ export interface ShareSetPropertiesOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ShareSetPropertiesResponse = ShareSetPropertiesHeaders & {
|
||||
_response: coreHttp.HttpResponse & {
|
||||
parsedHeaders: ShareSetPropertiesHeaders;
|
||||
};
|
||||
};
|
||||
export type ShareSetPropertiesResponse = WithResponse<ShareSetPropertiesHeaders, ShareSetPropertiesHeaders>;
|
||||
|
||||
// @public
|
||||
export type ShareSetQuotaHeaders = ShareSetPropertiesHeaders;
|
||||
|
@ -2068,7 +1934,7 @@ export interface ShareSetQuotaOptions extends CommonOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type ShareSetQuotaResponse = ShareSetPropertiesResponse;
|
||||
export type ShareSetQuotaResponse = WithResponse<ShareSetQuotaHeaders, ShareSetQuotaHeaders>;
|
||||
|
||||
// @public
|
||||
export interface ShareSmbSettings {
|
||||
|
@ -2109,22 +1975,23 @@ export interface SourceModifiedAccessConditions {
|
|||
|
||||
// @public
|
||||
export class StorageBrowserPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions);
|
||||
sendRequest(request: WebResource): Promise<HttpOperationResponse>;
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike);
|
||||
sendRequest(request: WebResourceLike): Promise<CompatResponse>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class StorageBrowserPolicyFactory implements RequestPolicyFactory {
|
||||
create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageBrowserPolicy;
|
||||
create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): StorageBrowserPolicy;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface StoragePipelineOptions {
|
||||
httpClient?: IHttpClient;
|
||||
audience?: string | string[];
|
||||
httpClient?: RequestPolicy;
|
||||
keepAliveOptions?: KeepAliveOptions;
|
||||
proxyOptions?: ProxyOptions;
|
||||
proxyOptions?: ProxySettings;
|
||||
retryOptions?: StorageRetryOptions;
|
||||
userAgentOptions?: UserAgentOptions;
|
||||
userAgentOptions?: UserAgentPolicyOptions;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -2133,21 +2000,22 @@ export interface StorageRetryOptions {
|
|||
readonly maxTries?: number;
|
||||
readonly retryDelayInMs?: number;
|
||||
readonly retryPolicyType?: StorageRetryPolicyType;
|
||||
readonly secondaryHost?: string;
|
||||
readonly tryTimeoutInMs?: number;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class StorageRetryPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions, retryOptions?: StorageRetryOptions);
|
||||
protected attemptSendRequest(request: WebResource, secondaryHas404: boolean, attempt: number): Promise<HttpOperationResponse>;
|
||||
sendRequest(request: WebResource): Promise<HttpOperationResponse>;
|
||||
protected shouldRetry(isPrimaryRetry: boolean, attempt: number, response?: HttpOperationResponse, err?: RestError): boolean;
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike, retryOptions?: StorageRetryOptions);
|
||||
protected attemptSendRequest(request: WebResourceLike, secondaryHas404: boolean, attempt: number): Promise<CompatResponse>;
|
||||
sendRequest(request: WebResourceLike): Promise<CompatResponse>;
|
||||
protected shouldRetry(isPrimaryRetry: boolean, attempt: number, response?: CompatResponse, err?: RestError): boolean;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class StorageRetryPolicyFactory implements RequestPolicyFactory {
|
||||
constructor(retryOptions?: StorageRetryOptions);
|
||||
create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageRetryPolicy;
|
||||
create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): StorageRetryPolicy;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -2161,13 +2029,13 @@ export class StorageSharedKeyCredential extends Credential_2 {
|
|||
constructor(accountName: string, accountKey: string);
|
||||
readonly accountName: string;
|
||||
computeHMACSHA256(stringToSign: string): string;
|
||||
create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageSharedKeyCredentialPolicy;
|
||||
create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): StorageSharedKeyCredentialPolicy;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class StorageSharedKeyCredentialPolicy extends CredentialPolicy {
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions, factory: StorageSharedKeyCredential);
|
||||
protected signRequest(request: WebResource): WebResource;
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike, factory: StorageSharedKeyCredential);
|
||||
protected signRequest(request: WebResourceLike): WebResourceLike;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -2176,7 +2044,8 @@ export type TimeNowType = "now";
|
|||
// @public
|
||||
export type TimePreserveType = "preserve";
|
||||
|
||||
export { WebResource }
|
||||
// @public
|
||||
export type WithResponse<T, Headers = undefined, Body = undefined> = T & (Body extends object ? ResponseWithBody<Headers, Body> : Headers extends object ? ResponseWithHeaders<Headers> : ResponseLike);
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import { AccountSASPermissions } from "./AccountSASPermissions";
|
||||
import { AccountSASResourceTypes } from "./AccountSASResourceTypes";
|
||||
import { AccountSASServices } from "./AccountSASServices";
|
||||
import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential";
|
||||
import { StorageSharedKeyCredential } from "../../storage-blob/src/credentials/StorageSharedKeyCredential";
|
||||
import { SasIPRange, ipRangeToString } from "./SasIPRange";
|
||||
import { SASProtocol, SASQueryParameters } from "./SASQueryParameters";
|
||||
import { SERVICE_VERSION } from "./utils/constants";
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { HttpResponse, isNode } from "@azure/core-http";
|
||||
import { isNode } from "@azure/core-util";
|
||||
import {
|
||||
CopyStatusType,
|
||||
FileDownloadHeaders,
|
||||
|
@ -16,6 +16,7 @@ import {
|
|||
RetriableReadableStream,
|
||||
RetriableReadableStreamOptions,
|
||||
} from "./utils/RetriableReadableStream";
|
||||
import { HttpResponse, WithResponse, assertResponse } from "./utils/utils.common";
|
||||
|
||||
/**
|
||||
* ONLY AVAILABLE IN NODE.JS RUNTIME.
|
||||
|
@ -397,7 +398,7 @@ export class FileDownloadResponse implements FileDownloadResponseModel {
|
|||
return this.originalResponse._response;
|
||||
}
|
||||
|
||||
private originalResponse: FileDownloadResponseModel;
|
||||
private originalResponse: WithResponse<FileDownloadResponseModel, FileDownloadHeaders>;
|
||||
private fileDownloadStream?: RetriableReadableStream;
|
||||
|
||||
/**
|
||||
|
@ -416,7 +417,9 @@ export class FileDownloadResponse implements FileDownloadResponseModel {
|
|||
count: number,
|
||||
options: RetriableReadableStreamOptions = {}
|
||||
) {
|
||||
this.originalResponse = originalResponse;
|
||||
this.originalResponse = assertResponse<FileDownloadResponseModel, FileDownloadHeaders>(
|
||||
originalResponse
|
||||
);
|
||||
this.fileDownloadStream = new RetriableReadableStream(
|
||||
this.originalResponse.readableStreamBody!,
|
||||
getter,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential";
|
||||
import { StorageSharedKeyCredential } from "../../storage-blob/src/credentials/StorageSharedKeyCredential";
|
||||
import { FileSASPermissions } from "./FileSASPermissions";
|
||||
import { SasIPRange, ipRangeToString } from "./SasIPRange";
|
||||
import { SASProtocol, SASQueryParameters } from "./SASQueryParameters";
|
||||
|
|
|
@ -1,181 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
BaseRequestPolicy,
|
||||
deserializationPolicy,
|
||||
disableResponseDecompressionPolicy,
|
||||
HttpClient as IHttpClient,
|
||||
HttpHeaders,
|
||||
HttpOperationResponse,
|
||||
HttpRequestBody,
|
||||
RequestPolicy,
|
||||
RequestPolicyFactory,
|
||||
RequestPolicyOptions,
|
||||
ServiceClientOptions,
|
||||
WebResource,
|
||||
proxyPolicy,
|
||||
isNode,
|
||||
tracingPolicy,
|
||||
logPolicy,
|
||||
ProxyOptions,
|
||||
UserAgentOptions,
|
||||
KeepAliveOptions,
|
||||
keepAlivePolicy,
|
||||
generateClientRequestIdPolicy,
|
||||
} from "@azure/core-http";
|
||||
|
||||
import { logger } from "./log";
|
||||
import { StorageBrowserPolicyFactory } from "./StorageBrowserPolicyFactory";
|
||||
import { Credential } from "./credentials/Credential";
|
||||
import { StorageRetryOptions, StorageRetryPolicyFactory } from "./StorageRetryPolicyFactory";
|
||||
import { TelemetryPolicyFactory } from "./TelemetryPolicyFactory";
|
||||
import {
|
||||
StorageFileLoggingAllowedHeaderNames,
|
||||
StorageFileLoggingAllowedQueryParameters,
|
||||
} from "./utils/constants";
|
||||
import { getCachedDefaultHttpClient } from "./utils/cache";
|
||||
import { AnonymousCredential } from "./credentials/AnonymousCredential";
|
||||
|
||||
// Export following interfaces and types for customers who want to implement their
|
||||
// own RequestPolicy or HTTPClient
|
||||
export {
|
||||
deserializationPolicy,
|
||||
IHttpClient,
|
||||
HttpHeaders,
|
||||
HttpOperationResponse,
|
||||
HttpRequestBody,
|
||||
WebResource,
|
||||
BaseRequestPolicy,
|
||||
RequestPolicyFactory,
|
||||
RequestPolicy,
|
||||
RequestPolicyOptions,
|
||||
};
|
||||
|
||||
/**
|
||||
* Option interface for Pipeline constructor.
|
||||
*/
|
||||
export interface PipelineOptions {
|
||||
/**
|
||||
* Optional. Configures the HTTP client to send requests and receive responses.
|
||||
*/
|
||||
httpClient?: IHttpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Pipeline class containing HTTP request policies.
|
||||
* You can create a default Pipeline by calling {@link newPipeline}.
|
||||
* Or you can create a Pipeline with your own policies by the constructor of Pipeline.
|
||||
*
|
||||
* Refer to {@link newPipeline} and provided policies as reference before
|
||||
* implementing your customized Pipeline.
|
||||
*/
|
||||
export class Pipeline {
|
||||
/**
|
||||
* A list of chained request policy factories.
|
||||
*/
|
||||
public readonly factories: RequestPolicyFactory[];
|
||||
/**
|
||||
* Configures pipeline logger and HTTP client.
|
||||
*/
|
||||
public readonly options: PipelineOptions;
|
||||
|
||||
/**
|
||||
* Creates an instance of Pipeline. Customize HTTPClient by implementing IHttpClient interface.
|
||||
*
|
||||
* @param factories -
|
||||
* @param options -
|
||||
*/
|
||||
constructor(factories: RequestPolicyFactory[], options: PipelineOptions = {}) {
|
||||
this.factories = factories;
|
||||
// when options.httpClient is not specified, passing in a DefaultHttpClient instance to
|
||||
// avoid each client creating its own http client.
|
||||
this.options = {
|
||||
...options,
|
||||
httpClient: options.httpClient || getCachedDefaultHttpClient(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer Pipeline object to ServiceClientOptions object which required by
|
||||
* ServiceClient constructor.
|
||||
*
|
||||
* @returns The ServiceClientOptions object from this Pipeline.
|
||||
*/
|
||||
public toServiceClientOptions(): ServiceClientOptions {
|
||||
return {
|
||||
httpClient: this.options.httpClient,
|
||||
requestPolicyFactories: this.factories,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Option interface for {@link newPipeline} function.
|
||||
*/
|
||||
export interface StoragePipelineOptions {
|
||||
/**
|
||||
* Options to configure a proxy for outgoing requests.
|
||||
*/
|
||||
proxyOptions?: ProxyOptions;
|
||||
/**
|
||||
* Options for adding user agent details to outgoing requests.
|
||||
*/
|
||||
userAgentOptions?: UserAgentOptions;
|
||||
/**
|
||||
* Configures the built-in retry policy behavior.
|
||||
*/
|
||||
retryOptions?: StorageRetryOptions;
|
||||
/**
|
||||
* Keep alive configurations. Default keep-alive is enabled.
|
||||
*/
|
||||
keepAliveOptions?: KeepAliveOptions;
|
||||
/**
|
||||
* Configures the HTTP client to send requests and receive responses.
|
||||
*/
|
||||
httpClient?: IHttpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Pipeline} object with {@link Credential} provided.
|
||||
*
|
||||
* @param credential - Such as AnonymousCredential, StorageSharedKeyCredential.
|
||||
* @param pipelineOptions - Optional. Options.
|
||||
* @returns A new Pipeline object.
|
||||
*/
|
||||
export function newPipeline(
|
||||
credential?: Credential,
|
||||
pipelineOptions: StoragePipelineOptions = {}
|
||||
): Pipeline {
|
||||
if (credential === undefined) {
|
||||
credential = new AnonymousCredential();
|
||||
}
|
||||
|
||||
// Order is important. Closer to the API at the top & closer to the network at the bottom.
|
||||
// The credential's policy factory must appear close to the wire so it can sign any
|
||||
// changes made by other factories (like UniqueRequestIDPolicyFactory)
|
||||
const telemetryPolicy = new TelemetryPolicyFactory(pipelineOptions.userAgentOptions);
|
||||
const factories: RequestPolicyFactory[] = [
|
||||
tracingPolicy({ userAgent: telemetryPolicy.telemetryString }),
|
||||
keepAlivePolicy(pipelineOptions.keepAliveOptions),
|
||||
telemetryPolicy,
|
||||
generateClientRequestIdPolicy(),
|
||||
new StorageBrowserPolicyFactory(),
|
||||
new StorageRetryPolicyFactory(pipelineOptions.retryOptions), // Retry policy should be above any policy that throws retryable errors
|
||||
deserializationPolicy(), // Default deserializationPolicy is provided by protocol layer
|
||||
logPolicy({
|
||||
logger: logger.info,
|
||||
allowedHeaderNames: StorageFileLoggingAllowedHeaderNames,
|
||||
allowedQueryParameters: StorageFileLoggingAllowedQueryParameters,
|
||||
}),
|
||||
];
|
||||
|
||||
if (isNode) {
|
||||
// policies only available in Node.js runtime, not in browsers
|
||||
factories.push(proxyPolicy(pipelineOptions.proxyOptions));
|
||||
factories.push(disableResponseDecompressionPolicy());
|
||||
}
|
||||
factories.push(credential);
|
||||
|
||||
return new Pipeline(factories, pipelineOptions);
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { Pipeline } from "./Pipeline";
|
||||
import { Pipeline } from "../../storage-blob/src/Pipeline";
|
||||
import { StorageClient } from "./StorageClient";
|
||||
import { ShareRestoreOptionalParams, ShareRestoreResponse } from "./generated/src/models";
|
||||
import { Share } from "./generated/src/operations";
|
||||
import { Share } from "./generated/src/operationsInterfaces";
|
||||
|
||||
/**
|
||||
* ShareClientInternal is the thin wrapper for Share which contains internal helper methods.
|
||||
|
@ -14,7 +14,7 @@ export class ShareClientInternal extends StorageClient {
|
|||
|
||||
constructor(url: string, pipeline: Pipeline) {
|
||||
super(url, pipeline);
|
||||
this.context = new Share(this.storageClientContext);
|
||||
this.context = this.storageClientContext.share;
|
||||
}
|
||||
|
||||
public async restore(options: ShareRestoreOptionalParams = {}): Promise<ShareRestoreResponse> {
|
||||
|
|
|
@ -12,21 +12,28 @@ import {
|
|||
ServiceListSharesSegmentHeaders,
|
||||
ListSharesResponseModel,
|
||||
SharePropertiesInternal,
|
||||
ServiceSetPropertiesHeaders,
|
||||
ServiceGetPropertiesHeaders,
|
||||
} from "./generatedModels";
|
||||
import { Service } from "./generated/src/operations";
|
||||
import { newPipeline, StoragePipelineOptions, Pipeline } from "./Pipeline";
|
||||
import { Service } from "./generated/src/operationsInterfaces";
|
||||
import { newPipeline, StoragePipelineOptions, Pipeline } from "../../storage-blob/src/Pipeline";
|
||||
import { StorageClient, CommonOptions } from "./StorageClient";
|
||||
import { ShareClientInternal } from "./ShareClientInternal";
|
||||
import { ShareClient, ShareCreateOptions, ShareDeleteMethodOptions } from "./Clients";
|
||||
import { appendToURLPath, extractConnectionStringParts } from "./utils/utils.common";
|
||||
import { Credential } from "./credentials/Credential";
|
||||
import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential";
|
||||
import { AnonymousCredential } from "./credentials/AnonymousCredential";
|
||||
import {
|
||||
WithResponse,
|
||||
appendToURLPath,
|
||||
extractConnectionStringParts,
|
||||
assertResponse,
|
||||
} from "./utils/utils.common";
|
||||
import { Credential } from "../../storage-blob/src/credentials/Credential";
|
||||
import { StorageSharedKeyCredential } from "../../storage-blob/src/credentials/StorageSharedKeyCredential";
|
||||
import { AnonymousCredential } from "../../storage-blob/src/credentials/AnonymousCredential";
|
||||
import "@azure/core-paging";
|
||||
import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
|
||||
import { isNode, HttpResponse } from "@azure/core-http";
|
||||
import { isNode } from "@azure/core-util";
|
||||
import { SpanStatusCode } from "@azure/core-tracing";
|
||||
import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing";
|
||||
import { createSpan } from "./utils/tracing";
|
||||
import { ShareProtocols, toShareProtocols } from "./models";
|
||||
import { AccountSASPermissions } from "./AccountSASPermissions";
|
||||
import { generateAccountSASQueryParameters } from "./AccountSASSignatureValues";
|
||||
|
@ -169,28 +176,11 @@ export interface ListSharesResponse {
|
|||
/**
|
||||
* Contains response data for the {@link ShareServiceClient.listShares} operation.
|
||||
*/
|
||||
export type ServiceListSharesSegmentResponse = ListSharesResponse &
|
||||
ServiceListSharesSegmentHeaders & {
|
||||
/**
|
||||
* The underlying HTTP response.
|
||||
*/
|
||||
_response: HttpResponse & {
|
||||
/**
|
||||
* The parsed HTTP response headers.
|
||||
*/
|
||||
parsedHeaders: ServiceListSharesSegmentHeaders;
|
||||
|
||||
/**
|
||||
* The response body as text (string format)
|
||||
*/
|
||||
bodyAsText: string;
|
||||
|
||||
/**
|
||||
* The response body as parsed JSON or XML
|
||||
*/
|
||||
parsedBody: ListSharesResponseModel;
|
||||
};
|
||||
};
|
||||
export type ServiceListSharesSegmentResponse = WithResponse<
|
||||
ListSharesResponse & ServiceListSharesSegmentHeaders,
|
||||
ServiceListSharesSegmentHeaders,
|
||||
ListSharesResponseModel
|
||||
>;
|
||||
|
||||
/**
|
||||
* Options to configure {@link ShareServiceClient.generateAccountSasUrl} operation.
|
||||
|
@ -278,9 +268,14 @@ export class ShareServiceClient extends StorageClient {
|
|||
* If not specified, AnonymousCredential is used.
|
||||
* @param options - Optional. Options to configure the HTTP pipeline.
|
||||
*/
|
||||
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
|
||||
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
|
||||
constructor(url: string, credential?: Credential, options?: StoragePipelineOptions);
|
||||
|
||||
constructor(
|
||||
url: string,
|
||||
credential?: AnonymousCredential | StorageSharedKeyCredential,
|
||||
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
|
||||
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
|
||||
options?: StoragePipelineOptions
|
||||
);
|
||||
/**
|
||||
* Creates an instance of ShareServiceClient.
|
||||
*
|
||||
|
@ -293,7 +288,7 @@ export class ShareServiceClient extends StorageClient {
|
|||
constructor(url: string, pipeline: Pipeline);
|
||||
constructor(
|
||||
url: string,
|
||||
credentialOrPipeline?: Credential | Pipeline,
|
||||
credentialOrPipeline?: AnonymousCredential | StorageSharedKeyCredential | Pipeline,
|
||||
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
|
||||
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
|
||||
options?: StoragePipelineOptions
|
||||
|
@ -309,7 +304,7 @@ export class ShareServiceClient extends StorageClient {
|
|||
}
|
||||
|
||||
super(url, pipeline);
|
||||
this.serviceContext = new Service(this.storageClientContext);
|
||||
this.serviceContext = this.storageClientContext.service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -399,10 +394,11 @@ export class ShareServiceClient extends StorageClient {
|
|||
): Promise<ServiceGetPropertiesResponse> {
|
||||
const { span, updatedOptions } = createSpan("ShareServiceClient-getProperties", options);
|
||||
try {
|
||||
return await this.serviceContext.getProperties({
|
||||
abortSignal: options.abortSignal,
|
||||
...convertTracingToRequestOptionsBase(updatedOptions),
|
||||
});
|
||||
return assertResponse<
|
||||
ServiceGetPropertiesHeaders & FileServiceProperties,
|
||||
ServiceGetPropertiesHeaders,
|
||||
FileServiceProperties
|
||||
>(await this.serviceContext.getProperties(updatedOptions));
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
|
@ -429,10 +425,9 @@ export class ShareServiceClient extends StorageClient {
|
|||
): Promise<ServiceSetPropertiesResponse> {
|
||||
const { span, updatedOptions } = createSpan("ShareServiceClient-setProperties", options);
|
||||
try {
|
||||
return await this.serviceContext.setProperties(properties, {
|
||||
abortSignal: options.abortSignal,
|
||||
...convertTracingToRequestOptionsBase(updatedOptions),
|
||||
});
|
||||
return assertResponse<ServiceSetPropertiesHeaders, ServiceSetPropertiesHeaders>(
|
||||
await this.serviceContext.setProperties(properties, updatedOptions)
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
|
@ -633,18 +628,22 @@ export class ShareServiceClient extends StorageClient {
|
|||
marker?: string,
|
||||
options: ServiceListSharesSegmentOptions = {}
|
||||
): Promise<ServiceListSharesSegmentResponse> {
|
||||
const { span, updatedOptions } = createSpan("ShareServiceClient-listSharesSegment", options);
|
||||
|
||||
if (options.prefix === "") {
|
||||
options.prefix = undefined;
|
||||
}
|
||||
const { span, updatedOptions } = createSpan("ShareServiceClient-listSharesSegment", options);
|
||||
|
||||
try {
|
||||
const res = await this.serviceContext.listSharesSegment({
|
||||
marker,
|
||||
...options,
|
||||
...convertTracingToRequestOptionsBase(updatedOptions),
|
||||
});
|
||||
const res = assertResponse<
|
||||
ServiceListSharesSegmentHeaders & ListSharesResponseModel,
|
||||
ServiceListSharesSegmentHeaders,
|
||||
ListSharesResponseModel
|
||||
>(
|
||||
await this.serviceContext.listSharesSegment({
|
||||
...updatedOptions,
|
||||
marker,
|
||||
})
|
||||
);
|
||||
|
||||
// parse protocols
|
||||
if (res.shareItems) {
|
||||
|
@ -685,10 +684,9 @@ export class ShareServiceClient extends StorageClient {
|
|||
try {
|
||||
const shareClient = this.getShareClient(deletedShareName);
|
||||
await new ShareClientInternal(shareClient.url, this.pipeline).restore({
|
||||
...updatedOptions,
|
||||
deletedShareName: deletedShareName,
|
||||
deletedShareVersion: deletedShareVersion,
|
||||
abortSignal: options.abortSignal,
|
||||
...convertTracingToRequestOptionsBase(updatedOptions),
|
||||
});
|
||||
return shareClient;
|
||||
} catch (e: any) {
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RequestPolicy, RequestPolicyFactory, RequestPolicyOptions } from "@azure/core-http";
|
||||
import { StorageBrowserPolicy } from "./policies/StorageBrowserPolicy";
|
||||
export { StorageBrowserPolicy };
|
||||
|
||||
/**
|
||||
* StorageBrowserPolicyFactory is a factory class helping generating BrowserPolicy objects.
|
||||
*/
|
||||
export class StorageBrowserPolicyFactory implements RequestPolicyFactory {
|
||||
/**
|
||||
* Creates a StorageBrowserPolicyFactory object.
|
||||
*
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
public create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageBrowserPolicy {
|
||||
return new StorageBrowserPolicy(nextPolicy, options);
|
||||
}
|
||||
}
|
|
@ -1,16 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { StorageClientContext } from "./generated/src/storageClientContext";
|
||||
import { Pipeline } from "./Pipeline";
|
||||
import { StorageClient as StorageClientContext } from "./generated/src/";
|
||||
import { StorageContextClient } from "./StorageContextClient";
|
||||
import {
|
||||
Pipeline,
|
||||
getCoreClientOptions,
|
||||
getCredentialFromPipeline,
|
||||
} from "../../storage-blob/src/Pipeline";
|
||||
import { escapeURLPath, getAccountNameFromUrl } from "./utils/utils.common";
|
||||
import { SERVICE_VERSION } from "./utils/constants";
|
||||
import { isTokenCredential } from "@azure/core-auth";
|
||||
import { OperationTracingOptions } from "@azure/core-tracing";
|
||||
import { AnonymousCredential } from "./credentials/AnonymousCredential";
|
||||
import { Credential } from "./credentials/Credential";
|
||||
import { isNode } from "@azure/core-http";
|
||||
import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential";
|
||||
import { AnonymousCredential } from "../../storage-blob/src/credentials/AnonymousCredential";
|
||||
import { StorageSharedKeyCredential } from "../../storage-blob/src/credentials/StorageSharedKeyCredential";
|
||||
import { HttpClient } from "@azure/core-rest-pipeline";
|
||||
|
||||
let testOnlyHttpClient: HttpClient | undefined;
|
||||
/**
|
||||
* @internal
|
||||
* Set a custom default http client for testing purposes
|
||||
*/
|
||||
export function setTestOnlySetHttpClient(httpClient: HttpClient): void {
|
||||
testOnlyHttpClient = httpClient;
|
||||
}
|
||||
/**
|
||||
* An interface for options common to every remote operation.
|
||||
*/
|
||||
|
@ -36,12 +48,12 @@ export abstract class StorageClient {
|
|||
protected readonly pipeline: Pipeline;
|
||||
|
||||
/**
|
||||
* Credential in the pipleline to authenticate requests to the service, such as AnonymousCredential, StorageSharedKeyCredential.
|
||||
* Credential in the pipeline to authenticate requests to the service, such as AnonymousCredential, StorageSharedKeyCredential.
|
||||
* Initialized to an AnonymousCredential if not able to retrieve it from the pipeline.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected readonly credential: Credential;
|
||||
protected readonly credential: StorageSharedKeyCredential | AnonymousCredential;
|
||||
|
||||
/**
|
||||
* StorageClient is a reference to protocol layer operations entry, which is
|
||||
|
@ -60,27 +72,21 @@ export abstract class StorageClient {
|
|||
this.accountName = getAccountNameFromUrl(url);
|
||||
|
||||
this.pipeline = pipeline;
|
||||
this.storageClientContext = new StorageClientContext(this.url, {
|
||||
version: SERVICE_VERSION,
|
||||
...pipeline.toServiceClientOptions(),
|
||||
});
|
||||
|
||||
const coreOptions = getCoreClientOptions(pipeline);
|
||||
if (testOnlyHttpClient) {
|
||||
coreOptions.httpClient = testOnlyHttpClient;
|
||||
}
|
||||
this.storageClientContext = new StorageContextClient(this.url, coreOptions);
|
||||
// Remove the default content-type in generated code of StorageClientContext
|
||||
const storageClientContext = this.storageClientContext as any;
|
||||
if (storageClientContext.requestContentType) {
|
||||
storageClientContext.requestContentType = undefined;
|
||||
}
|
||||
|
||||
// Retrieve credential from the pipeline.
|
||||
this.credential = new AnonymousCredential();
|
||||
for (const factory of this.pipeline.factories) {
|
||||
if (
|
||||
(isNode && factory instanceof StorageSharedKeyCredential) ||
|
||||
factory instanceof AnonymousCredential
|
||||
) {
|
||||
this.credential = factory;
|
||||
break;
|
||||
}
|
||||
const credential = getCredentialFromPipeline(pipeline);
|
||||
if (isTokenCredential(credential)) {
|
||||
throw new Error("Unsupported TokenCredential type found in pipeline.");
|
||||
}
|
||||
this.credential = credential;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { OperationArguments, OperationSpec } from "@azure/core-client";
|
||||
import { StorageClient } from "./generated/src";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class StorageContextClient extends StorageClient {
|
||||
async sendOperationRequest<T>(
|
||||
operationArguments: OperationArguments,
|
||||
operationSpec: OperationSpec
|
||||
): Promise<T> {
|
||||
const operationSpecToSend = { ...operationSpec };
|
||||
|
||||
if (
|
||||
operationSpecToSend.path === "/{shareName}" ||
|
||||
operationSpecToSend.path === "/{shareName}/{directory}" ||
|
||||
operationSpecToSend.path === "/{shareName}/{directory}/{fileName}"
|
||||
) {
|
||||
operationSpecToSend.path = "";
|
||||
}
|
||||
return super.sendOperationRequest(operationArguments, operationSpecToSend);
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RequestPolicy, RequestPolicyFactory, RequestPolicyOptions } from "@azure/core-http";
|
||||
import { StorageRetryPolicy, StorageRetryPolicyType } from "./policies/StorageRetryPolicy";
|
||||
|
||||
export { StorageRetryPolicyType, StorageRetryPolicy };
|
||||
|
||||
/**
|
||||
* Retry options interface.
|
||||
*/
|
||||
export interface StorageRetryOptions {
|
||||
/**
|
||||
* Optional. StorageRetryPolicyType, default is exponential retry policy.
|
||||
*/
|
||||
readonly retryPolicyType?: StorageRetryPolicyType;
|
||||
|
||||
/**
|
||||
* Optional. Max try number of attempts, default is 4.
|
||||
* A value of 1 means 1 try and no retries.
|
||||
* A value smaller than 1 means default retry number of attempts.
|
||||
*/
|
||||
readonly maxTries?: number;
|
||||
|
||||
/**
|
||||
* Optional. Indicates the maximum time in ms allowed for any single try of an HTTP request.
|
||||
* A value of zero or undefined means that you accept our default timeout, 60s or 60 * 1000ms.
|
||||
*
|
||||
* NOTE: When transferring large amounts of data, the default TryTimeout will probably
|
||||
* not be sufficient. You should override this value based on the bandwidth available to
|
||||
* the host machine and proximity to the Storage service. A good starting point may be something
|
||||
* like (60 seconds per MB of anticipated-payload-size)
|
||||
*/
|
||||
readonly tryTimeoutInMs?: number;
|
||||
|
||||
/**
|
||||
* Optional. Specifies the amount of delay to use before retrying an operation (default is 4s or 4 * 1000ms).
|
||||
* The delay increases (exponentially or linearly) with each retry up to a maximum specified by
|
||||
* maxRetryDelayInMs. If you specify 0, then you must also specify 0 for maxRetryDelayInMs.
|
||||
*/
|
||||
readonly retryDelayInMs?: number;
|
||||
|
||||
/**
|
||||
* Optional. Specifies the maximum delay allowed before retrying an operation (default is 120s or 120 * 1000ms).
|
||||
* If you specify 0, then you must also specify 0 for retryDelayInMs.
|
||||
*/
|
||||
readonly maxRetryDelayInMs?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* StorageRetryPolicyFactory is a factory class helping generating StorageRetryPolicy objects.
|
||||
*/
|
||||
export class StorageRetryPolicyFactory implements RequestPolicyFactory {
|
||||
private retryOptions?: StorageRetryOptions;
|
||||
|
||||
/**
|
||||
* Creates an instance of StorageRetryPolicyFactory.
|
||||
* @param retryOptions -
|
||||
*/
|
||||
constructor(retryOptions?: StorageRetryOptions) {
|
||||
this.retryOptions = retryOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a StorageRetryPolicy object.
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
public create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageRetryPolicy {
|
||||
return new StorageRetryPolicy(nextPolicy, options, this.retryOptions);
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
isNode,
|
||||
RequestPolicy,
|
||||
RequestPolicyFactory,
|
||||
RequestPolicyOptions,
|
||||
UserAgentOptions,
|
||||
} from "@azure/core-http";
|
||||
import * as os from "os";
|
||||
|
||||
import { TelemetryPolicy } from "./policies/TelemetryPolicy";
|
||||
import { SDK_VERSION } from "./utils/constants";
|
||||
|
||||
/**
|
||||
* TelemetryPolicyFactory is a factory class helping generating {@link TelemetryPolicy} objects.
|
||||
*/
|
||||
export class TelemetryPolicyFactory implements RequestPolicyFactory {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public readonly telemetryString: string;
|
||||
|
||||
/**
|
||||
* Creates an instance of TelemetryPolicyFactory.
|
||||
* @param telemetry -
|
||||
*/
|
||||
constructor(telemetry?: UserAgentOptions) {
|
||||
const userAgentInfo: string[] = [];
|
||||
|
||||
if (isNode) {
|
||||
if (telemetry) {
|
||||
const telemetryString = telemetry.userAgentPrefix || "";
|
||||
if (telemetryString.length > 0 && userAgentInfo.indexOf(telemetryString) === -1) {
|
||||
userAgentInfo.push(telemetryString);
|
||||
}
|
||||
}
|
||||
|
||||
// e.g. azsdk-js-storagefile/11.0.0
|
||||
const libInfo = `azsdk-js-storagefile/${SDK_VERSION}`;
|
||||
if (userAgentInfo.indexOf(libInfo) === -1) {
|
||||
userAgentInfo.push(libInfo);
|
||||
}
|
||||
|
||||
// e.g. (NODE-VERSION 4.9.1; Windows_NT 10.0.16299)
|
||||
let runtimeInfo = `(NODE-VERSION ${process.version})`;
|
||||
if (os) {
|
||||
runtimeInfo = `(NODE-VERSION ${process.version}; ${os.type()} ${os.release()})`;
|
||||
}
|
||||
if (userAgentInfo.indexOf(runtimeInfo) === -1) {
|
||||
userAgentInfo.push(runtimeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
this.telemetryString = userAgentInfo.join(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link RequestPolicy} object.
|
||||
*
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
public create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): TelemetryPolicy {
|
||||
return new TelemetryPolicy(nextPolicy, options, this.telemetryString);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RequestPolicy, RequestPolicyOptions } from "@azure/core-http";
|
||||
|
||||
import { AnonymousCredentialPolicy } from "../policies/AnonymousCredentialPolicy";
|
||||
import { Credential } from "./Credential";
|
||||
|
||||
/**
|
||||
* AnonymousCredential provides a credentialPolicyCreator member used to create
|
||||
* {@link AnonymousCredentialPolicy} objects. AnonymousCredentialPolicy is used with
|
||||
* HTTP(S) requests that read public resources or for use with Shared Access
|
||||
* Signatures (SAS).
|
||||
*/
|
||||
export class AnonymousCredential extends Credential {
|
||||
/**
|
||||
* Creates an {@link AnonymousCredentialPolicy} object.
|
||||
*
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
public create(
|
||||
nextPolicy: RequestPolicy,
|
||||
options: RequestPolicyOptions
|
||||
): AnonymousCredentialPolicy {
|
||||
return new AnonymousCredentialPolicy(nextPolicy, options);
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RequestPolicy, RequestPolicyFactory, RequestPolicyOptions } from "@azure/core-http";
|
||||
import { CredentialPolicy } from "../policies/CredentialPolicy";
|
||||
|
||||
/**
|
||||
* Credential is an abstract class for Azure Storage HTTP requests signing. This
|
||||
* class will host an credentialPolicyCreator factory which generates CredentialPolicy.
|
||||
*/
|
||||
export abstract class Credential implements RequestPolicyFactory {
|
||||
/**
|
||||
* Creates a RequestPolicy object.
|
||||
*
|
||||
* @param _nextPolicy -
|
||||
* @param _options -
|
||||
*/
|
||||
public create(_nextPolicy: RequestPolicy, _options: RequestPolicyOptions): RequestPolicy {
|
||||
throw new Error("Method should be implemented in children classes.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A factory function that creates a new CredentialPolicy that uses the provided nextPolicy.
|
||||
*/
|
||||
export type CredentialPolicyCreator = (
|
||||
nextPolicy: RequestPolicy,
|
||||
options: RequestPolicyOptions
|
||||
) => CredentialPolicy;
|
|
@ -1,4 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
export class StorageSharedKeyCredential {}
|
|
@ -1,58 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { createHmac } from "crypto";
|
||||
import { RequestPolicy, RequestPolicyOptions } from "@azure/core-http";
|
||||
|
||||
import { StorageSharedKeyCredentialPolicy } from "../policies/StorageSharedKeyCredentialPolicy";
|
||||
import { Credential } from "./Credential";
|
||||
|
||||
/**
|
||||
* ONLY AVAILABLE IN NODE.JS RUNTIME.
|
||||
*
|
||||
* StorageSharedKeyCredential for account key authorization of Azure Storage service.
|
||||
*/
|
||||
export class StorageSharedKeyCredential extends Credential {
|
||||
/**
|
||||
* Azure Storage account name; readonly.
|
||||
*/
|
||||
public readonly accountName: string;
|
||||
|
||||
/**
|
||||
* Azure Storage account key; readonly.
|
||||
*/
|
||||
private readonly accountKey: Buffer;
|
||||
|
||||
/**
|
||||
* Creates an instance of StorageSharedKeyCredential.
|
||||
* @param accountName -
|
||||
* @param accountKey -
|
||||
*/
|
||||
constructor(accountName: string, accountKey: string) {
|
||||
super();
|
||||
this.accountName = accountName;
|
||||
this.accountKey = Buffer.from(accountKey, "base64");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link StorageSharedKeyCredentialPolicy} object.
|
||||
*
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
public create(
|
||||
nextPolicy: RequestPolicy,
|
||||
options: RequestPolicyOptions
|
||||
): StorageSharedKeyCredentialPolicy {
|
||||
return new StorageSharedKeyCredentialPolicy(nextPolicy, options, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a hash signature for an HTTP request or for a SAS.
|
||||
*
|
||||
* @param stringToSign -
|
||||
*/
|
||||
public computeHMACSHA256(stringToSign: string): string {
|
||||
return createHmac("sha256", this.accountKey).update(stringToSign, "utf8").digest("base64");
|
||||
}
|
||||
}
|
|
@ -8,4 +8,4 @@
|
|||
|
||||
export * from "./models";
|
||||
export { StorageClient } from "./storageClient";
|
||||
export { StorageClientContext } from "./storageClientContext";
|
||||
export * from "./operationsInterfaces";
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -9,9 +9,8 @@
|
|||
import {
|
||||
OperationParameter,
|
||||
OperationURLParameter,
|
||||
OperationQueryParameter,
|
||||
QueryCollectionFormat
|
||||
} from "@azure/core-http";
|
||||
OperationQueryParameter
|
||||
} from "@azure/core-client";
|
||||
import {
|
||||
FileServiceProperties as FileServicePropertiesMapper,
|
||||
SharePermission as SharePermissionMapper
|
||||
|
@ -185,7 +184,7 @@ export const include: OperationQueryParameter = {
|
|||
}
|
||||
}
|
||||
},
|
||||
collectionFormat: QueryCollectionFormat.Csv
|
||||
collectionFormat: "CSV"
|
||||
};
|
||||
|
||||
export const restype1: OperationQueryParameter = {
|
||||
|
@ -205,11 +204,11 @@ export const metadata: OperationParameter = {
|
|||
mapper: {
|
||||
serializedName: "x-ms-meta",
|
||||
xmlName: "x-ms-meta",
|
||||
headerCollectionPrefix: "x-ms-meta-",
|
||||
type: {
|
||||
name: "Dictionary",
|
||||
value: { type: { name: "String" } }
|
||||
},
|
||||
headerCollectionPrefix: "x-ms-meta-"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -436,6 +435,18 @@ export const comp3: OperationQueryParameter = {
|
|||
}
|
||||
};
|
||||
|
||||
export const contentType1: OperationParameter = {
|
||||
parameterPath: ["options", "contentType"],
|
||||
mapper: {
|
||||
defaultValue: "application/json",
|
||||
isConstant: true,
|
||||
serializedName: "Content-Type",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const sharePermission: OperationParameter = {
|
||||
parameterPath: "sharePermission",
|
||||
mapper: SharePermissionMapper
|
||||
|
@ -661,7 +672,7 @@ export const include1: OperationQueryParameter = {
|
|||
}
|
||||
}
|
||||
},
|
||||
collectionFormat: QueryCollectionFormat.Csv
|
||||
collectionFormat: "CSV"
|
||||
};
|
||||
|
||||
export const includeExtendedInfo: OperationParameter = {
|
||||
|
@ -961,7 +972,7 @@ export const fileContentLength1: OperationParameter = {
|
|||
}
|
||||
};
|
||||
|
||||
export const contentType1: OperationParameter = {
|
||||
export const contentType2: OperationParameter = {
|
||||
parameterPath: ["options", "contentType"],
|
||||
mapper: {
|
||||
defaultValue: "application/octet-stream",
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import * as coreHttp from "@azure/core-http";
|
||||
import { Directory } from "../operationsInterfaces";
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import * as Mappers from "../models/mappers";
|
||||
import * as Parameters from "../models/parameters";
|
||||
import { StorageClientContext } from "../storageClientContext";
|
||||
import { StorageClient } from "../storageClient";
|
||||
import {
|
||||
DirectoryCreateOptionalParams,
|
||||
DirectoryCreateResponse,
|
||||
|
@ -31,15 +32,15 @@ import {
|
|||
DirectoryRenameResponse
|
||||
} from "../models";
|
||||
|
||||
/** Class representing a Directory. */
|
||||
export class Directory {
|
||||
private readonly client: StorageClientContext;
|
||||
/** Class containing Directory operations. */
|
||||
export class DirectoryImpl implements Directory {
|
||||
private readonly client: StorageClient;
|
||||
|
||||
/**
|
||||
* Initialize a new instance of the class Directory class.
|
||||
* @param client Reference to the service client
|
||||
*/
|
||||
constructor(client: StorageClientContext) {
|
||||
constructor(client: StorageClient) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
@ -53,14 +54,10 @@ export class Directory {
|
|||
fileAttributes: string,
|
||||
options?: DirectoryCreateOptionalParams
|
||||
): Promise<DirectoryCreateResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
fileAttributes,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ fileAttributes, options },
|
||||
createOperationSpec
|
||||
) as Promise<DirectoryCreateResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,13 +69,10 @@ export class Directory {
|
|||
getProperties(
|
||||
options?: DirectoryGetPropertiesOptionalParams
|
||||
): Promise<DirectoryGetPropertiesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
getPropertiesOperationSpec
|
||||
) as Promise<DirectoryGetPropertiesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,13 +83,7 @@ export class Directory {
|
|||
delete(
|
||||
options?: DirectoryDeleteOptionalParams
|
||||
): Promise<DirectoryDeleteResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
deleteOperationSpec
|
||||
) as Promise<DirectoryDeleteResponse>;
|
||||
return this.client.sendOperationRequest({ options }, deleteOperationSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,14 +96,10 @@ export class Directory {
|
|||
fileAttributes: string,
|
||||
options?: DirectorySetPropertiesOptionalParams
|
||||
): Promise<DirectorySetPropertiesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
fileAttributes,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ fileAttributes, options },
|
||||
setPropertiesOperationSpec
|
||||
) as Promise<DirectorySetPropertiesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,13 +109,10 @@ export class Directory {
|
|||
setMetadata(
|
||||
options?: DirectorySetMetadataOptionalParams
|
||||
): Promise<DirectorySetMetadataResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
setMetadataOperationSpec
|
||||
) as Promise<DirectorySetMetadataResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,13 +123,10 @@ export class Directory {
|
|||
listFilesAndDirectoriesSegment(
|
||||
options?: DirectoryListFilesAndDirectoriesSegmentOptionalParams
|
||||
): Promise<DirectoryListFilesAndDirectoriesSegmentResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
listFilesAndDirectoriesSegmentOperationSpec
|
||||
) as Promise<DirectoryListFilesAndDirectoriesSegmentResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,13 +136,10 @@ export class Directory {
|
|||
listHandles(
|
||||
options?: DirectoryListHandlesOptionalParams
|
||||
): Promise<DirectoryListHandlesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
listHandlesOperationSpec
|
||||
) as Promise<DirectoryListHandlesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,14 +152,10 @@ export class Directory {
|
|||
handleId: string,
|
||||
options?: DirectoryForceCloseHandlesOptionalParams
|
||||
): Promise<DirectoryForceCloseHandlesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
handleId,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ handleId, options },
|
||||
forceCloseHandlesOperationSpec
|
||||
) as Promise<DirectoryForceCloseHandlesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,20 +167,16 @@ export class Directory {
|
|||
renameSource: string,
|
||||
options?: DirectoryRenameOptionalParams
|
||||
): Promise<DirectoryRenameResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
renameSource,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ renameSource, options },
|
||||
renameOperationSpec
|
||||
) as Promise<DirectoryRenameResponse>;
|
||||
);
|
||||
}
|
||||
}
|
||||
// Operation Specifications
|
||||
const xmlSerializer = new coreHttp.Serializer(Mappers, /* isXml */ true);
|
||||
const xmlSerializer = coreClient.createSerializer(Mappers, /* isXml */ true);
|
||||
|
||||
const createOperationSpec: coreHttp.OperationSpec = {
|
||||
const createOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -237,7 +204,7 @@ const createOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const getPropertiesOperationSpec: coreHttp.OperationSpec = {
|
||||
const getPropertiesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -259,7 +226,7 @@ const getPropertiesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const deleteOperationSpec: coreHttp.OperationSpec = {
|
||||
const deleteOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}",
|
||||
httpMethod: "DELETE",
|
||||
responses: {
|
||||
|
@ -277,7 +244,7 @@ const deleteOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const setPropertiesOperationSpec: coreHttp.OperationSpec = {
|
||||
const setPropertiesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -308,7 +275,7 @@ const setPropertiesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const setMetadataOperationSpec: coreHttp.OperationSpec = {
|
||||
const setMetadataOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -334,7 +301,7 @@ const setMetadataOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const listFilesAndDirectoriesSegmentOperationSpec: coreHttp.OperationSpec = {
|
||||
const listFilesAndDirectoriesSegmentOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -367,7 +334,7 @@ const listFilesAndDirectoriesSegmentOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const listHandlesOperationSpec: coreHttp.OperationSpec = {
|
||||
const listHandlesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -396,7 +363,7 @@ const listHandlesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const forceCloseHandlesOperationSpec: coreHttp.OperationSpec = {
|
||||
const forceCloseHandlesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -424,7 +391,7 @@ const forceCloseHandlesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const renameOperationSpec: coreHttp.OperationSpec = {
|
||||
const renameOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import * as coreHttp from "@azure/core-http";
|
||||
import { File } from "../operationsInterfaces";
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import * as Mappers from "../models/mappers";
|
||||
import * as Parameters from "../models/parameters";
|
||||
import { StorageClientContext } from "../storageClientContext";
|
||||
import { StorageClient } from "../storageClient";
|
||||
import {
|
||||
FileCreateOptionalParams,
|
||||
FileCreateResponse,
|
||||
|
@ -50,15 +51,15 @@ import {
|
|||
FileRenameResponse
|
||||
} from "../models";
|
||||
|
||||
/** Class representing a File. */
|
||||
export class File {
|
||||
private readonly client: StorageClientContext;
|
||||
/** Class containing File operations. */
|
||||
export class FileImpl implements File {
|
||||
private readonly client: StorageClient;
|
||||
|
||||
/**
|
||||
* Initialize a new instance of the class File class.
|
||||
* @param client Reference to the service client
|
||||
*/
|
||||
constructor(client: StorageClientContext) {
|
||||
constructor(client: StorageClient) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
@ -74,15 +75,10 @@ export class File {
|
|||
fileAttributes: string,
|
||||
options?: FileCreateOptionalParams
|
||||
): Promise<FileCreateResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
fileContentLength,
|
||||
fileAttributes,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ fileContentLength, fileAttributes, options },
|
||||
createOperationSpec
|
||||
) as Promise<FileCreateResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,13 +88,7 @@ export class File {
|
|||
download(
|
||||
options?: FileDownloadOptionalParams
|
||||
): Promise<FileDownloadResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
downloadOperationSpec
|
||||
) as Promise<FileDownloadResponse>;
|
||||
return this.client.sendOperationRequest({ options }, downloadOperationSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,13 +99,10 @@ export class File {
|
|||
getProperties(
|
||||
options?: FileGetPropertiesOptionalParams
|
||||
): Promise<FileGetPropertiesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
getPropertiesOperationSpec
|
||||
) as Promise<FileGetPropertiesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,13 +110,7 @@ export class File {
|
|||
* @param options The options parameters.
|
||||
*/
|
||||
delete(options?: FileDeleteOptionalParams): Promise<FileDeleteResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
deleteOperationSpec
|
||||
) as Promise<FileDeleteResponse>;
|
||||
return this.client.sendOperationRequest({ options }, deleteOperationSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,14 +123,10 @@ export class File {
|
|||
fileAttributes: string,
|
||||
options?: FileSetHttpHeadersOptionalParams
|
||||
): Promise<FileSetHttpHeadersResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
fileAttributes,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ fileAttributes, options },
|
||||
setHttpHeadersOperationSpec
|
||||
) as Promise<FileSetHttpHeadersResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,13 +136,10 @@ export class File {
|
|||
setMetadata(
|
||||
options?: FileSetMetadataOptionalParams
|
||||
): Promise<FileSetMetadataResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
setMetadataOperationSpec
|
||||
) as Promise<FileSetMetadataResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,13 +150,10 @@ export class File {
|
|||
acquireLease(
|
||||
options?: FileAcquireLeaseOptionalParams
|
||||
): Promise<FileAcquireLeaseResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
acquireLeaseOperationSpec
|
||||
) as Promise<FileAcquireLeaseResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,14 +166,10 @@ export class File {
|
|||
leaseId: string,
|
||||
options?: FileReleaseLeaseOptionalParams
|
||||
): Promise<FileReleaseLeaseResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
leaseId,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ leaseId, options },
|
||||
releaseLeaseOperationSpec
|
||||
) as Promise<FileReleaseLeaseResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,14 +182,10 @@ export class File {
|
|||
leaseId: string,
|
||||
options?: FileChangeLeaseOptionalParams
|
||||
): Promise<FileChangeLeaseResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
leaseId,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ leaseId, options },
|
||||
changeLeaseOperationSpec
|
||||
) as Promise<FileChangeLeaseResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,13 +196,10 @@ export class File {
|
|||
breakLease(
|
||||
options?: FileBreakLeaseOptionalParams
|
||||
): Promise<FileBreakLeaseResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
breakLeaseOperationSpec
|
||||
) as Promise<FileBreakLeaseResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,16 +224,10 @@ export class File {
|
|||
contentLength: number,
|
||||
options?: FileUploadRangeOptionalParams
|
||||
): Promise<FileUploadRangeResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
range,
|
||||
fileRangeWrite,
|
||||
contentLength,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ range, fileRangeWrite, contentLength, options },
|
||||
uploadRangeOperationSpec
|
||||
) as Promise<FileUploadRangeResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -295,16 +249,10 @@ export class File {
|
|||
contentLength: number,
|
||||
options?: FileUploadRangeFromURLOptionalParams
|
||||
): Promise<FileUploadRangeFromURLResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
range,
|
||||
copySource,
|
||||
contentLength,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ range, copySource, contentLength, options },
|
||||
uploadRangeFromURLOperationSpec
|
||||
) as Promise<FileUploadRangeFromURLResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -314,13 +262,10 @@ export class File {
|
|||
getRangeList(
|
||||
options?: FileGetRangeListOptionalParams
|
||||
): Promise<FileGetRangeListResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
getRangeListOperationSpec
|
||||
) as Promise<FileGetRangeListResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -337,14 +282,10 @@ export class File {
|
|||
copySource: string,
|
||||
options?: FileStartCopyOptionalParams
|
||||
): Promise<FileStartCopyResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
copySource,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ copySource, options },
|
||||
startCopyOperationSpec
|
||||
) as Promise<FileStartCopyResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -358,14 +299,10 @@ export class File {
|
|||
copyId: string,
|
||||
options?: FileAbortCopyOptionalParams
|
||||
): Promise<FileAbortCopyResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
copyId,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ copyId, options },
|
||||
abortCopyOperationSpec
|
||||
) as Promise<FileAbortCopyResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -375,13 +312,10 @@ export class File {
|
|||
listHandles(
|
||||
options?: FileListHandlesOptionalParams
|
||||
): Promise<FileListHandlesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
listHandlesOperationSpec
|
||||
) as Promise<FileListHandlesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -394,14 +328,10 @@ export class File {
|
|||
handleId: string,
|
||||
options?: FileForceCloseHandlesOptionalParams
|
||||
): Promise<FileForceCloseHandlesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
handleId,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ handleId, options },
|
||||
forceCloseHandlesOperationSpec
|
||||
) as Promise<FileForceCloseHandlesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -413,20 +343,16 @@ export class File {
|
|||
renameSource: string,
|
||||
options?: FileRenameOptionalParams
|
||||
): Promise<FileRenameResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
renameSource,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ renameSource, options },
|
||||
renameOperationSpec
|
||||
) as Promise<FileRenameResponse>;
|
||||
);
|
||||
}
|
||||
}
|
||||
// Operation Specifications
|
||||
const xmlSerializer = new coreHttp.Serializer(Mappers, /* isXml */ true);
|
||||
const xmlSerializer = coreClient.createSerializer(Mappers, /* isXml */ true);
|
||||
|
||||
const createOperationSpec: coreHttp.OperationSpec = {
|
||||
const createOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -463,7 +389,7 @@ const createOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const downloadOperationSpec: coreHttp.OperationSpec = {
|
||||
const downloadOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -498,7 +424,7 @@ const downloadOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const getPropertiesOperationSpec: coreHttp.OperationSpec = {
|
||||
const getPropertiesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "HEAD",
|
||||
responses: {
|
||||
|
@ -520,7 +446,7 @@ const getPropertiesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const deleteOperationSpec: coreHttp.OperationSpec = {
|
||||
const deleteOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "DELETE",
|
||||
responses: {
|
||||
|
@ -542,7 +468,7 @@ const deleteOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const setHttpHeadersOperationSpec: coreHttp.OperationSpec = {
|
||||
const setHttpHeadersOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -577,7 +503,7 @@ const setHttpHeadersOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const setMetadataOperationSpec: coreHttp.OperationSpec = {
|
||||
const setMetadataOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -600,7 +526,7 @@ const setMetadataOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const acquireLeaseOperationSpec: coreHttp.OperationSpec = {
|
||||
const acquireLeaseOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -625,7 +551,7 @@ const acquireLeaseOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const releaseLeaseOperationSpec: coreHttp.OperationSpec = {
|
||||
const releaseLeaseOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -649,7 +575,7 @@ const releaseLeaseOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const changeLeaseOperationSpec: coreHttp.OperationSpec = {
|
||||
const changeLeaseOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -674,7 +600,7 @@ const changeLeaseOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const breakLeaseOperationSpec: coreHttp.OperationSpec = {
|
||||
const breakLeaseOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -698,7 +624,7 @@ const breakLeaseOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const uploadRangeOperationSpec: coreHttp.OperationSpec = {
|
||||
const uploadRangeOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -716,19 +642,20 @@ const uploadRangeOperationSpec: coreHttp.OperationSpec = {
|
|||
headerParameters: [
|
||||
Parameters.version,
|
||||
Parameters.leaseId,
|
||||
Parameters.contentType1,
|
||||
Parameters.contentType2,
|
||||
Parameters.accept3,
|
||||
Parameters.range1,
|
||||
Parameters.fileRangeWrite,
|
||||
Parameters.contentLength,
|
||||
Parameters.contentMD5,
|
||||
Parameters.fileLastWrittenMode
|
||||
],
|
||||
contentType: "application/octet-stream",
|
||||
],
|
||||
isXML: true,
|
||||
contentType: "application/xml; charset=utf-8",
|
||||
mediaType: "binary",
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const uploadRangeFromURLOperationSpec: coreHttp.OperationSpec = {
|
||||
const uploadRangeFromURLOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -760,7 +687,7 @@ const uploadRangeFromURLOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const getRangeListOperationSpec: coreHttp.OperationSpec = {
|
||||
const getRangeListOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -789,7 +716,7 @@ const getRangeListOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const startCopyOperationSpec: coreHttp.OperationSpec = {
|
||||
const startCopyOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -822,7 +749,7 @@ const startCopyOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const abortCopyOperationSpec: coreHttp.OperationSpec = {
|
||||
const abortCopyOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -849,7 +776,7 @@ const abortCopyOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const listHandlesOperationSpec: coreHttp.OperationSpec = {
|
||||
const listHandlesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -874,7 +801,7 @@ const listHandlesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const forceCloseHandlesOperationSpec: coreHttp.OperationSpec = {
|
||||
const forceCloseHandlesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -901,7 +828,7 @@ const forceCloseHandlesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const renameOperationSpec: coreHttp.OperationSpec = {
|
||||
const renameOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}/{directory}/{fileName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import * as coreHttp from "@azure/core-http";
|
||||
import { Service } from "../operationsInterfaces";
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import * as Mappers from "../models/mappers";
|
||||
import * as Parameters from "../models/parameters";
|
||||
import { StorageClientContext } from "../storageClientContext";
|
||||
import { StorageClient } from "../storageClient";
|
||||
import {
|
||||
FileServiceProperties,
|
||||
ServiceSetPropertiesOptionalParams,
|
||||
|
@ -20,15 +21,15 @@ import {
|
|||
ServiceListSharesSegmentResponse
|
||||
} from "../models";
|
||||
|
||||
/** Class representing a Service. */
|
||||
export class Service {
|
||||
private readonly client: StorageClientContext;
|
||||
/** Class containing Service operations. */
|
||||
export class ServiceImpl implements Service {
|
||||
private readonly client: StorageClient;
|
||||
|
||||
/**
|
||||
* Initialize a new instance of the class Service class.
|
||||
* @param client Reference to the service client
|
||||
*/
|
||||
constructor(client: StorageClientContext) {
|
||||
constructor(client: StorageClient) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
@ -42,14 +43,10 @@ export class Service {
|
|||
properties: FileServiceProperties,
|
||||
options?: ServiceSetPropertiesOptionalParams
|
||||
): Promise<ServiceSetPropertiesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
properties,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ properties, options },
|
||||
setPropertiesOperationSpec
|
||||
) as Promise<ServiceSetPropertiesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,13 +57,10 @@ export class Service {
|
|||
getProperties(
|
||||
options?: ServiceGetPropertiesOptionalParams
|
||||
): Promise<ServiceGetPropertiesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
getPropertiesOperationSpec
|
||||
) as Promise<ServiceGetPropertiesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,19 +71,16 @@ export class Service {
|
|||
listSharesSegment(
|
||||
options?: ServiceListSharesSegmentOptionalParams
|
||||
): Promise<ServiceListSharesSegmentResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
listSharesSegmentOperationSpec
|
||||
) as Promise<ServiceListSharesSegmentResponse>;
|
||||
);
|
||||
}
|
||||
}
|
||||
// Operation Specifications
|
||||
const xmlSerializer = new coreHttp.Serializer(Mappers, /* isXml */ true);
|
||||
const xmlSerializer = coreClient.createSerializer(Mappers, /* isXml */ true);
|
||||
|
||||
const setPropertiesOperationSpec: coreHttp.OperationSpec = {
|
||||
const setPropertiesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -118,7 +109,7 @@ const setPropertiesOperationSpec: coreHttp.OperationSpec = {
|
|||
mediaType: "xml",
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const getPropertiesOperationSpec: coreHttp.OperationSpec = {
|
||||
const getPropertiesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -141,7 +132,7 @@ const getPropertiesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const listSharesSegmentOperationSpec: coreHttp.OperationSpec = {
|
||||
const listSharesSegmentOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import * as coreHttp from "@azure/core-http";
|
||||
import { Share } from "../operationsInterfaces";
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import * as Mappers from "../models/mappers";
|
||||
import * as Parameters from "../models/parameters";
|
||||
import { StorageClientContext } from "../storageClientContext";
|
||||
import { StorageClient } from "../storageClient";
|
||||
import {
|
||||
ShareCreateOptionalParams,
|
||||
ShareCreateResponse,
|
||||
|
@ -48,15 +49,15 @@ import {
|
|||
ShareRestoreResponse
|
||||
} from "../models";
|
||||
|
||||
/** Class representing a Share. */
|
||||
export class Share {
|
||||
private readonly client: StorageClientContext;
|
||||
/** Class containing Share operations. */
|
||||
export class ShareImpl implements Share {
|
||||
private readonly client: StorageClient;
|
||||
|
||||
/**
|
||||
* Initialize a new instance of the class Share class.
|
||||
* @param client Reference to the service client
|
||||
*/
|
||||
constructor(client: StorageClientContext) {
|
||||
constructor(client: StorageClient) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
@ -66,13 +67,7 @@ export class Share {
|
|||
* @param options The options parameters.
|
||||
*/
|
||||
create(options?: ShareCreateOptionalParams): Promise<ShareCreateResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
createOperationSpec
|
||||
) as Promise<ShareCreateResponse>;
|
||||
return this.client.sendOperationRequest({ options }, createOperationSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,13 +78,10 @@ export class Share {
|
|||
getProperties(
|
||||
options?: ShareGetPropertiesOptionalParams
|
||||
): Promise<ShareGetPropertiesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
getPropertiesOperationSpec
|
||||
) as Promise<ShareGetPropertiesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,13 +90,7 @@ export class Share {
|
|||
* @param options The options parameters.
|
||||
*/
|
||||
delete(options?: ShareDeleteOptionalParams): Promise<ShareDeleteResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
deleteOperationSpec
|
||||
) as Promise<ShareDeleteResponse>;
|
||||
return this.client.sendOperationRequest({ options }, deleteOperationSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,13 +101,10 @@ export class Share {
|
|||
acquireLease(
|
||||
options?: ShareAcquireLeaseOptionalParams
|
||||
): Promise<ShareAcquireLeaseResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
acquireLeaseOperationSpec
|
||||
) as Promise<ShareAcquireLeaseResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,14 +117,10 @@ export class Share {
|
|||
leaseId: string,
|
||||
options?: ShareReleaseLeaseOptionalParams
|
||||
): Promise<ShareReleaseLeaseResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
leaseId,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ leaseId, options },
|
||||
releaseLeaseOperationSpec
|
||||
) as Promise<ShareReleaseLeaseResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,14 +133,10 @@ export class Share {
|
|||
leaseId: string,
|
||||
options?: ShareChangeLeaseOptionalParams
|
||||
): Promise<ShareChangeLeaseResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
leaseId,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ leaseId, options },
|
||||
changeLeaseOperationSpec
|
||||
) as Promise<ShareChangeLeaseResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,14 +149,10 @@ export class Share {
|
|||
leaseId: string,
|
||||
options?: ShareRenewLeaseOptionalParams
|
||||
): Promise<ShareRenewLeaseResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
leaseId,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ leaseId, options },
|
||||
renewLeaseOperationSpec
|
||||
) as Promise<ShareRenewLeaseResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -192,13 +163,10 @@ export class Share {
|
|||
breakLease(
|
||||
options?: ShareBreakLeaseOptionalParams
|
||||
): Promise<ShareBreakLeaseResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
breakLeaseOperationSpec
|
||||
) as Promise<ShareBreakLeaseResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,13 +176,10 @@ export class Share {
|
|||
createSnapshot(
|
||||
options?: ShareCreateSnapshotOptionalParams
|
||||
): Promise<ShareCreateSnapshotResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
createSnapshotOperationSpec
|
||||
) as Promise<ShareCreateSnapshotResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,14 +191,10 @@ export class Share {
|
|||
sharePermission: SharePermission,
|
||||
options?: ShareCreatePermissionOptionalParams
|
||||
): Promise<ShareCreatePermissionResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
sharePermission,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ sharePermission, options },
|
||||
createPermissionOperationSpec
|
||||
) as Promise<ShareCreatePermissionResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,14 +206,10 @@ export class Share {
|
|||
filePermissionKey: string,
|
||||
options?: ShareGetPermissionOptionalParams
|
||||
): Promise<ShareGetPermissionResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
filePermissionKey,
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ filePermissionKey, options },
|
||||
getPermissionOperationSpec
|
||||
) as Promise<ShareGetPermissionResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,13 +219,10 @@ export class Share {
|
|||
setProperties(
|
||||
options?: ShareSetPropertiesOptionalParams
|
||||
): Promise<ShareSetPropertiesResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
setPropertiesOperationSpec
|
||||
) as Promise<ShareSetPropertiesResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,13 +232,10 @@ export class Share {
|
|||
setMetadata(
|
||||
options?: ShareSetMetadataOptionalParams
|
||||
): Promise<ShareSetMetadataResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
setMetadataOperationSpec
|
||||
) as Promise<ShareSetMetadataResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,13 +245,10 @@ export class Share {
|
|||
getAccessPolicy(
|
||||
options?: ShareGetAccessPolicyOptionalParams
|
||||
): Promise<ShareGetAccessPolicyResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
getAccessPolicyOperationSpec
|
||||
) as Promise<ShareGetAccessPolicyResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -310,13 +258,10 @@ export class Share {
|
|||
setAccessPolicy(
|
||||
options?: ShareSetAccessPolicyOptionalParams
|
||||
): Promise<ShareSetAccessPolicyResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
setAccessPolicyOperationSpec
|
||||
) as Promise<ShareSetAccessPolicyResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -326,13 +271,10 @@ export class Share {
|
|||
getStatistics(
|
||||
options?: ShareGetStatisticsOptionalParams
|
||||
): Promise<ShareGetStatisticsResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
{ options },
|
||||
getStatisticsOperationSpec
|
||||
) as Promise<ShareGetStatisticsResponse>;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,21 +282,15 @@ export class Share {
|
|||
* @param options The options parameters.
|
||||
*/
|
||||
restore(options?: ShareRestoreOptionalParams): Promise<ShareRestoreResponse> {
|
||||
const operationArguments: coreHttp.OperationArguments = {
|
||||
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
||||
};
|
||||
return this.client.sendOperationRequest(
|
||||
operationArguments,
|
||||
restoreOperationSpec
|
||||
) as Promise<ShareRestoreResponse>;
|
||||
return this.client.sendOperationRequest({ options }, restoreOperationSpec);
|
||||
}
|
||||
}
|
||||
// Operation Specifications
|
||||
const xmlSerializer = new coreHttp.Serializer(Mappers, /* isXml */ true);
|
||||
const xmlSerializer = coreClient.createSerializer(Mappers, /* isXml */ true);
|
||||
|
||||
const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false);
|
||||
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
|
||||
|
||||
const createOperationSpec: coreHttp.OperationSpec = {
|
||||
const createOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -380,7 +316,7 @@ const createOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const getPropertiesOperationSpec: coreHttp.OperationSpec = {
|
||||
const getPropertiesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -406,7 +342,7 @@ const getPropertiesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const deleteOperationSpec: coreHttp.OperationSpec = {
|
||||
const deleteOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "DELETE",
|
||||
responses: {
|
||||
|
@ -433,7 +369,7 @@ const deleteOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const acquireLeaseOperationSpec: coreHttp.OperationSpec = {
|
||||
const acquireLeaseOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -463,7 +399,7 @@ const acquireLeaseOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const releaseLeaseOperationSpec: coreHttp.OperationSpec = {
|
||||
const releaseLeaseOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -492,7 +428,7 @@ const releaseLeaseOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const changeLeaseOperationSpec: coreHttp.OperationSpec = {
|
||||
const changeLeaseOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -522,7 +458,7 @@ const changeLeaseOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const renewLeaseOperationSpec: coreHttp.OperationSpec = {
|
||||
const renewLeaseOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -551,7 +487,7 @@ const renewLeaseOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const breakLeaseOperationSpec: coreHttp.OperationSpec = {
|
||||
const breakLeaseOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -581,7 +517,7 @@ const breakLeaseOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const createSnapshotOperationSpec: coreHttp.OperationSpec = {
|
||||
const createSnapshotOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -607,7 +543,7 @@ const createSnapshotOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const createPermissionOperationSpec: coreHttp.OperationSpec = {
|
||||
const createPermissionOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -627,15 +563,14 @@ const createPermissionOperationSpec: coreHttp.OperationSpec = {
|
|||
],
|
||||
urlParameters: [Parameters.url],
|
||||
headerParameters: [
|
||||
Parameters.contentType,
|
||||
Parameters.accept,
|
||||
Parameters.version
|
||||
Parameters.version,
|
||||
Parameters.accept1,
|
||||
Parameters.contentType1
|
||||
],
|
||||
isXML: false,
|
||||
contentType: "application/xml; charset=utf-8",
|
||||
serializer: xmlSerializer
|
||||
mediaType: "json",
|
||||
serializer
|
||||
};
|
||||
const getPermissionOperationSpec: coreHttp.OperationSpec = {
|
||||
const getPermissionOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -661,7 +596,7 @@ const getPermissionOperationSpec: coreHttp.OperationSpec = {
|
|||
],
|
||||
serializer
|
||||
};
|
||||
const setPropertiesOperationSpec: coreHttp.OperationSpec = {
|
||||
const setPropertiesOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -690,7 +625,7 @@ const setPropertiesOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const setMetadataOperationSpec: coreHttp.OperationSpec = {
|
||||
const setMetadataOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -717,7 +652,7 @@ const setMetadataOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const getAccessPolicyOperationSpec: coreHttp.OperationSpec = {
|
||||
const getAccessPolicyOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -755,7 +690,7 @@ const getAccessPolicyOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const setAccessPolicyOperationSpec: coreHttp.OperationSpec = {
|
||||
const setAccessPolicyOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
@ -785,7 +720,7 @@ const setAccessPolicyOperationSpec: coreHttp.OperationSpec = {
|
|||
mediaType: "xml",
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const getStatisticsOperationSpec: coreHttp.OperationSpec = {
|
||||
const getStatisticsOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "GET",
|
||||
responses: {
|
||||
|
@ -812,7 +747,7 @@ const getStatisticsOperationSpec: coreHttp.OperationSpec = {
|
|||
isXML: true,
|
||||
serializer: xmlSerializer
|
||||
};
|
||||
const restoreOperationSpec: coreHttp.OperationSpec = {
|
||||
const restoreOperationSpec: coreClient.OperationSpec = {
|
||||
path: "/{shareName}",
|
||||
httpMethod: "PUT",
|
||||
responses: {
|
||||
|
|
110
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/directory.ts
сгенерированный
Normal file
110
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/directory.ts
сгенерированный
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* 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 {
|
||||
DirectoryCreateOptionalParams,
|
||||
DirectoryCreateResponse,
|
||||
DirectoryGetPropertiesOptionalParams,
|
||||
DirectoryGetPropertiesResponse,
|
||||
DirectoryDeleteOptionalParams,
|
||||
DirectoryDeleteResponse,
|
||||
DirectorySetPropertiesOptionalParams,
|
||||
DirectorySetPropertiesResponse,
|
||||
DirectorySetMetadataOptionalParams,
|
||||
DirectorySetMetadataResponse,
|
||||
DirectoryListFilesAndDirectoriesSegmentOptionalParams,
|
||||
DirectoryListFilesAndDirectoriesSegmentResponse,
|
||||
DirectoryListHandlesOptionalParams,
|
||||
DirectoryListHandlesResponse,
|
||||
DirectoryForceCloseHandlesOptionalParams,
|
||||
DirectoryForceCloseHandlesResponse,
|
||||
DirectoryRenameOptionalParams,
|
||||
DirectoryRenameResponse
|
||||
} from "../models";
|
||||
|
||||
/** Interface representing a Directory. */
|
||||
export interface Directory {
|
||||
/**
|
||||
* Creates a new directory under the specified share or parent directory.
|
||||
* @param fileAttributes If specified, the provided file attributes shall be set. Default value:
|
||||
* ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
create(
|
||||
fileAttributes: string,
|
||||
options?: DirectoryCreateOptionalParams
|
||||
): Promise<DirectoryCreateResponse>;
|
||||
/**
|
||||
* Returns all system properties for the specified directory, and can also be used to check the
|
||||
* existence of a directory. The data returned does not include the files in the directory or any
|
||||
* subdirectories.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
getProperties(
|
||||
options?: DirectoryGetPropertiesOptionalParams
|
||||
): Promise<DirectoryGetPropertiesResponse>;
|
||||
/**
|
||||
* Removes the specified empty directory. Note that the directory must be empty before it can be
|
||||
* deleted.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
delete(
|
||||
options?: DirectoryDeleteOptionalParams
|
||||
): Promise<DirectoryDeleteResponse>;
|
||||
/**
|
||||
* Sets properties on the directory.
|
||||
* @param fileAttributes If specified, the provided file attributes shall be set. Default value:
|
||||
* ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
setProperties(
|
||||
fileAttributes: string,
|
||||
options?: DirectorySetPropertiesOptionalParams
|
||||
): Promise<DirectorySetPropertiesResponse>;
|
||||
/**
|
||||
* Updates user defined metadata for the specified directory.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
setMetadata(
|
||||
options?: DirectorySetMetadataOptionalParams
|
||||
): Promise<DirectorySetMetadataResponse>;
|
||||
/**
|
||||
* Returns a list of files or directories under the specified share or directory. It lists the contents
|
||||
* only for a single level of the directory hierarchy.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
listFilesAndDirectoriesSegment(
|
||||
options?: DirectoryListFilesAndDirectoriesSegmentOptionalParams
|
||||
): Promise<DirectoryListFilesAndDirectoriesSegmentResponse>;
|
||||
/**
|
||||
* Lists handles for directory.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
listHandles(
|
||||
options?: DirectoryListHandlesOptionalParams
|
||||
): Promise<DirectoryListHandlesResponse>;
|
||||
/**
|
||||
* Closes all handles open for given directory.
|
||||
* @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is
|
||||
* a wildcard that specifies all handles.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
forceCloseHandles(
|
||||
handleId: string,
|
||||
options?: DirectoryForceCloseHandlesOptionalParams
|
||||
): Promise<DirectoryForceCloseHandlesResponse>;
|
||||
/**
|
||||
* Renames a directory
|
||||
* @param renameSource Required. Specifies the URI-style path of the source file, up to 2 KB in length.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
rename(
|
||||
renameSource: string,
|
||||
options?: DirectoryRenameOptionalParams
|
||||
): Promise<DirectoryRenameResponse>;
|
||||
}
|
233
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/file.ts
сгенерированный
Normal file
233
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/file.ts
сгенерированный
Normal file
|
@ -0,0 +1,233 @@
|
|||
/*
|
||||
* 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 {
|
||||
FileCreateOptionalParams,
|
||||
FileCreateResponse,
|
||||
FileDownloadOptionalParams,
|
||||
FileDownloadResponse,
|
||||
FileGetPropertiesOptionalParams,
|
||||
FileGetPropertiesResponse,
|
||||
FileDeleteOptionalParams,
|
||||
FileDeleteResponse,
|
||||
FileSetHttpHeadersOptionalParams,
|
||||
FileSetHttpHeadersResponse,
|
||||
FileSetMetadataOptionalParams,
|
||||
FileSetMetadataResponse,
|
||||
FileAcquireLeaseOptionalParams,
|
||||
FileAcquireLeaseResponse,
|
||||
FileReleaseLeaseOptionalParams,
|
||||
FileReleaseLeaseResponse,
|
||||
FileChangeLeaseOptionalParams,
|
||||
FileChangeLeaseResponse,
|
||||
FileBreakLeaseOptionalParams,
|
||||
FileBreakLeaseResponse,
|
||||
FileRangeWriteType,
|
||||
FileUploadRangeOptionalParams,
|
||||
FileUploadRangeResponse,
|
||||
FileUploadRangeFromURLOptionalParams,
|
||||
FileUploadRangeFromURLResponse,
|
||||
FileGetRangeListOptionalParams,
|
||||
FileGetRangeListResponse,
|
||||
FileStartCopyOptionalParams,
|
||||
FileStartCopyResponse,
|
||||
FileAbortCopyOptionalParams,
|
||||
FileAbortCopyResponse,
|
||||
FileListHandlesOptionalParams,
|
||||
FileListHandlesResponse,
|
||||
FileForceCloseHandlesOptionalParams,
|
||||
FileForceCloseHandlesResponse,
|
||||
FileRenameOptionalParams,
|
||||
FileRenameResponse
|
||||
} from "../models";
|
||||
|
||||
/** Interface representing a File. */
|
||||
export interface File {
|
||||
/**
|
||||
* Creates a new file or replaces a file. Note it only initializes the file with no content.
|
||||
* @param fileContentLength Specifies the maximum size for the file, up to 4 TB.
|
||||
* @param fileAttributes If specified, the provided file attributes shall be set. Default value:
|
||||
* ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
create(
|
||||
fileContentLength: number,
|
||||
fileAttributes: string,
|
||||
options?: FileCreateOptionalParams
|
||||
): Promise<FileCreateResponse>;
|
||||
/**
|
||||
* Reads or downloads a file from the system, including its metadata and properties.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
download(options?: FileDownloadOptionalParams): Promise<FileDownloadResponse>;
|
||||
/**
|
||||
* Returns all user-defined metadata, standard HTTP properties, and system properties for the file. It
|
||||
* does not return the content of the file.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
getProperties(
|
||||
options?: FileGetPropertiesOptionalParams
|
||||
): Promise<FileGetPropertiesResponse>;
|
||||
/**
|
||||
* removes the file from the storage account.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
delete(options?: FileDeleteOptionalParams): Promise<FileDeleteResponse>;
|
||||
/**
|
||||
* Sets HTTP headers on the file.
|
||||
* @param fileAttributes If specified, the provided file attributes shall be set. Default value:
|
||||
* ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
setHttpHeaders(
|
||||
fileAttributes: string,
|
||||
options?: FileSetHttpHeadersOptionalParams
|
||||
): Promise<FileSetHttpHeadersResponse>;
|
||||
/**
|
||||
* Updates user-defined metadata for the specified file.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
setMetadata(
|
||||
options?: FileSetMetadataOptionalParams
|
||||
): Promise<FileSetMetadataResponse>;
|
||||
/**
|
||||
* [Update] The Lease File operation establishes and manages a lock on a file for write and delete
|
||||
* operations
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
acquireLease(
|
||||
options?: FileAcquireLeaseOptionalParams
|
||||
): Promise<FileAcquireLeaseResponse>;
|
||||
/**
|
||||
* [Update] The Lease File operation establishes and manages a lock on a file for write and delete
|
||||
* operations
|
||||
* @param leaseId Specifies the current lease ID on the resource.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
releaseLease(
|
||||
leaseId: string,
|
||||
options?: FileReleaseLeaseOptionalParams
|
||||
): Promise<FileReleaseLeaseResponse>;
|
||||
/**
|
||||
* [Update] The Lease File operation establishes and manages a lock on a file for write and delete
|
||||
* operations
|
||||
* @param leaseId Specifies the current lease ID on the resource.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
changeLease(
|
||||
leaseId: string,
|
||||
options?: FileChangeLeaseOptionalParams
|
||||
): Promise<FileChangeLeaseResponse>;
|
||||
/**
|
||||
* [Update] The Lease File operation establishes and manages a lock on a file for write and delete
|
||||
* operations
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
breakLease(
|
||||
options?: FileBreakLeaseOptionalParams
|
||||
): Promise<FileBreakLeaseResponse>;
|
||||
/**
|
||||
* Upload a range of bytes to a file.
|
||||
* @param range Specifies the range of bytes to be written. Both the start and end of the range must be
|
||||
* specified. For an update operation, the range can be up to 4 MB in size. For a clear operation, the
|
||||
* range can be up to the value of the file's full size. The File service accepts only a single byte
|
||||
* range for the Range and 'x-ms-range' headers, and the byte range must be specified in the following
|
||||
* format: bytes=startByte-endByte.
|
||||
* @param fileRangeWrite Specify one of the following options: - Update: Writes the bytes specified by
|
||||
* the request body into the specified range. The Range and Content-Length headers must match to
|
||||
* perform the update. - Clear: Clears the specified range and releases the space used in storage for
|
||||
* that range. To clear a range, set the Content-Length header to zero, and set the Range header to a
|
||||
* value that indicates the range to clear, up to maximum file size.
|
||||
* @param contentLength Specifies the number of bytes being transmitted in the request body. When the
|
||||
* x-ms-write header is set to clear, the value of this header must be set to zero.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
uploadRange(
|
||||
range: string,
|
||||
fileRangeWrite: FileRangeWriteType,
|
||||
contentLength: number,
|
||||
options?: FileUploadRangeOptionalParams
|
||||
): Promise<FileUploadRangeResponse>;
|
||||
/**
|
||||
* Upload a range of bytes to a file where the contents are read from a URL.
|
||||
* @param range Writes data to the specified byte range in the file.
|
||||
* @param copySource Specifies the URL of the source file or blob, up to 2 KB in length. To copy a file
|
||||
* to another file within the same storage account, you may use Shared Key to authenticate the source
|
||||
* file. If you are copying a file from another storage account, or if you are copying a blob from the
|
||||
* same storage account or another storage account, then you must authenticate the source file or blob
|
||||
* using a shared access signature. If the source is a public blob, no authentication is required to
|
||||
* perform the copy operation. A file in a share snapshot can also be specified as a copy source.
|
||||
* @param contentLength Specifies the number of bytes being transmitted in the request body. When the
|
||||
* x-ms-write header is set to clear, the value of this header must be set to zero.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
uploadRangeFromURL(
|
||||
range: string,
|
||||
copySource: string,
|
||||
contentLength: number,
|
||||
options?: FileUploadRangeFromURLOptionalParams
|
||||
): Promise<FileUploadRangeFromURLResponse>;
|
||||
/**
|
||||
* Returns the list of valid ranges for a file.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
getRangeList(
|
||||
options?: FileGetRangeListOptionalParams
|
||||
): Promise<FileGetRangeListResponse>;
|
||||
/**
|
||||
* Copies a blob or file to a destination file within the storage account.
|
||||
* @param copySource Specifies the URL of the source file or blob, up to 2 KB in length. To copy a file
|
||||
* to another file within the same storage account, you may use Shared Key to authenticate the source
|
||||
* file. If you are copying a file from another storage account, or if you are copying a blob from the
|
||||
* same storage account or another storage account, then you must authenticate the source file or blob
|
||||
* using a shared access signature. If the source is a public blob, no authentication is required to
|
||||
* perform the copy operation. A file in a share snapshot can also be specified as a copy source.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
startCopy(
|
||||
copySource: string,
|
||||
options?: FileStartCopyOptionalParams
|
||||
): Promise<FileStartCopyResponse>;
|
||||
/**
|
||||
* Aborts a pending Copy File operation, and leaves a destination file with zero length and full
|
||||
* metadata.
|
||||
* @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy File
|
||||
* operation.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
abortCopy(
|
||||
copyId: string,
|
||||
options?: FileAbortCopyOptionalParams
|
||||
): Promise<FileAbortCopyResponse>;
|
||||
/**
|
||||
* Lists handles for file
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
listHandles(
|
||||
options?: FileListHandlesOptionalParams
|
||||
): Promise<FileListHandlesResponse>;
|
||||
/**
|
||||
* Closes all handles open for given file
|
||||
* @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is
|
||||
* a wildcard that specifies all handles.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
forceCloseHandles(
|
||||
handleId: string,
|
||||
options?: FileForceCloseHandlesOptionalParams
|
||||
): Promise<FileForceCloseHandlesResponse>;
|
||||
/**
|
||||
* Renames a file
|
||||
* @param renameSource Required. Specifies the URI-style path of the source file, up to 2 KB in length.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
rename(
|
||||
renameSource: string,
|
||||
options?: FileRenameOptionalParams
|
||||
): Promise<FileRenameResponse>;
|
||||
}
|
12
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/index.ts
сгенерированный
Normal file
12
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/index.ts
сгенерированный
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from "./service";
|
||||
export * from "./share";
|
||||
export * from "./directory";
|
||||
export * from "./file";
|
47
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/service.ts
сгенерированный
Normal file
47
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/service.ts
сгенерированный
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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 {
|
||||
FileServiceProperties,
|
||||
ServiceSetPropertiesOptionalParams,
|
||||
ServiceSetPropertiesResponse,
|
||||
ServiceGetPropertiesOptionalParams,
|
||||
ServiceGetPropertiesResponse,
|
||||
ServiceListSharesSegmentOptionalParams,
|
||||
ServiceListSharesSegmentResponse
|
||||
} from "../models";
|
||||
|
||||
/** Interface representing a Service. */
|
||||
export interface Service {
|
||||
/**
|
||||
* Sets properties for a storage account's File service endpoint, including properties for Storage
|
||||
* Analytics metrics and CORS (Cross-Origin Resource Sharing) rules.
|
||||
* @param properties The StorageService properties.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
setProperties(
|
||||
properties: FileServiceProperties,
|
||||
options?: ServiceSetPropertiesOptionalParams
|
||||
): Promise<ServiceSetPropertiesResponse>;
|
||||
/**
|
||||
* Gets the properties of a storage account's File service, including properties for Storage Analytics
|
||||
* metrics and CORS (Cross-Origin Resource Sharing) rules.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
getProperties(
|
||||
options?: ServiceGetPropertiesOptionalParams
|
||||
): Promise<ServiceGetPropertiesResponse>;
|
||||
/**
|
||||
* The List Shares Segment operation returns a list of the shares and share snapshots under the
|
||||
* specified account.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
listSharesSegment(
|
||||
options?: ServiceListSharesSegmentOptionalParams
|
||||
): Promise<ServiceListSharesSegmentResponse>;
|
||||
}
|
180
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/share.ts
сгенерированный
Normal file
180
sdk/storage/storage-file-share/src/generated/src/operationsInterfaces/share.ts
сгенерированный
Normal file
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* 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 {
|
||||
ShareCreateOptionalParams,
|
||||
ShareCreateResponse,
|
||||
ShareGetPropertiesOptionalParams,
|
||||
ShareGetPropertiesResponse,
|
||||
ShareDeleteOptionalParams,
|
||||
ShareDeleteResponse,
|
||||
ShareAcquireLeaseOptionalParams,
|
||||
ShareAcquireLeaseResponse,
|
||||
ShareReleaseLeaseOptionalParams,
|
||||
ShareReleaseLeaseResponse,
|
||||
ShareChangeLeaseOptionalParams,
|
||||
ShareChangeLeaseResponse,
|
||||
ShareRenewLeaseOptionalParams,
|
||||
ShareRenewLeaseResponse,
|
||||
ShareBreakLeaseOptionalParams,
|
||||
ShareBreakLeaseResponse,
|
||||
ShareCreateSnapshotOptionalParams,
|
||||
ShareCreateSnapshotResponse,
|
||||
SharePermission,
|
||||
ShareCreatePermissionOptionalParams,
|
||||
ShareCreatePermissionResponse,
|
||||
ShareGetPermissionOptionalParams,
|
||||
ShareGetPermissionResponse,
|
||||
ShareSetPropertiesOptionalParams,
|
||||
ShareSetPropertiesResponse,
|
||||
ShareSetMetadataOptionalParams,
|
||||
ShareSetMetadataResponse,
|
||||
ShareGetAccessPolicyOptionalParams,
|
||||
ShareGetAccessPolicyResponse,
|
||||
ShareSetAccessPolicyOptionalParams,
|
||||
ShareSetAccessPolicyResponse,
|
||||
ShareGetStatisticsOptionalParams,
|
||||
ShareGetStatisticsResponse,
|
||||
ShareRestoreOptionalParams,
|
||||
ShareRestoreResponse
|
||||
} from "../models";
|
||||
|
||||
/** Interface representing a Share. */
|
||||
export interface Share {
|
||||
/**
|
||||
* Creates a new share under the specified account. If the share with the same name already exists, the
|
||||
* operation fails.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
create(options?: ShareCreateOptionalParams): Promise<ShareCreateResponse>;
|
||||
/**
|
||||
* Returns all user-defined metadata and system properties for the specified share or share snapshot.
|
||||
* The data returned does not include the share's list of files.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
getProperties(
|
||||
options?: ShareGetPropertiesOptionalParams
|
||||
): Promise<ShareGetPropertiesResponse>;
|
||||
/**
|
||||
* Operation marks the specified share or share snapshot for deletion. The share or share snapshot and
|
||||
* any files contained within it are later deleted during garbage collection.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
delete(options?: ShareDeleteOptionalParams): Promise<ShareDeleteResponse>;
|
||||
/**
|
||||
* The Lease Share operation establishes and manages a lock on a share, or the specified snapshot for
|
||||
* set and delete share operations.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
acquireLease(
|
||||
options?: ShareAcquireLeaseOptionalParams
|
||||
): Promise<ShareAcquireLeaseResponse>;
|
||||
/**
|
||||
* The Lease Share operation establishes and manages a lock on a share, or the specified snapshot for
|
||||
* set and delete share operations.
|
||||
* @param leaseId Specifies the current lease ID on the resource.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
releaseLease(
|
||||
leaseId: string,
|
||||
options?: ShareReleaseLeaseOptionalParams
|
||||
): Promise<ShareReleaseLeaseResponse>;
|
||||
/**
|
||||
* The Lease Share operation establishes and manages a lock on a share, or the specified snapshot for
|
||||
* set and delete share operations.
|
||||
* @param leaseId Specifies the current lease ID on the resource.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
changeLease(
|
||||
leaseId: string,
|
||||
options?: ShareChangeLeaseOptionalParams
|
||||
): Promise<ShareChangeLeaseResponse>;
|
||||
/**
|
||||
* The Lease Share operation establishes and manages a lock on a share, or the specified snapshot for
|
||||
* set and delete share operations.
|
||||
* @param leaseId Specifies the current lease ID on the resource.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
renewLease(
|
||||
leaseId: string,
|
||||
options?: ShareRenewLeaseOptionalParams
|
||||
): Promise<ShareRenewLeaseResponse>;
|
||||
/**
|
||||
* The Lease Share operation establishes and manages a lock on a share, or the specified snapshot for
|
||||
* set and delete share operations.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
breakLease(
|
||||
options?: ShareBreakLeaseOptionalParams
|
||||
): Promise<ShareBreakLeaseResponse>;
|
||||
/**
|
||||
* Creates a read-only snapshot of a share.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
createSnapshot(
|
||||
options?: ShareCreateSnapshotOptionalParams
|
||||
): Promise<ShareCreateSnapshotResponse>;
|
||||
/**
|
||||
* Create a permission (a security descriptor).
|
||||
* @param sharePermission A permission (a security descriptor) at the share level.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
createPermission(
|
||||
sharePermission: SharePermission,
|
||||
options?: ShareCreatePermissionOptionalParams
|
||||
): Promise<ShareCreatePermissionResponse>;
|
||||
/**
|
||||
* Returns the permission (security descriptor) for a given key
|
||||
* @param filePermissionKey Key of the permission to be set for the directory/file.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
getPermission(
|
||||
filePermissionKey: string,
|
||||
options?: ShareGetPermissionOptionalParams
|
||||
): Promise<ShareGetPermissionResponse>;
|
||||
/**
|
||||
* Sets properties for the specified share.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
setProperties(
|
||||
options?: ShareSetPropertiesOptionalParams
|
||||
): Promise<ShareSetPropertiesResponse>;
|
||||
/**
|
||||
* Sets one or more user-defined name-value pairs for the specified share.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
setMetadata(
|
||||
options?: ShareSetMetadataOptionalParams
|
||||
): Promise<ShareSetMetadataResponse>;
|
||||
/**
|
||||
* Returns information about stored access policies specified on the share.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
getAccessPolicy(
|
||||
options?: ShareGetAccessPolicyOptionalParams
|
||||
): Promise<ShareGetAccessPolicyResponse>;
|
||||
/**
|
||||
* Sets a stored access policy for use with shared access signatures.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
setAccessPolicy(
|
||||
options?: ShareSetAccessPolicyOptionalParams
|
||||
): Promise<ShareSetAccessPolicyResponse>;
|
||||
/**
|
||||
* Retrieves statistics related to the share.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
getStatistics(
|
||||
options?: ShareGetStatisticsOptionalParams
|
||||
): Promise<ShareGetStatisticsResponse>;
|
||||
/**
|
||||
* Restores a previously deleted Share.
|
||||
* @param options The options parameters.
|
||||
*/
|
||||
restore(options?: ShareRestoreOptionalParams): Promise<ShareRestoreResponse>;
|
||||
}
|
|
@ -6,11 +6,16 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import { Service, Share, Directory, File } from "./operations";
|
||||
import { StorageClientContext } from "./storageClientContext";
|
||||
import * as coreHttpCompat from "@azure/core-http-compat";
|
||||
import { ServiceImpl, ShareImpl, DirectoryImpl, FileImpl } from "./operations";
|
||||
import { Service, Share, Directory, File } from "./operationsInterfaces";
|
||||
import { StorageClientOptionalParams } from "./models";
|
||||
|
||||
export class StorageClient extends StorageClientContext {
|
||||
export class StorageClient extends coreHttpCompat.ExtendedServiceClient {
|
||||
url: string;
|
||||
version: string;
|
||||
fileRangeWriteFromUrl: string;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the StorageClient class.
|
||||
* @param url The URL of the service account, share, directory or file that is the target of the
|
||||
|
@ -18,11 +23,43 @@ export class StorageClient extends StorageClientContext {
|
|||
* @param options The parameter options
|
||||
*/
|
||||
constructor(url: string, options?: StorageClientOptionalParams) {
|
||||
super(url, options);
|
||||
this.service = new Service(this);
|
||||
this.share = new Share(this);
|
||||
this.directory = new Directory(this);
|
||||
this.file = new File(this);
|
||||
if (url === undefined) {
|
||||
throw new Error("'url' cannot be null");
|
||||
}
|
||||
|
||||
// Initializing default values for options
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
const defaults: StorageClientOptionalParams = {
|
||||
requestContentType: "application/json; charset=utf-8"
|
||||
};
|
||||
|
||||
const packageDetails = `azsdk-js-azure-storage-file-share/12.20.0`;
|
||||
const userAgentPrefix =
|
||||
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
||||
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
||||
: `${packageDetails}`;
|
||||
|
||||
const optionsWithDefaults = {
|
||||
...defaults,
|
||||
...options,
|
||||
userAgentOptions: {
|
||||
userAgentPrefix
|
||||
},
|
||||
endpoint: options.endpoint ?? options.baseUri ?? "{url}"
|
||||
};
|
||||
super(optionsWithDefaults);
|
||||
// Parameter assignments
|
||||
this.url = url;
|
||||
|
||||
// Assigning values to Constant parameters
|
||||
this.version = options.version || "2021-10-04";
|
||||
this.fileRangeWriteFromUrl = options.fileRangeWriteFromUrl || "update";
|
||||
this.service = new ServiceImpl(this);
|
||||
this.share = new ShareImpl(this);
|
||||
this.directory = new DirectoryImpl(this);
|
||||
this.file = new FileImpl(this);
|
||||
}
|
||||
|
||||
service: Service;
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* 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 * as coreHttp from "@azure/core-http";
|
||||
import { StorageClientOptionalParams } from "./models";
|
||||
|
||||
const packageName = "azure-storage-file-share";
|
||||
const packageVersion = "12.13.0";
|
||||
|
||||
export class StorageClientContext extends coreHttp.ServiceClient {
|
||||
url: string;
|
||||
version: string;
|
||||
fileRangeWriteFromUrl: string;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the StorageClientContext class.
|
||||
* @param url The URL of the service account, share, directory or file that is the target of the
|
||||
* desired operation.
|
||||
* @param options The parameter options
|
||||
*/
|
||||
constructor(url: string, options?: StorageClientOptionalParams) {
|
||||
if (url === undefined) {
|
||||
throw new Error("'url' cannot be null");
|
||||
}
|
||||
|
||||
// Initializing default values for options
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (!options.userAgent) {
|
||||
const defaultUserAgent = coreHttp.getDefaultUserAgentValue();
|
||||
options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
|
||||
}
|
||||
|
||||
super(undefined, options);
|
||||
|
||||
this.requestContentType = "application/json; charset=utf-8";
|
||||
|
||||
this.baseUri = options.endpoint || "{url}";
|
||||
|
||||
// Parameter assignments
|
||||
this.url = url;
|
||||
|
||||
// Assigning values to Constant parameters
|
||||
this.version = options.version || "2021-10-04";
|
||||
this.fileRangeWriteFromUrl = options.fileRangeWriteFromUrl || "update";
|
||||
}
|
||||
}
|
|
@ -1,54 +1,234 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
DirectoryCreateHeaders,
|
||||
DirectoryDeleteHeaders,
|
||||
DirectoryGetPropertiesHeaders,
|
||||
DirectoryListFilesAndDirectoriesSegmentHeaders,
|
||||
DirectoryListHandlesHeaders,
|
||||
DirectoryRenameHeaders,
|
||||
DirectorySetMetadataHeaders,
|
||||
DirectorySetPropertiesHeaders,
|
||||
FileAbortCopyHeaders,
|
||||
FileCreateHeaders,
|
||||
FileDeleteHeaders,
|
||||
FileDownloadHeaders,
|
||||
FileDownloadResponse,
|
||||
FileGetPropertiesHeaders,
|
||||
FileGetRangeListHeaders,
|
||||
FileListHandlesHeaders,
|
||||
FileRenameHeaders,
|
||||
FileServiceProperties,
|
||||
FileSetHttpHeadersHeaders,
|
||||
FileSetMetadataHeaders,
|
||||
FileStartCopyHeaders,
|
||||
FileUploadRangeFromURLHeaders,
|
||||
FileUploadRangeHeaders,
|
||||
ListFilesAndDirectoriesSegmentResponse,
|
||||
ListHandlesResponse,
|
||||
ServiceGetPropertiesHeaders,
|
||||
ServiceSetPropertiesHeaders,
|
||||
ShareCreateHeaders,
|
||||
ShareCreatePermissionHeaders,
|
||||
ShareCreateSnapshotHeaders,
|
||||
ShareDeleteHeaders,
|
||||
ShareFileRangeList,
|
||||
ShareGetAccessPolicyHeaders,
|
||||
ShareGetPermissionHeaders,
|
||||
ShareGetPropertiesHeaders,
|
||||
ShareGetStatisticsHeaders,
|
||||
SharePermission,
|
||||
ShareSetAccessPolicyHeaders,
|
||||
ShareSetMetadataHeaders,
|
||||
ShareStats,
|
||||
} from "./generated/src/models";
|
||||
|
||||
/** Contains response data for the create operation. */
|
||||
export type DirectoryCreateResponse = WithResponse<DirectoryCreateHeaders, DirectoryCreateHeaders>;
|
||||
|
||||
/** Contains response data for the delete operation. */
|
||||
export type DirectoryDeleteResponse = WithResponse<DirectoryDeleteHeaders, DirectoryDeleteHeaders>;
|
||||
|
||||
/** Contains response data for the getProperties operation. */
|
||||
export type DirectoryGetPropertiesResponse = WithResponse<
|
||||
DirectoryGetPropertiesHeaders,
|
||||
DirectoryGetPropertiesHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the listFilesAndDirectoriesSegment operation. */
|
||||
export type DirectoryListFilesAndDirectoriesSegmentResponse = WithResponse<
|
||||
DirectoryListFilesAndDirectoriesSegmentHeaders & ListFilesAndDirectoriesSegmentResponse,
|
||||
DirectoryListFilesAndDirectoriesSegmentHeaders,
|
||||
ListFilesAndDirectoriesSegmentResponse
|
||||
>;
|
||||
|
||||
/** Contains response data for the listHandles operation. */
|
||||
export type DirectoryListHandlesResponse = WithResponse<
|
||||
DirectoryListHandlesHeaders & ListHandlesResponse,
|
||||
DirectoryListHandlesHeaders,
|
||||
ListHandlesResponse
|
||||
>;
|
||||
|
||||
/** Contains response data for the setMetadata operation. */
|
||||
export type DirectorySetMetadataResponse = WithResponse<
|
||||
DirectorySetMetadataHeaders,
|
||||
DirectorySetMetadataHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the setProperties operation. */
|
||||
export type DirectorySetPropertiesResponse = WithResponse<
|
||||
DirectorySetPropertiesHeaders,
|
||||
DirectorySetPropertiesHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the abortCopy operation. */
|
||||
export type FileAbortCopyResponse = WithResponse<FileAbortCopyHeaders, FileAbortCopyHeaders>;
|
||||
|
||||
/** Contains response data for the create operation. */
|
||||
export type FileCreateResponse = WithResponse<FileCreateHeaders, FileCreateHeaders>;
|
||||
|
||||
/** Contains response data for the delete operation. */
|
||||
export type FileDeleteResponse = WithResponse<FileDeleteHeaders, FileDeleteHeaders>;
|
||||
|
||||
/** Contains response data for the getProperties operation. */
|
||||
export type FileGetPropertiesResponse = WithResponse<
|
||||
FileGetPropertiesHeaders,
|
||||
FileGetPropertiesHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the listHandles operation. */
|
||||
export type FileListHandlesResponse = WithResponse<
|
||||
FileListHandlesHeaders & ListHandlesResponse,
|
||||
FileListHandlesHeaders,
|
||||
ListHandlesResponse
|
||||
>;
|
||||
|
||||
/** Contains response data for the setMetadata operation. */
|
||||
export type FileSetMetadataResponse = WithResponse<FileSetMetadataHeaders, FileSetMetadataHeaders>;
|
||||
|
||||
/** Contains response data for the startCopy operation. */
|
||||
export type FileStartCopyResponse = WithResponse<FileStartCopyHeaders, FileStartCopyHeaders>;
|
||||
|
||||
/** Contains response data for the uploadRange operation. */
|
||||
export type FileUploadRangeResponse = WithResponse<FileUploadRangeHeaders, FileUploadRangeHeaders>;
|
||||
|
||||
/** Contains response data for the getProperties operation. */
|
||||
export type ServiceGetPropertiesResponse = WithResponse<
|
||||
ServiceGetPropertiesHeaders & FileServiceProperties,
|
||||
ServiceGetPropertiesHeaders,
|
||||
FileServiceProperties
|
||||
>;
|
||||
|
||||
/** Contains response data for the setProperties operation. */
|
||||
export type ServiceSetPropertiesResponse = WithResponse<
|
||||
ServiceSetPropertiesHeaders,
|
||||
ServiceSetPropertiesHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the createPermission operation. */
|
||||
export type ShareCreatePermissionResponse = WithResponse<
|
||||
ShareCreatePermissionHeaders,
|
||||
ShareCreatePermissionHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the create operation. */
|
||||
export type ShareCreateResponse = WithResponse<ShareCreateHeaders, ShareCreateHeaders>;
|
||||
|
||||
/** Contains response data for the createSnapshot operation. */
|
||||
export type ShareCreateSnapshotResponse = WithResponse<
|
||||
ShareCreateSnapshotHeaders,
|
||||
ShareCreateSnapshotHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the delete operation. */
|
||||
export type ShareDeleteResponse = WithResponse<ShareDeleteHeaders, ShareDeleteHeaders>;
|
||||
|
||||
/** Contains response data for the getPermission operation. */
|
||||
export type ShareGetPermissionResponse = WithResponse<
|
||||
ShareGetPermissionHeaders & SharePermission,
|
||||
ShareGetPermissionHeaders,
|
||||
SharePermission
|
||||
>;
|
||||
|
||||
/** Contains response data for the setAccessPolicy operation. */
|
||||
export type ShareSetAccessPolicyResponse = WithResponse<
|
||||
ShareSetAccessPolicyHeaders,
|
||||
ShareGetAccessPolicyHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the setMetadata operation. */
|
||||
export type ShareSetMetadataResponse = WithResponse<
|
||||
ShareSetMetadataHeaders,
|
||||
ShareSetMetadataHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the setProperties operation. */
|
||||
export type ShareSetPropertiesResponse = WithResponse<
|
||||
ShareSetPropertiesHeaders,
|
||||
ShareSetPropertiesHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the rename operation. */
|
||||
export type DirectoryRenameResponse = WithResponse<DirectoryRenameHeaders, DirectoryRenameHeaders>;
|
||||
|
||||
/** Contains response data for the download operation. */
|
||||
export type FileDownloadResponseModel = WithResponse<FileDownloadResponse, FileDownloadHeaders>;
|
||||
|
||||
/** Contains response data for the uploadRangeFromURL operation. */
|
||||
export type FileUploadRangeFromURLResponse = WithResponse<
|
||||
FileUploadRangeFromURLHeaders,
|
||||
FileUploadRangeFromURLHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the getProperties operation. */
|
||||
export type ShareGetPropertiesResponseModel = WithResponse<
|
||||
ShareGetPropertiesHeaders,
|
||||
ShareGetPropertiesHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the getStatistics operation. */
|
||||
export type ShareGetStatisticsResponseModel = WithResponse<
|
||||
ShareGetStatisticsHeaders & ShareStats,
|
||||
ShareGetStatisticsHeaders,
|
||||
ShareStats
|
||||
>;
|
||||
|
||||
/** Contains response data for the getRangeList operation. */
|
||||
export type FileGetRangeListDiffResponse = WithResponse<
|
||||
FileGetRangeListHeaders & ShareFileRangeList,
|
||||
FileGetRangeListHeaders,
|
||||
ShareFileRangeList
|
||||
>;
|
||||
|
||||
/** Contains response data for the setHttpHeaders operation. */
|
||||
export type FileSetHTTPHeadersResponse = WithResponse<
|
||||
FileSetHttpHeadersHeaders,
|
||||
FileSetHttpHeadersHeaders
|
||||
>;
|
||||
|
||||
/** Contains response data for the rename operation. */
|
||||
export type FileRenameResponse = WithResponse<FileRenameHeaders, FileRenameHeaders>;
|
||||
|
||||
// explicitly exporting types that we need.
|
||||
|
||||
export {
|
||||
CopyStatusType,
|
||||
DeleteSnapshotsOptionType,
|
||||
DirectoryCreateResponse,
|
||||
DirectoryDeleteResponse,
|
||||
DirectoryGetPropertiesResponse,
|
||||
DirectoryItem,
|
||||
DirectoryListFilesAndDirectoriesSegmentResponse,
|
||||
DirectoryListHandlesResponse,
|
||||
DirectorySetMetadataResponse,
|
||||
DirectorySetPropertiesResponse,
|
||||
FileAbortCopyResponse,
|
||||
FileCreateResponse,
|
||||
FileDeleteResponse,
|
||||
FileDownloadHeaders,
|
||||
FileDownloadOptionalParams,
|
||||
FileDownloadResponse as FileDownloadResponseModel,
|
||||
FileGetPropertiesResponse,
|
||||
FileGetRangeListHeaders,
|
||||
FileItem,
|
||||
FileLastWrittenMode,
|
||||
FileListHandlesResponse,
|
||||
FileServiceProperties,
|
||||
FileSetMetadataResponse,
|
||||
FileStartCopyResponse,
|
||||
FileUploadRangeFromURLOptionalParams,
|
||||
FileUploadRangeFromURLResponse,
|
||||
FileUploadRangeResponse,
|
||||
PermissionCopyModeType,
|
||||
HandleItem,
|
||||
ListSharesIncludeType,
|
||||
FileRange as RangeModel,
|
||||
ServiceGetPropertiesResponse,
|
||||
ServiceSetPropertiesResponse,
|
||||
ShareCreatePermissionResponse,
|
||||
ShareCreateResponse,
|
||||
ShareCreateSnapshotResponse,
|
||||
ShareDeleteResponse,
|
||||
ShareGetAccessPolicyHeaders,
|
||||
ShareGetPermissionResponse,
|
||||
ShareGetPropertiesResponse as ShareGetPropertiesResponseModel,
|
||||
ShareGetStatisticsResponse as ShareGetStatisticsResponseModel,
|
||||
ShareItemInternal,
|
||||
ShareSetAccessPolicyResponse,
|
||||
ShareSetMetadataResponse,
|
||||
ShareSetPropertiesResponse,
|
||||
SignedIdentifier as SignedIdentifierModel,
|
||||
SourceModifiedAccessConditions,
|
||||
FileForceCloseHandlesHeaders,
|
||||
|
@ -61,7 +241,6 @@ export {
|
|||
DirectoryListFilesAndDirectoriesSegmentHeaders,
|
||||
ListHandlesResponse,
|
||||
DirectoryRenameHeaders,
|
||||
DirectoryRenameResponse,
|
||||
DirectoryListHandlesHeaders,
|
||||
DirectorySetMetadataHeaders,
|
||||
DirectorySetPropertiesHeaders,
|
||||
|
@ -75,10 +254,8 @@ export {
|
|||
CorsRule,
|
||||
Metrics,
|
||||
FileSetHttpHeadersHeaders as FileSetHTTPHeadersHeaders,
|
||||
FileSetHttpHeadersResponse as FileSetHTTPHeadersResponse,
|
||||
FileSetMetadataHeaders,
|
||||
FileStartCopyHeaders,
|
||||
FileRenameResponse,
|
||||
FileUploadRangeFromURLHeaders,
|
||||
FileUploadRangeHeaders,
|
||||
ServiceGetPropertiesHeaders,
|
||||
|
@ -108,19 +285,20 @@ export {
|
|||
ShareProtocolSettings,
|
||||
ShareSmbSettings,
|
||||
SmbMultichannel,
|
||||
FileGetRangeListResponse as FileGetRangeListDiffResponse,
|
||||
ShareFileRangeList,
|
||||
ClearRange,
|
||||
ShareAccessTier,
|
||||
ShareRootSquash,
|
||||
FileDownloadResponse as RawFileDownloadResponse,
|
||||
} from "./generated/src/models";
|
||||
|
||||
import { ShareSetPropertiesResponse, ShareSetPropertiesHeaders } from "./generated/src/models";
|
||||
import { ShareSetPropertiesHeaders } from "./generated/src/models";
|
||||
import { WithResponse } from "./utils/utils.common";
|
||||
|
||||
/**
|
||||
* Contains response data for the setQuota operation.
|
||||
*/
|
||||
export type ShareSetQuotaResponse = ShareSetPropertiesResponse;
|
||||
export type ShareSetQuotaResponse = WithResponse<ShareSetQuotaHeaders, ShareSetQuotaHeaders>;
|
||||
|
||||
/**
|
||||
* Defines headers for setQuota operation.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RestError } from "@azure/core-http";
|
||||
import { RestError } from "@azure/core-rest-pipeline";
|
||||
|
||||
export * from "./Clients";
|
||||
export * from "./credentials/AnonymousCredential";
|
||||
export * from "./credentials/Credential";
|
||||
export * from "../../storage-blob/src/credentials/AnonymousCredential";
|
||||
export * from "../../storage-blob/src/credentials/Credential";
|
||||
export { SasIPRange } from "./SasIPRange";
|
||||
export { Range } from "./Range";
|
||||
export {
|
||||
|
@ -18,13 +18,29 @@ export {
|
|||
HttpAuthorization,
|
||||
} from "./models";
|
||||
export * from "./FileSystemAttributes";
|
||||
export * from "./Pipeline";
|
||||
export * from "./policies/AnonymousCredentialPolicy";
|
||||
export * from "./policies/CredentialPolicy";
|
||||
export * from "./StorageRetryPolicyFactory";
|
||||
export * from "./StorageBrowserPolicyFactory";
|
||||
export {
|
||||
Pipeline,
|
||||
PipelineLike,
|
||||
PipelineOptions,
|
||||
isPipelineLike,
|
||||
newPipeline,
|
||||
StoragePipelineOptions,
|
||||
ServiceClientOptions,
|
||||
} from "../../storage-blob/src/Pipeline";
|
||||
export { BaseRequestPolicy } from "../../storage-blob/src/policies/RequestPolicy";
|
||||
export * from "../../storage-blob/src/policies/AnonymousCredentialPolicy";
|
||||
export * from "../../storage-blob/src/policies/CredentialPolicy";
|
||||
export * from "../../storage-blob/src/StorageRetryPolicyFactory";
|
||||
export * from "../../storage-blob/src/StorageBrowserPolicyFactory";
|
||||
export * from "./ShareServiceClient";
|
||||
export { CommonOptions } from "./StorageClient";
|
||||
export * from "./generatedModels";
|
||||
export {
|
||||
WithResponse,
|
||||
ResponseLike,
|
||||
ResponseWithBody,
|
||||
ResponseWithHeaders,
|
||||
HttpResponse,
|
||||
} from "./utils/utils.common";
|
||||
export { RestError };
|
||||
export { logger } from "./log";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RestError } from "@azure/core-http";
|
||||
import { RestError } from "@azure/core-rest-pipeline";
|
||||
|
||||
export * from "./AccountSASPermissions";
|
||||
export * from "./AccountSASResourceTypes";
|
||||
|
@ -11,9 +11,9 @@ export * from "./FileSASPermissions";
|
|||
export * from "./FileSASSignatureValues";
|
||||
export * from "./Clients";
|
||||
export * from "./ShareSASPermissions";
|
||||
export * from "./credentials/AnonymousCredential";
|
||||
export * from "./credentials/Credential";
|
||||
export * from "./credentials/StorageSharedKeyCredential";
|
||||
export * from "../../storage-blob/src/credentials/AnonymousCredential";
|
||||
export * from "../../storage-blob/src/credentials/Credential";
|
||||
export * from "../../storage-blob/src/credentials/StorageSharedKeyCredential";
|
||||
export { SasIPRange } from "./SasIPRange";
|
||||
export { Range } from "./Range";
|
||||
export {
|
||||
|
@ -31,15 +31,31 @@ export {
|
|||
HttpAuthorization,
|
||||
} from "./models";
|
||||
export * from "./FileSystemAttributes";
|
||||
export * from "./Pipeline";
|
||||
export * from "./policies/AnonymousCredentialPolicy";
|
||||
export * from "./policies/CredentialPolicy";
|
||||
export * from "./StorageRetryPolicyFactory";
|
||||
export * from "./policies/StorageSharedKeyCredentialPolicy";
|
||||
export * from "./StorageBrowserPolicyFactory";
|
||||
export { BaseRequestPolicy } from "../../storage-blob/src/policies/RequestPolicy";
|
||||
export {
|
||||
Pipeline,
|
||||
PipelineLike,
|
||||
PipelineOptions,
|
||||
isPipelineLike,
|
||||
newPipeline,
|
||||
StoragePipelineOptions,
|
||||
ServiceClientOptions,
|
||||
} from "../../storage-blob/src/Pipeline";
|
||||
export * from "../../storage-blob/src/policies/AnonymousCredentialPolicy";
|
||||
export * from "../../storage-blob/src/policies/CredentialPolicy";
|
||||
export * from "../../storage-blob/src/StorageRetryPolicyFactory";
|
||||
export * from "../../storage-blob/src/policies/StorageSharedKeyCredentialPolicy";
|
||||
export * from "../../storage-blob/src/StorageBrowserPolicyFactory";
|
||||
export * from "./ShareServiceClient";
|
||||
export * from "./SASQueryParameters";
|
||||
export { CommonOptions } from "./StorageClient";
|
||||
export * from "./generatedModels";
|
||||
export {
|
||||
WithResponse,
|
||||
ResponseLike,
|
||||
ResponseWithBody,
|
||||
ResponseWithHeaders,
|
||||
HttpResponse,
|
||||
} from "./utils/utils.common";
|
||||
export { RestError };
|
||||
export { logger } from "./log";
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RequestPolicy, RequestPolicyOptions } from "@azure/core-http";
|
||||
|
||||
import { CredentialPolicy } from "./CredentialPolicy";
|
||||
|
||||
/**
|
||||
* AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources
|
||||
* or for use with Shared Access Signatures (SAS).
|
||||
*/
|
||||
export class AnonymousCredentialPolicy extends CredentialPolicy {
|
||||
/**
|
||||
* Creates an instance of AnonymousCredentialPolicy.
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
// The base class has a protected constructor. Adding a public one to enable constructing of this class.
|
||||
/* eslint-disable-next-line @typescript-eslint/no-useless-constructor*/
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) {
|
||||
super(nextPolicy, options);
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { BaseRequestPolicy, HttpOperationResponse, WebResource } from "@azure/core-http";
|
||||
|
||||
/**
|
||||
* Credential policy used to sign HTTP(S) requests before sending. This is an
|
||||
* abstract class.
|
||||
*/
|
||||
export abstract class CredentialPolicy extends BaseRequestPolicy {
|
||||
/**
|
||||
* Sends out request.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
public sendRequest(request: WebResource): Promise<HttpOperationResponse> {
|
||||
return this._nextPolicy.sendRequest(this.signRequest(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Child classes must implement this method with request signing. This method
|
||||
* will be executed in {@link sendRequest}.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
protected signRequest(request: WebResource): WebResource {
|
||||
// Child classes must override this method with request signing. This method
|
||||
// will be executed in sendRequest().
|
||||
return request;
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
BaseRequestPolicy,
|
||||
HttpOperationResponse,
|
||||
isNode,
|
||||
RequestPolicy,
|
||||
RequestPolicyOptions,
|
||||
WebResource,
|
||||
} from "@azure/core-http";
|
||||
|
||||
import { HeaderConstants, URLConstants } from "../utils/constants";
|
||||
import { setURLParameter } from "../utils/utils.common";
|
||||
|
||||
/**
|
||||
* StorageBrowserPolicy will handle differences between Node.js and browser runtime, including:
|
||||
*
|
||||
* 1. Browsers cache GET/HEAD requests by adding conditional headers such as 'IF_MODIFIED_SINCE'.
|
||||
* StorageBrowserPolicy is a policy used to add a timestamp query to GET/HEAD request URL
|
||||
* thus avoid the browser cache.
|
||||
*
|
||||
* 2. Remove cookie header for security
|
||||
*
|
||||
* 3. Remove content-length header to avoid browsers warning
|
||||
*/
|
||||
export class StorageBrowserPolicy extends BaseRequestPolicy {
|
||||
/**
|
||||
* Creates an instance of StorageBrowserPolicy.
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
// The base class has a protected constructor. Adding a public one to enable constructing of this class.
|
||||
/* eslint-disable-next-line @typescript-eslint/no-useless-constructor*/
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) {
|
||||
super(nextPolicy, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends out request.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
public async sendRequest(request: WebResource): Promise<HttpOperationResponse> {
|
||||
if (isNode) {
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
|
||||
if (request.method.toUpperCase() === "GET" || request.method.toUpperCase() === "HEAD") {
|
||||
request.url = setURLParameter(
|
||||
request.url,
|
||||
URLConstants.Parameters.FORCE_BROWSER_NO_CACHE,
|
||||
new Date().getTime().toString()
|
||||
);
|
||||
}
|
||||
|
||||
request.headers.remove(HeaderConstants.COOKIE);
|
||||
|
||||
// According to XHR standards, content-length should be fully controlled by browsers
|
||||
request.headers.remove(HeaderConstants.CONTENT_LENGTH);
|
||||
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
}
|
|
@ -1,280 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
AbortSignalLike,
|
||||
BaseRequestPolicy,
|
||||
HttpOperationResponse,
|
||||
RequestPolicy,
|
||||
RequestPolicyFactory,
|
||||
RequestPolicyOptions,
|
||||
RestError,
|
||||
WebResource,
|
||||
} from "@azure/core-http";
|
||||
|
||||
import { AbortError } from "@azure/abort-controller";
|
||||
|
||||
import { StorageRetryOptions } from "../StorageRetryPolicyFactory";
|
||||
import { URLConstants } from "../utils/constants";
|
||||
import { delay, setURLParameter } from "../utils/utils.common";
|
||||
import { logger } from "../log";
|
||||
|
||||
/**
|
||||
* A factory method used to generated a RetryPolicy factory.
|
||||
*
|
||||
* @param retryOptions -
|
||||
*/
|
||||
export function NewStorageRetryPolicyFactory(
|
||||
retryOptions?: StorageRetryOptions
|
||||
): RequestPolicyFactory {
|
||||
return {
|
||||
create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageRetryPolicy => {
|
||||
return new StorageRetryPolicy(nextPolicy, options, retryOptions);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* RetryPolicy types.
|
||||
*/
|
||||
export enum StorageRetryPolicyType {
|
||||
/**
|
||||
* Exponential retry. Retry time delay grows exponentially.
|
||||
*/
|
||||
EXPONENTIAL,
|
||||
/**
|
||||
* Linear retry. Retry time delay grows linearly.
|
||||
*/
|
||||
FIXED,
|
||||
}
|
||||
|
||||
// Default values of RetryOptions
|
||||
const DEFAULT_RETRY_OPTIONS: StorageRetryOptions = {
|
||||
maxRetryDelayInMs: 120 * 1000,
|
||||
maxTries: 4,
|
||||
retryDelayInMs: 4 * 1000,
|
||||
retryPolicyType: StorageRetryPolicyType.EXPONENTIAL,
|
||||
tryTimeoutInMs: undefined, // Use server side default timeout strategy
|
||||
};
|
||||
|
||||
const RETRY_ABORT_ERROR = new AbortError("The operation was aborted.");
|
||||
|
||||
/**
|
||||
* Retry policy with exponential retry and linear retry implemented.
|
||||
*/
|
||||
export class StorageRetryPolicy extends BaseRequestPolicy {
|
||||
/**
|
||||
* RetryOptions.
|
||||
*/
|
||||
private readonly retryOptions: StorageRetryOptions;
|
||||
|
||||
/**
|
||||
* Creates an instance of RetryPolicy.
|
||||
*
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
* @param retryOptions -
|
||||
*/
|
||||
constructor(
|
||||
nextPolicy: RequestPolicy,
|
||||
options: RequestPolicyOptions,
|
||||
retryOptions: StorageRetryOptions = DEFAULT_RETRY_OPTIONS
|
||||
) {
|
||||
super(nextPolicy, options);
|
||||
|
||||
// Initialize retry options
|
||||
this.retryOptions = {
|
||||
retryPolicyType: retryOptions.retryPolicyType
|
||||
? retryOptions.retryPolicyType
|
||||
: DEFAULT_RETRY_OPTIONS.retryPolicyType,
|
||||
|
||||
maxTries:
|
||||
retryOptions.maxTries && retryOptions.maxTries >= 1
|
||||
? Math.floor(retryOptions.maxTries)
|
||||
: DEFAULT_RETRY_OPTIONS.maxTries,
|
||||
|
||||
tryTimeoutInMs:
|
||||
retryOptions.tryTimeoutInMs && retryOptions.tryTimeoutInMs >= 0
|
||||
? retryOptions.tryTimeoutInMs
|
||||
: DEFAULT_RETRY_OPTIONS.tryTimeoutInMs,
|
||||
|
||||
retryDelayInMs:
|
||||
retryOptions.retryDelayInMs && retryOptions.retryDelayInMs >= 0
|
||||
? Math.min(
|
||||
retryOptions.retryDelayInMs,
|
||||
retryOptions.maxRetryDelayInMs
|
||||
? retryOptions.maxRetryDelayInMs
|
||||
: DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs!
|
||||
)
|
||||
: DEFAULT_RETRY_OPTIONS.retryDelayInMs,
|
||||
|
||||
maxRetryDelayInMs:
|
||||
retryOptions.maxRetryDelayInMs && retryOptions.maxRetryDelayInMs >= 0
|
||||
? retryOptions.maxRetryDelayInMs
|
||||
: DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends request.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
public async sendRequest(request: WebResource): Promise<HttpOperationResponse> {
|
||||
return this.attemptSendRequest(request, false, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide and perform next retry. Won't mutate request parameter.
|
||||
*
|
||||
* @param request -
|
||||
* @param response -
|
||||
* @param secondaryHas404 - If attempt was against the secondary & it returned a StatusNotFound (404), then
|
||||
* the resource was not found. This may be due to replication delay. So, in this
|
||||
* case, we'll never try the secondary again for this operation.
|
||||
* @param attempt - How many retries has been attempted to performed, starting from 1, which includes
|
||||
* the attempt will be performed by this method call.
|
||||
*/
|
||||
protected async attemptSendRequest(
|
||||
request: WebResource,
|
||||
secondaryHas404: boolean,
|
||||
attempt: number
|
||||
): Promise<HttpOperationResponse> {
|
||||
const newRequest: WebResource = request.clone();
|
||||
|
||||
const isPrimaryRetry = true; // File doesn't support secondary endpoint
|
||||
|
||||
// Set the server-side timeout query parameter "timeout=[seconds]"
|
||||
if (this.retryOptions.tryTimeoutInMs) {
|
||||
newRequest.url = setURLParameter(
|
||||
newRequest.url,
|
||||
URLConstants.Parameters.TIMEOUT,
|
||||
Math.floor(this.retryOptions.tryTimeoutInMs! / 1000).toString()
|
||||
);
|
||||
}
|
||||
|
||||
let response: HttpOperationResponse | undefined;
|
||||
try {
|
||||
logger.info(`RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? "Primary" : "Secondary"}`);
|
||||
response = await this._nextPolicy.sendRequest(newRequest);
|
||||
if (!this.shouldRetry(isPrimaryRetry, attempt, response)) {
|
||||
return response;
|
||||
}
|
||||
|
||||
secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);
|
||||
} catch (err: any) {
|
||||
logger.error(`RetryPolicy: Caught error, message: ${err.message}, code: ${err.code}`);
|
||||
if (!this.shouldRetry(isPrimaryRetry, attempt, response, err)) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
await this.delay(isPrimaryRetry, attempt, request.abortSignal);
|
||||
return this.attemptSendRequest(request, secondaryHas404, ++attempt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide whether to retry according to last HTTP response and retry counters.
|
||||
*
|
||||
* @param isPrimaryRetry -
|
||||
* @param attempt -
|
||||
* @param response -
|
||||
* @param err -
|
||||
*/
|
||||
protected shouldRetry(
|
||||
isPrimaryRetry: boolean,
|
||||
attempt: number,
|
||||
response?: HttpOperationResponse,
|
||||
err?: RestError
|
||||
): boolean {
|
||||
if (attempt >= this.retryOptions.maxTries!) {
|
||||
logger.info(
|
||||
`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${this.retryOptions
|
||||
.maxTries!}, no further try.`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Handle network failures, you may need to customize the list when you implement
|
||||
// your own http client
|
||||
const retriableErrors = [
|
||||
"ETIMEDOUT",
|
||||
"ESOCKETTIMEDOUT",
|
||||
"ECONNREFUSED",
|
||||
"ECONNRESET",
|
||||
"ENOENT",
|
||||
"ENOTFOUND",
|
||||
"TIMEOUT",
|
||||
"EPIPE",
|
||||
"REQUEST_SEND_ERROR", // For default xhr based http client provided in ms-rest-js
|
||||
];
|
||||
if (err) {
|
||||
for (const retriableError of retriableErrors) {
|
||||
if (
|
||||
err.name.toUpperCase().includes(retriableError) ||
|
||||
err.message.toUpperCase().includes(retriableError) ||
|
||||
(err.code && err.code.toString().toUpperCase() === retriableError)
|
||||
) {
|
||||
logger.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If attempt was against the secondary & it returned a StatusNotFound (404), then
|
||||
// the resource was not found. This may be due to replication delay. So, in this
|
||||
// case, we'll never try the secondary again for this operation.
|
||||
if (response || err) {
|
||||
const statusCode = response ? response.status : err ? err.statusCode : 0;
|
||||
if (!isPrimaryRetry && statusCode === 404) {
|
||||
logger.info(`RetryPolicy: Secondary access with 404, will retry.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Server internal error or server timeout
|
||||
if (statusCode === 503 || statusCode === 500) {
|
||||
logger.info(`RetryPolicy: Will retry for status code ${statusCode}.`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (err?.code === "PARSE_ERROR" && err?.message.startsWith(`Error "Error: Unclosed root tag`)) {
|
||||
logger.info(
|
||||
"RetryPolicy: Incomplete XML response likely due to service timeout, will retry."
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delay a calculated time between retries.
|
||||
*
|
||||
* @param isPrimaryRetry -
|
||||
* @param attempt -
|
||||
* @param abortSignal -
|
||||
*/
|
||||
private async delay(isPrimaryRetry: boolean, attempt: number, abortSignal?: AbortSignalLike) {
|
||||
let delayTimeInMs: number = 0;
|
||||
|
||||
if (isPrimaryRetry) {
|
||||
switch (this.retryOptions.retryPolicyType) {
|
||||
case StorageRetryPolicyType.EXPONENTIAL:
|
||||
delayTimeInMs = Math.min(
|
||||
(Math.pow(2, attempt - 1) - 1) * this.retryOptions.retryDelayInMs!,
|
||||
this.retryOptions.maxRetryDelayInMs!
|
||||
);
|
||||
break;
|
||||
case StorageRetryPolicyType.FIXED:
|
||||
delayTimeInMs = this.retryOptions.retryDelayInMs!;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
delayTimeInMs = Math.random() * 1000;
|
||||
}
|
||||
|
||||
logger.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);
|
||||
return delay(delayTimeInMs, abortSignal, RETRY_ABORT_ERROR);
|
||||
}
|
||||
}
|
|
@ -1,177 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RequestPolicy, RequestPolicyOptions, WebResource } from "@azure/core-http";
|
||||
import { StorageSharedKeyCredential } from "../credentials/StorageSharedKeyCredential";
|
||||
import { HeaderConstants } from "../utils/constants";
|
||||
import { getURLPath, getURLQueries } from "../utils/utils.common";
|
||||
import { CredentialPolicy } from "./CredentialPolicy";
|
||||
|
||||
/**
|
||||
* StorageSharedKeyCredentialPolicy is a policy used to sign HTTP request with a shared key.
|
||||
*/
|
||||
export class StorageSharedKeyCredentialPolicy extends CredentialPolicy {
|
||||
/**
|
||||
* Reference to {@link StorageSharedKeyCredential} which generates StorageSharedKeyCredentialPolicy
|
||||
*/
|
||||
private readonly factory: StorageSharedKeyCredential;
|
||||
|
||||
/**
|
||||
* Creates an instance of StorageSharedKeyCredentialPolicy.
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
* @param factory -
|
||||
*/
|
||||
constructor(
|
||||
nextPolicy: RequestPolicy,
|
||||
options: RequestPolicyOptions,
|
||||
factory: StorageSharedKeyCredential
|
||||
) {
|
||||
super(nextPolicy, options);
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs request.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
protected signRequest(request: WebResource): WebResource {
|
||||
request.headers.set(HeaderConstants.X_MS_DATE, new Date().toUTCString());
|
||||
|
||||
if (
|
||||
request.body &&
|
||||
(typeof request.body === "string" || (request.body as Buffer) !== undefined) &&
|
||||
request.body.length > 0
|
||||
) {
|
||||
request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));
|
||||
}
|
||||
|
||||
const stringToSign: string =
|
||||
[
|
||||
request.method.toUpperCase(),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.CONTENT_LANGUAGE),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.CONTENT_ENCODING),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.CONTENT_LENGTH),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.CONTENT_MD5),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.CONTENT_TYPE),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.DATE),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.IF_MODIFIED_SINCE),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.IF_MATCH),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.IF_NONE_MATCH),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.IF_UNMODIFIED_SINCE),
|
||||
this.getHeaderValueToSign(request, HeaderConstants.RANGE),
|
||||
].join("\n") +
|
||||
"\n" +
|
||||
this.getCanonicalizedHeadersString(request) +
|
||||
this.getCanonicalizedResourceString(request);
|
||||
|
||||
const signature: string = this.factory.computeHMACSHA256(stringToSign);
|
||||
request.headers.set(
|
||||
HeaderConstants.AUTHORIZATION,
|
||||
`SharedKey ${this.factory.accountName}:${signature}`
|
||||
);
|
||||
|
||||
// console.log(`[URL]:${request.url}`);
|
||||
// console.log(`[HEADERS]:${request.headers.toString()}`);
|
||||
// console.log(`[STRING TO SIGN]:${JSON.stringify(stringToSign)}`);
|
||||
// console.log(`[KEY]: ${request.headers.get(HeaderConstants.AUTHORIZATION)}`);
|
||||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve header value according to shared key sign rules.
|
||||
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/authenticate-with-shared-key
|
||||
*
|
||||
* @param request -
|
||||
* @param headerName -
|
||||
*/
|
||||
private getHeaderValueToSign(request: WebResource, headerName: string): string {
|
||||
const value = request.headers.get(headerName);
|
||||
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// When using version 2015-02-21 or later, if Content-Length is zero, then
|
||||
// set the Content-Length part of the StringToSign to an empty string.
|
||||
// https://docs.microsoft.com/en-us/rest/api/storageservices/authenticate-with-shared-key
|
||||
if (headerName === HeaderConstants.CONTENT_LENGTH && value === "0") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* To construct the CanonicalizedHeaders portion of the signature string, follow these steps:
|
||||
* 1. Retrieve all headers for the resource that begin with x-ms-, including the x-ms-date header.
|
||||
* 2. Convert each HTTP header name to lowercase.
|
||||
* 3. Sort the headers lexicographically by header name, in ascending order.
|
||||
* Each header may appear only once in the string.
|
||||
* 4. Replace any linear whitespace in the header value with a single space.
|
||||
* 5. Trim any whitespace around the colon in the header.
|
||||
* 6. Finally, append a new-line character to each canonicalized header in the resulting list.
|
||||
* Construct the CanonicalizedHeaders string by concatenating all headers in this list into a single string.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
private getCanonicalizedHeadersString(request: WebResource): string {
|
||||
let headersArray = request.headers.headersArray().filter((value) => {
|
||||
return value.name.toLowerCase().startsWith(HeaderConstants.PREFIX_FOR_STORAGE);
|
||||
});
|
||||
|
||||
headersArray.sort((a, b): number => {
|
||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||
});
|
||||
|
||||
// Remove duplicate headers
|
||||
headersArray = headersArray.filter((value, index, array) => {
|
||||
if (index > 0 && value.name.toLowerCase() === array[index - 1].name.toLowerCase()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
let canonicalizedHeadersStringToSign: string = "";
|
||||
headersArray.forEach((header) => {
|
||||
canonicalizedHeadersStringToSign += `${header.name
|
||||
.toLowerCase()
|
||||
.trimRight()}:${header.value.trimLeft()}\n`;
|
||||
});
|
||||
|
||||
return canonicalizedHeadersStringToSign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the webResource canonicalized resource string.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
private getCanonicalizedResourceString(request: WebResource): string {
|
||||
const path = getURLPath(request.url) || "/";
|
||||
|
||||
let canonicalizedResourceString: string = "";
|
||||
canonicalizedResourceString += `/${this.factory.accountName}${path}`;
|
||||
|
||||
const queries = getURLQueries(request.url);
|
||||
const lowercaseQueries: { [key: string]: string } = {};
|
||||
if (queries) {
|
||||
const queryKeys: string[] = [];
|
||||
for (const key in queries) {
|
||||
if (Object.prototype.hasOwnProperty.call(queries, key)) {
|
||||
const lowercaseKey = key.toLowerCase();
|
||||
lowercaseQueries[lowercaseKey] = queries[key];
|
||||
queryKeys.push(lowercaseKey);
|
||||
}
|
||||
}
|
||||
|
||||
queryKeys.sort();
|
||||
for (const key of queryKeys) {
|
||||
canonicalizedResourceString += `\n${key}:${decodeURIComponent(lowercaseQueries[key])}`;
|
||||
}
|
||||
}
|
||||
|
||||
return canonicalizedResourceString;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
BaseRequestPolicy,
|
||||
HttpHeaders,
|
||||
HttpOperationResponse,
|
||||
isNode,
|
||||
RequestPolicy,
|
||||
RequestPolicyOptions,
|
||||
WebResource,
|
||||
} from "@azure/core-http";
|
||||
|
||||
import { HeaderConstants } from "../utils/constants";
|
||||
|
||||
/**
|
||||
* TelemetryPolicy is a policy used to tag user-agent header for every requests.
|
||||
*/
|
||||
export class TelemetryPolicy extends BaseRequestPolicy {
|
||||
/**
|
||||
* Telemetry string.
|
||||
*/
|
||||
public readonly telemetry: string;
|
||||
|
||||
/**
|
||||
* Creates an instance of TelemetryPolicy.
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
* @param telemetry -
|
||||
*/
|
||||
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions, telemetry: string) {
|
||||
super(nextPolicy, options);
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends out request.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
public async sendRequest(request: WebResource): Promise<HttpOperationResponse> {
|
||||
if (isNode) {
|
||||
if (!request.headers) {
|
||||
request.headers = new HttpHeaders();
|
||||
}
|
||||
if (!request.headers.get(HeaderConstants.USER_AGENT)) {
|
||||
request.headers.set(HeaderConstants.USER_AGENT, this.telemetry);
|
||||
}
|
||||
}
|
||||
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
}
|
|
@ -2,14 +2,12 @@
|
|||
// Licensed under the MIT license.
|
||||
|
||||
import { AbortError } from "@azure/abort-controller";
|
||||
import { TransferProgressEvent } from "@azure/core-http";
|
||||
import { TransferProgressEvent } from "@azure/core-rest-pipeline";
|
||||
import { Readable } from "stream";
|
||||
import { AbortSignal, AbortSignalLike } from "@azure/abort-controller";
|
||||
|
||||
export type ReadableStreamGetter = (offset: number) => Promise<NodeJS.ReadableStream>;
|
||||
|
||||
export interface RetriableReadableStreamOptions {
|
||||
abortSignal?: AbortSignalLike;
|
||||
/**
|
||||
* Max retry count (greater than or equal to 0), undefined or invalid value means no retry
|
||||
*/
|
||||
|
@ -32,15 +30,12 @@ export interface RetriableReadableStreamOptions {
|
|||
doInjectErrorOnce?: boolean;
|
||||
}
|
||||
|
||||
const ABORT_ERROR = new AbortError("The operation was aborted.");
|
||||
|
||||
/**
|
||||
* ONLY AVAILABLE IN NODE.JS RUNTIME.
|
||||
*
|
||||
* A Node.js ReadableStream will internally retry when internal ReadableStream unexpected ends.
|
||||
*/
|
||||
export class RetriableReadableStream extends Readable {
|
||||
private aborter: AbortSignalLike;
|
||||
private start: number;
|
||||
private offset: number;
|
||||
private end: number;
|
||||
|
@ -50,10 +45,6 @@ export class RetriableReadableStream extends Readable {
|
|||
private maxRetryRequests: number;
|
||||
private onProgress?: (progress: TransferProgressEvent) => void;
|
||||
private options: RetriableReadableStreamOptions;
|
||||
private abortHandler = () => {
|
||||
this.source.pause();
|
||||
this.emit("error", ABORT_ERROR);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an instance of RetriableReadableStream.
|
||||
|
@ -73,8 +64,6 @@ export class RetriableReadableStream extends Readable {
|
|||
options: RetriableReadableStreamOptions = {}
|
||||
) {
|
||||
super();
|
||||
const aborter = options.abortSignal || AbortSignal.none;
|
||||
this.aborter = aborter;
|
||||
this.getter = getter;
|
||||
this.source = source;
|
||||
this.start = offset;
|
||||
|
@ -85,97 +74,110 @@ export class RetriableReadableStream extends Readable {
|
|||
this.onProgress = options.onProgress;
|
||||
this.options = options;
|
||||
|
||||
aborter.addEventListener("abort", this.abortHandler);
|
||||
|
||||
this.setSourceDataHandler();
|
||||
this.setSourceEndHandler();
|
||||
this.setSourceErrorHandler();
|
||||
this.setSourceEventHandlers();
|
||||
}
|
||||
|
||||
public _read(): void {
|
||||
if (!this.aborter.aborted) {
|
||||
this.source.resume();
|
||||
this.source.resume();
|
||||
}
|
||||
|
||||
private setSourceEventHandlers() {
|
||||
this.source.on("data", this.sourceDataHandler);
|
||||
this.source.on("end", this.sourceErrorOrEndHandler);
|
||||
this.source.on("error", this.sourceErrorOrEndHandler);
|
||||
// needed for Node14
|
||||
this.source.on("aborted", this.sourceAbortedHandler);
|
||||
}
|
||||
|
||||
private removeSourceEventHandlers() {
|
||||
this.source.removeListener("data", this.sourceDataHandler);
|
||||
this.source.removeListener("end", this.sourceErrorOrEndHandler);
|
||||
this.source.removeListener("error", this.sourceErrorOrEndHandler);
|
||||
this.source.removeListener("aborted", this.sourceAbortedHandler);
|
||||
}
|
||||
|
||||
private sourceDataHandler = (data: Buffer) => {
|
||||
if (this.options.doInjectErrorOnce) {
|
||||
this.options.doInjectErrorOnce = undefined;
|
||||
this.source.pause();
|
||||
this.sourceErrorOrEndHandler();
|
||||
(this.source as Readable).destroy();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private setSourceDataHandler() {
|
||||
this.source.on("data", (data: Buffer) => {
|
||||
if (this.options.doInjectErrorOnce) {
|
||||
this.options.doInjectErrorOnce = undefined;
|
||||
this.source.pause();
|
||||
this.source.removeAllListeners("data");
|
||||
this.source.emit("end");
|
||||
return;
|
||||
}
|
||||
// console.log(
|
||||
// `Offset: ${this.offset}, Received ${data.length} from internal stream`
|
||||
// );
|
||||
this.offset += data.length;
|
||||
if (this.onProgress) {
|
||||
this.onProgress({ loadedBytes: this.offset - this.start });
|
||||
}
|
||||
if (!this.push(data)) {
|
||||
this.source.pause();
|
||||
}
|
||||
};
|
||||
|
||||
private sourceAbortedHandler = () => {
|
||||
const abortError = new AbortError("The operation was aborted.");
|
||||
this.destroy(abortError);
|
||||
};
|
||||
|
||||
private sourceErrorOrEndHandler = (err?: Error) => {
|
||||
if (err && err.name === "AbortError") {
|
||||
this.destroy(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log(
|
||||
// `Source stream emits end or error, offset: ${
|
||||
// this.offset
|
||||
// }, dest end : ${this.end}`
|
||||
// );
|
||||
this.removeSourceEventHandlers();
|
||||
if (this.offset - 1 === this.end) {
|
||||
this.push(null);
|
||||
} else if (this.offset <= this.end) {
|
||||
// console.log(
|
||||
// `Offset: ${this.offset}, Received ${data.length} from internal stream`
|
||||
// `retries: ${this.retries}, max retries: ${this.maxRetries}`
|
||||
// );
|
||||
this.offset += data.length;
|
||||
if (this.onProgress) {
|
||||
this.onProgress({ loadedBytes: this.offset - this.start });
|
||||
}
|
||||
if (!this.push(data)) {
|
||||
this.source.pause();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private setSourceEndHandler() {
|
||||
this.source.on("end", () => {
|
||||
// console.log(
|
||||
// `Source stream emits end, offset: ${
|
||||
// this.offset
|
||||
// }, dest end : ${this.end}`
|
||||
// );
|
||||
if (this.offset - 1 === this.end) {
|
||||
this.aborter.removeEventListener("abort", this.abortHandler);
|
||||
this.push(null);
|
||||
} else if (this.offset <= this.end) {
|
||||
// console.log(
|
||||
// `retries: ${this.retries}, max retries: ${this.maxRetries}`
|
||||
// );
|
||||
if (this.retries < this.maxRetryRequests) {
|
||||
this.retries += 1;
|
||||
this.getter(this.offset)
|
||||
.then((newSource) => {
|
||||
this.source = newSource;
|
||||
this.setSourceDataHandler();
|
||||
this.setSourceEndHandler();
|
||||
this.setSourceErrorHandler();
|
||||
return;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.emit("error", error);
|
||||
});
|
||||
} else {
|
||||
this.emit(
|
||||
"error",
|
||||
new Error(
|
||||
`Data corruption failure: received less data than required and reached maxRetires limitation. Received data offset: ${
|
||||
this.offset - 1
|
||||
}, data needed offset: ${this.end}, retries: ${this.retries}, max retries: ${
|
||||
this.maxRetryRequests
|
||||
}`
|
||||
)
|
||||
);
|
||||
}
|
||||
if (this.retries < this.maxRetryRequests) {
|
||||
this.retries += 1;
|
||||
this.getter(this.offset)
|
||||
.then((newSource) => {
|
||||
this.source = newSource;
|
||||
this.setSourceEventHandlers();
|
||||
return;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.destroy(error);
|
||||
});
|
||||
} else {
|
||||
this.emit(
|
||||
"error",
|
||||
this.destroy(
|
||||
new Error(
|
||||
`Data corruption failure: Received more data than original request, data needed offset is ${
|
||||
this.end
|
||||
}, received offset: ${this.offset - 1}`
|
||||
`Data corruption failure: received less data than required and reached maxRetires limitation. Received data offset: ${
|
||||
this.offset - 1
|
||||
}, data needed offset: ${this.end}, retries: ${this.retries}, max retries: ${
|
||||
this.maxRetryRequests
|
||||
}`
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.destroy(
|
||||
new Error(
|
||||
`Data corruption failure: Received more data than original request, data needed offset is ${
|
||||
this.end
|
||||
}, received offset: ${this.offset - 1}`
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
private setSourceErrorHandler() {
|
||||
this.source.on("error", (error) => {
|
||||
this.emit("error", error);
|
||||
});
|
||||
_destroy(error: Error | null, callback: (error?: Error) => void): void {
|
||||
// remove listener from source and release source
|
||||
this.removeSourceEventHandlers();
|
||||
(this.source as Readable).destroy();
|
||||
|
||||
callback(error === null ? undefined : error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { DefaultHttpClient } from "@azure/core-http";
|
||||
import { IHttpClient } from "../Pipeline";
|
||||
|
||||
const _defaultHttpClient = new DefaultHttpClient();
|
||||
|
||||
export function getCachedDefaultHttpClient(): IHttpClient {
|
||||
return _defaultHttpClient;
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { OperationOptions, RequestOptionsBase } from "@azure/core-http";
|
||||
import { createSpanFunction } from "@azure/core-tracing";
|
||||
|
||||
/**
|
||||
|
@ -12,20 +11,3 @@ export const createSpan = createSpanFunction({
|
|||
packagePrefix: "Azure.Storage.File",
|
||||
namespace: "Microsoft.Storage",
|
||||
});
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* Adapt the tracing options from OperationOptions to what they need to be for
|
||||
* RequestOptionsBase (when we update to later OpenTelemetry versions this is now
|
||||
* two separate fields, not just one).
|
||||
*/
|
||||
export function convertTracingToRequestOptionsBase(
|
||||
options?: OperationOptions
|
||||
): Pick<RequestOptionsBase, "spanOptions" | "tracingContext"> {
|
||||
return {
|
||||
// By passing spanOptions if they exist at runtime, we're backwards compatible with @azure/core-tracing@preview.13 and earlier.
|
||||
spanOptions: (options?.tracingOptions as any)?.spanOptions,
|
||||
tracingContext: options?.tracingOptions?.tracingContext,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
// Licensed under the MIT license.
|
||||
|
||||
import { AbortSignalLike } from "@azure/abort-controller";
|
||||
import { HttpHeaders, isNode, URLBuilder } from "@azure/core-http";
|
||||
import { HttpHeaders, createHttpHeaders } from "@azure/core-rest-pipeline";
|
||||
import { HttpAuthorization } from "../models";
|
||||
import { HeaderConstants, PathStylePorts, URLConstants } from "./constants";
|
||||
import { isNode } from "@azure/core-util";
|
||||
import { HttpHeadersLike, WebResourceLike } from "@azure/core-http-compat";
|
||||
|
||||
/**
|
||||
* Reserved URL characters must be properly escaped for Storage services like Blob or File.
|
||||
|
@ -59,13 +61,13 @@ import { HeaderConstants, PathStylePorts, URLConstants } from "./constants";
|
|||
* @param url -
|
||||
*/
|
||||
export function escapeURLPath(url: string): string {
|
||||
const urlParsed = URLBuilder.parse(url);
|
||||
const urlParsed = new URL(url);
|
||||
|
||||
let path = urlParsed.getPath();
|
||||
let path = urlParsed.pathname;
|
||||
path = path || "/";
|
||||
|
||||
path = escape(path);
|
||||
urlParsed.setPath(path);
|
||||
urlParsed.pathname = path;
|
||||
|
||||
return urlParsed.toString();
|
||||
}
|
||||
|
@ -158,7 +160,7 @@ export function extractConnectionStringParts(connectionString: string): Connecti
|
|||
};
|
||||
} else {
|
||||
// SAS connection string
|
||||
const accountSas = getValueInConnString(connectionString, "SharedAccessSignature");
|
||||
let accountSas = getValueInConnString(connectionString, "SharedAccessSignature");
|
||||
const accountName = getAccountNameFromUrl(fileEndpoint);
|
||||
if (!fileEndpoint) {
|
||||
throw new Error("Invalid FileEndpoint in the provided SAS Connection String");
|
||||
|
@ -166,6 +168,11 @@ export function extractConnectionStringParts(connectionString: string): Connecti
|
|||
throw new Error("Invalid SharedAccessSignature in the provided SAS Connection String");
|
||||
}
|
||||
|
||||
// remove test SAS
|
||||
if (accountSas === "fakeSasToken") {
|
||||
accountSas = "";
|
||||
}
|
||||
|
||||
return { kind: "SASConnString", url: fileEndpoint, accountName, accountSas };
|
||||
}
|
||||
}
|
||||
|
@ -192,11 +199,11 @@ function escape(text: string): string {
|
|||
* @returns An updated URL string
|
||||
*/
|
||||
export function appendToURLPath(url: string, name: string): string {
|
||||
const urlParsed = URLBuilder.parse(url);
|
||||
const urlParsed = new URL(url);
|
||||
|
||||
let path = urlParsed.getPath();
|
||||
let path = urlParsed.pathname;
|
||||
path = path ? (path.endsWith("/") ? `${path}${name}` : `${path}/${name}`) : name;
|
||||
urlParsed.setPath(path);
|
||||
urlParsed.pathname = path;
|
||||
|
||||
return urlParsed.toString();
|
||||
}
|
||||
|
@ -209,16 +216,16 @@ export function appendToURLPath(url: string, name: string): string {
|
|||
* @returns An updated URL string.
|
||||
*/
|
||||
export function appendToURLQuery(url: string, queryParts: string): string {
|
||||
const urlParsed = URLBuilder.parse(url);
|
||||
const urlParsed = new URL(url);
|
||||
|
||||
let query = urlParsed.getQuery();
|
||||
let query = urlParsed.search;
|
||||
if (query) {
|
||||
query += "&" + queryParts;
|
||||
} else {
|
||||
query = queryParts;
|
||||
}
|
||||
|
||||
urlParsed.setQuery(query);
|
||||
urlParsed.search = query;
|
||||
return urlParsed.toString();
|
||||
}
|
||||
|
||||
|
@ -232,8 +239,28 @@ export function appendToURLQuery(url: string, queryParts: string): string {
|
|||
* @returns An updated URL string
|
||||
*/
|
||||
export function setURLParameter(url: string, name: string, value?: string): string {
|
||||
const urlParsed = URLBuilder.parse(url);
|
||||
urlParsed.setQueryParameter(name, value);
|
||||
const urlParsed = new URL(url);
|
||||
const encodedName = encodeURIComponent(name);
|
||||
const encodedValue = value ? encodeURIComponent(value) : undefined;
|
||||
// mutating searchParams will change the encoding, so we have to do this ourselves
|
||||
const searchString = urlParsed.search === "" ? "?" : urlParsed.search;
|
||||
|
||||
const searchPieces: string[] = [];
|
||||
|
||||
for (const pair of searchString.slice(1).split("&")) {
|
||||
if (pair) {
|
||||
const [key] = pair.split("=", 2);
|
||||
if (key !== encodedName) {
|
||||
searchPieces.push(pair);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (encodedValue) {
|
||||
searchPieces.push(`${encodedName}=${encodedValue}`);
|
||||
}
|
||||
|
||||
urlParsed.search = searchPieces.length ? `?${searchPieces.join("&")}` : "";
|
||||
|
||||
return urlParsed.toString();
|
||||
}
|
||||
|
||||
|
@ -244,8 +271,8 @@ export function setURLParameter(url: string, name: string, value?: string): stri
|
|||
* @param name -
|
||||
*/
|
||||
export function getURLParameter(url: string, name: string): string | string[] | undefined {
|
||||
const urlParsed = URLBuilder.parse(url);
|
||||
return urlParsed.getQueryParameterValue(name);
|
||||
const urlParsed = new URL(url);
|
||||
return urlParsed.searchParams.get(name) ?? undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,8 +283,8 @@ export function getURLParameter(url: string, name: string): string | string[] |
|
|||
* @returns An updated URL string
|
||||
*/
|
||||
export function setURLHost(url: string, host: string): string {
|
||||
const urlParsed = URLBuilder.parse(url);
|
||||
urlParsed.setHost(host);
|
||||
const urlParsed = new URL(url);
|
||||
urlParsed.hostname = host;
|
||||
return urlParsed.toString();
|
||||
}
|
||||
|
||||
|
@ -267,8 +294,12 @@ export function setURLHost(url: string, host: string): string {
|
|||
* @param url - Source URL string
|
||||
*/
|
||||
export function getURLPath(url: string): string | undefined {
|
||||
const urlParsed = URLBuilder.parse(url);
|
||||
return urlParsed.getPath();
|
||||
try {
|
||||
const urlParsed = new URL(url);
|
||||
return urlParsed.pathname;
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,19 +308,21 @@ export function getURLPath(url: string): string | undefined {
|
|||
* @param url -
|
||||
*/
|
||||
export function getURLQueries(url: string): { [key: string]: string } {
|
||||
let queryString = URLBuilder.parse(url).getQuery();
|
||||
let queryString = new URL(url).search;
|
||||
if (!queryString) {
|
||||
return {};
|
||||
}
|
||||
|
||||
queryString = queryString.trim();
|
||||
queryString = queryString.startsWith("?") ? queryString.substr(1) : queryString;
|
||||
queryString = queryString.startsWith("?") ? queryString.substring(1) : queryString;
|
||||
|
||||
let querySubStrings: string[] = queryString.split("&");
|
||||
querySubStrings = querySubStrings.filter((value: string) => {
|
||||
const indexOfEqual = value.indexOf("=");
|
||||
const lastIndexOfEqual = value.lastIndexOf("=");
|
||||
return indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual;
|
||||
return (
|
||||
indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual && lastIndexOfEqual < value.length - 1
|
||||
);
|
||||
});
|
||||
|
||||
const queries: { [key: string]: string } = {};
|
||||
|
@ -386,14 +419,14 @@ export function sanitizeURL(url: string): string {
|
|||
}
|
||||
|
||||
export function sanitizeHeaders(originalHeader: HttpHeaders): HttpHeaders {
|
||||
const headers: HttpHeaders = new HttpHeaders();
|
||||
for (const header of originalHeader.headersArray()) {
|
||||
if (header.name.toLowerCase() === HeaderConstants.AUTHORIZATION) {
|
||||
headers.set(header.name, "*****");
|
||||
} else if (header.name.toLowerCase() === HeaderConstants.X_MS_COPY_SOURCE) {
|
||||
headers.set(header.name, sanitizeURL(header.value));
|
||||
const headers: HttpHeaders = createHttpHeaders();
|
||||
for (const [name, value] of originalHeader) {
|
||||
if (name.toLowerCase() === HeaderConstants.AUTHORIZATION.toLowerCase()) {
|
||||
headers.set(name, "*****");
|
||||
} else if (name.toLowerCase() === HeaderConstants.X_MS_COPY_SOURCE) {
|
||||
headers.set(name, sanitizeURL(value));
|
||||
} else {
|
||||
headers.set(header.name, header.value);
|
||||
headers.set(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,20 +439,20 @@ export function sanitizeHeaders(originalHeader: HttpHeaders): HttpHeaders {
|
|||
* @returns with the account name
|
||||
*/
|
||||
export function getAccountNameFromUrl(url: string): string {
|
||||
const parsedUrl: URLBuilder = URLBuilder.parse(url);
|
||||
const parsedUrl = new URL(url);
|
||||
let accountName;
|
||||
try {
|
||||
if (parsedUrl.getHost()!.split(".")[1] === "file") {
|
||||
if (parsedUrl.hostname.split(".")[1] === "file") {
|
||||
// `${defaultEndpointsProtocol}://${accountName}.file.${endpointSuffix}`;
|
||||
// Slicing off '/' at the end if exists
|
||||
url = url.endsWith("/") ? url.slice(0, -1) : url;
|
||||
|
||||
accountName = parsedUrl.getHost()!.split(".")[0];
|
||||
accountName = parsedUrl.hostname.split(".")[0];
|
||||
} else if (isIpEndpointStyle(parsedUrl)) {
|
||||
// IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/
|
||||
// Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/
|
||||
// .getPath() -> /devstoreaccount1/
|
||||
accountName = parsedUrl.getPath()!.split("/")[1];
|
||||
accountName = parsedUrl.pathname.split("/")[1];
|
||||
} else {
|
||||
// Custom domain case: "https://customdomain.com/containername/blob".
|
||||
accountName = "";
|
||||
|
@ -430,13 +463,8 @@ export function getAccountNameFromUrl(url: string): string {
|
|||
}
|
||||
}
|
||||
|
||||
export function isIpEndpointStyle(parsedUrl: URLBuilder): boolean {
|
||||
if (parsedUrl.getHost() === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const host =
|
||||
parsedUrl.getHost()! + (parsedUrl.getPort() === undefined ? "" : ":" + parsedUrl.getPort());
|
||||
export function isIpEndpointStyle(parsedUrl: URL): boolean {
|
||||
const host = parsedUrl.host;
|
||||
|
||||
// Case 1: Ipv6, use a broad regex to find out candidates whose host contains two ':'.
|
||||
// Case 2: localhost(:port), use broad regex to match port part.
|
||||
|
@ -446,7 +474,7 @@ export function isIpEndpointStyle(parsedUrl: URLBuilder): boolean {
|
|||
/^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(
|
||||
host
|
||||
) ||
|
||||
(parsedUrl.getPort() !== undefined && PathStylePorts.includes(parsedUrl.getPort()!))
|
||||
(Boolean(parsedUrl.port) && PathStylePorts.includes(parsedUrl.port))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -471,24 +499,24 @@ export function getShareNameAndPathFromUrl(url: string): {
|
|||
let baseName;
|
||||
|
||||
try {
|
||||
const parsedUrl = URLBuilder.parse(url);
|
||||
if (parsedUrl.getHost()!.split(".")[1] === "file") {
|
||||
const parsedUrl = new URL(url);
|
||||
if (parsedUrl.hostname.split(".")[1] === "file") {
|
||||
// "https://myaccount.file.core.windows.net/myshare/mydirectory/file";
|
||||
// .getPath() -> /myshare/mydirectory/file
|
||||
const pathComponents = parsedUrl.getPath()!.match("/([^/]*)(/(.*))?");
|
||||
const pathComponents = parsedUrl.pathname.match("/([^/]*)(/(.*))?");
|
||||
shareName = pathComponents![1];
|
||||
path = pathComponents![3];
|
||||
} else if (isIpEndpointStyle(parsedUrl)) {
|
||||
// IPv4/IPv6 address hosts... Example - http://187.24.0.1:1000/devstoreaccount1/mydirectory/file
|
||||
// Single word domain without a [dot] in the endpoint... Example - http://localhost:1000/devstoreaccount1/mydirectory/file
|
||||
// .getPath() -> /devstoreaccount1/mydirectory/file
|
||||
const pathComponents = parsedUrl.getPath()!.match("/([^/]*)/([^/]*)(/(.*))?");
|
||||
const pathComponents = parsedUrl.pathname.match("/([^/]*)/([^/]*)(/(.*))?");
|
||||
shareName = pathComponents![2];
|
||||
path = pathComponents![4];
|
||||
} else {
|
||||
// "https://customdomain.com/myshare/mydirectory/file";
|
||||
// .getPath() -> /myshare/mydirectory/file
|
||||
const pathComponents = parsedUrl.getPath()!.match("/([^/]*)(/(.*))?");
|
||||
const pathComponents = parsedUrl.pathname.match("/([^/]*)(/(.*))?");
|
||||
shareName = pathComponents![1];
|
||||
path = pathComponents![3];
|
||||
}
|
||||
|
@ -525,9 +553,9 @@ export function httpAuthorizationToString(
|
|||
* @param url - URL to change path to.
|
||||
* @param path - Path to set into the URL.
|
||||
*/
|
||||
export function setURLPath(url: string, path?: string): string {
|
||||
const urlParsed = URLBuilder.parse(url);
|
||||
urlParsed.setPath(path);
|
||||
export function setURLPath(url: string, path: string): string {
|
||||
const urlParsed = new URL(url);
|
||||
urlParsed.pathname = path;
|
||||
return urlParsed.toString();
|
||||
}
|
||||
|
||||
|
@ -538,8 +566,8 @@ export function setURLPath(url: string, path?: string): string {
|
|||
* @param queryString - Query string to set to the URL.
|
||||
*/
|
||||
export function setURLQueries(url: string, queryString: string): string {
|
||||
const urlParsed = URLBuilder.parse(url);
|
||||
urlParsed.setQuery(queryString);
|
||||
const urlParsed = new URL(url);
|
||||
urlParsed.search = queryString;
|
||||
return urlParsed.toString();
|
||||
}
|
||||
|
||||
|
@ -553,3 +581,99 @@ export function EscapePath(pathName: string): string {
|
|||
}
|
||||
return split.join("/");
|
||||
}
|
||||
|
||||
/**
|
||||
* A representation of an HTTP response that
|
||||
* includes a reference to the request that
|
||||
* originated it.
|
||||
*/
|
||||
export interface HttpResponse {
|
||||
/**
|
||||
* The headers from the response.
|
||||
*/
|
||||
headers: HttpHeadersLike;
|
||||
/**
|
||||
* The original request that resulted in this response.
|
||||
*/
|
||||
request: WebResourceLike;
|
||||
/**
|
||||
* The HTTP status code returned from the service.
|
||||
*/
|
||||
status: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object with a _response property that has
|
||||
* headers already parsed into a typed object.
|
||||
*/
|
||||
export interface ResponseWithHeaders<Headers> {
|
||||
/**
|
||||
* The underlying HTTP response.
|
||||
*/
|
||||
_response: HttpResponse & {
|
||||
/**
|
||||
* The parsed HTTP response headers.
|
||||
*/
|
||||
parsedHeaders: Headers;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An object with a _response property that has body
|
||||
* and headers already parsed into known types.
|
||||
*/
|
||||
export interface ResponseWithBody<Headers, Body> {
|
||||
/**
|
||||
* The underlying HTTP response.
|
||||
*/
|
||||
_response: HttpResponse & {
|
||||
/**
|
||||
* The parsed HTTP response headers.
|
||||
*/
|
||||
parsedHeaders: Headers;
|
||||
/**
|
||||
* The response body as text (string format)
|
||||
*/
|
||||
bodyAsText: string;
|
||||
/**
|
||||
* The response body as parsed JSON or XML
|
||||
*/
|
||||
parsedBody: Body;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An object with a simple _response property.
|
||||
*/
|
||||
export interface ResponseLike {
|
||||
/**
|
||||
* The underlying HTTP response.
|
||||
*/
|
||||
_response: HttpResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type that represents an operation result with a known _response property.
|
||||
*/
|
||||
export type WithResponse<T, Headers = undefined, Body = undefined> = T &
|
||||
(Body extends object
|
||||
? ResponseWithBody<Headers, Body>
|
||||
: Headers extends object
|
||||
? ResponseWithHeaders<Headers>
|
||||
: ResponseLike);
|
||||
|
||||
/**
|
||||
* A typesafe helper for ensuring that a given response object has
|
||||
* the original _response attached.
|
||||
* @param response - A response object from calling a client operation
|
||||
* @returns The same object, but with known _response property
|
||||
*/
|
||||
export function assertResponse<T extends object, Headers = undefined, Body = undefined>(
|
||||
response: T
|
||||
): WithResponse<T, Headers, Body> {
|
||||
if (`_response` in response) {
|
||||
return response as WithResponse<T, Headers, Body>;
|
||||
}
|
||||
|
||||
throw new TypeError(`Unexpected response object ${response}`);
|
||||
}
|
||||
|
|
|
@ -18,9 +18,10 @@ optional-response-headers: true
|
|||
v3: true
|
||||
disable-async-iterators: true
|
||||
add-credentials: false
|
||||
core-http-compat-mode: true
|
||||
use-extension:
|
||||
"@autorest/typescript": "6.0.0-dev.20210218.1"
|
||||
package-version: 12.13.0
|
||||
"@autorest/typescript": "6.0.2"
|
||||
package-version: 12.20.0
|
||||
```
|
||||
|
||||
## Customizations for Track 2 Generator
|
||||
|
@ -296,16 +297,6 @@ directive:
|
|||
delete $.format;
|
||||
```
|
||||
|
||||
### Retain XStore swagger behavior - Revert file permissions content-type to "application/xml" from "application/json"(unified swagger)
|
||||
|
||||
```yaml
|
||||
directive:
|
||||
- from: swagger-document
|
||||
where: $["x-ms-paths"]["/{shareName}?restype=share&comp=filepermission"]
|
||||
transform: >
|
||||
$.put.consumes = ["application/xml"];
|
||||
```
|
||||
|
||||
### Rename optionalbody -> body
|
||||
|
||||
```yaml
|
||||
|
|
|
@ -32,7 +32,6 @@ describe("Aborter", () => {
|
|||
assert.fail();
|
||||
} catch (err: any) {
|
||||
assert.equal(err.name, "AbortError");
|
||||
assert.equal(err.message, "The operation was aborted.", "Unexpected error caught: " + err);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -50,7 +49,6 @@ describe("Aborter", () => {
|
|||
assert.fail();
|
||||
} catch (err: any) {
|
||||
assert.equal(err.name, "AbortError");
|
||||
assert.equal(err.message, "The operation was aborted.", "Unexpected error caught: " + err);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -72,7 +70,6 @@ describe("Aborter", () => {
|
|||
assert.fail();
|
||||
} catch (err: any) {
|
||||
assert.equal(err.name, "AbortError");
|
||||
assert.equal(err.message, "The operation was aborted.", "Unexpected error caught: " + err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,8 +9,6 @@ import { record, Recorder } from "@azure-tools/test-recorder";
|
|||
import { DirectoryCreateResponse } from "../src/generated/src/models";
|
||||
import { truncatedISO8061Date } from "../src/utils/utils.common";
|
||||
import { SpanGraph, setTracer, getYieldedValue } from "@azure/test-utils";
|
||||
import { MockPolicyFactory } from "./utils/MockPolicyFactory";
|
||||
import { Pipeline } from "../src/Pipeline";
|
||||
import { setSpan, context } from "@azure/core-tracing";
|
||||
import { Context } from "mocha";
|
||||
|
||||
|
@ -784,12 +782,7 @@ describe("DirectoryClient", () => {
|
|||
children: [
|
||||
{
|
||||
name: "Azure.Storage.File.ShareDirectoryClient-create",
|
||||
children: [
|
||||
{
|
||||
name: "HTTP PUT",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -798,55 +791,30 @@ describe("DirectoryClient", () => {
|
|||
children: [
|
||||
{
|
||||
name: "Azure.Storage.File.ShareFileClient-create",
|
||||
children: [
|
||||
{
|
||||
name: "HTTP PUT",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Azure.Storage.File.ShareFileClient-getProperties",
|
||||
children: [
|
||||
{
|
||||
name: "HTTP HEAD",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
name: "Azure.Storage.File.ShareDirectoryClient-deleteFile",
|
||||
children: [
|
||||
{
|
||||
name: "Azure.Storage.File.ShareFileClient-delete",
|
||||
children: [
|
||||
{
|
||||
name: "HTTP DELETE",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Azure.Storage.File.ShareFileClient-getProperties",
|
||||
children: [
|
||||
{
|
||||
name: "HTTP HEAD",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
name: "Azure.Storage.File.ShareDirectoryClient-delete",
|
||||
children: [
|
||||
{
|
||||
name: "HTTP DELETE",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -893,26 +861,6 @@ describe("DirectoryClient", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("forceCloseHandle could return closeFailureCount", async () => {
|
||||
// TODO: Open or create a handle; currently have to do this manually
|
||||
const result = (await dirClient.listHandles().byPage().next()).value;
|
||||
if (result.handleList !== undefined && result.handleList.length > 0) {
|
||||
const mockPolicyFactory = new MockPolicyFactory({ numberOfHandlesFailedToClose: 1 });
|
||||
const factories = (dirClient as any).pipeline.factories.slice(); // clone factories array
|
||||
factories.unshift(mockPolicyFactory);
|
||||
const pipeline = new Pipeline(factories);
|
||||
const mockDirClient = new ShareDirectoryClient(dirClient.url, pipeline);
|
||||
|
||||
const handle = result.handleList[0];
|
||||
const closeResp = await mockDirClient.forceCloseHandle(handle.handleId);
|
||||
assert.equal(
|
||||
closeResp.closeFailureCount,
|
||||
1,
|
||||
"Number of handles failed to close is not as set."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("forceCloseAllHandles return correct closeFailureCount", async () => {
|
||||
const closeRes = await dirClient.forceCloseAllHandles();
|
||||
assert.equal(
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import { assert } from "chai";
|
||||
|
||||
import { AbortController } from "@azure/abort-controller";
|
||||
import { isNode, URLBuilder, URLQuery } from "@azure/core-http";
|
||||
import { isNode } from "@azure/core-util";
|
||||
import { delay, isLiveMode, record, Recorder } from "@azure-tools/test-recorder";
|
||||
import { context, setSpan } from "@azure/core-tracing";
|
||||
import { Context } from "mocha";
|
||||
|
@ -13,11 +13,9 @@ import { setTracer, SpanGraph } from "@azure/test-utils";
|
|||
import { FileStartCopyOptions, ShareClient, ShareDirectoryClient, ShareFileClient } from "../src";
|
||||
import { FileSystemAttributes } from "../src/FileSystemAttributes";
|
||||
import { DirectoryCreateResponse } from "../src/generated/src/models";
|
||||
import { Pipeline } from "../src/Pipeline";
|
||||
import { FILE_MAX_SIZE_BYTES } from "../src/utils/constants";
|
||||
import { truncatedISO8061Date } from "../src/utils/utils.common";
|
||||
import { bodyToString, compareBodyWithUint8Array, getBSU, recorderEnvSetup } from "./utils";
|
||||
import { MockPolicyFactory } from "./utils/MockPolicyFactory";
|
||||
|
||||
describe("FileClient", () => {
|
||||
let shareName: string;
|
||||
|
@ -345,15 +343,11 @@ describe("FileClient", () => {
|
|||
// so we remove it before comparing urls.
|
||||
assert.ok(properties2.copySource, "Expecting valid 'properties2.copySource");
|
||||
|
||||
const sanitizedActualUrl = URLBuilder.parse(properties2.copySource!);
|
||||
const sanitizedQuery = URLQuery.parse(sanitizedActualUrl.getQuery()!);
|
||||
sanitizedQuery.set("sig", undefined);
|
||||
sanitizedActualUrl.setQuery(sanitizedQuery.toString());
|
||||
const sanitizedActualUrl = new URL(properties2.copySource!);
|
||||
sanitizedActualUrl.searchParams.delete("sig");
|
||||
|
||||
const sanitizedExpectedUrl = URLBuilder.parse(fileClient.url);
|
||||
const sanitizedQuery2 = URLQuery.parse(sanitizedActualUrl.getQuery()!);
|
||||
sanitizedQuery2.set("sig", undefined);
|
||||
sanitizedExpectedUrl.setQuery(sanitizedQuery.toString());
|
||||
const sanitizedExpectedUrl = new URL(fileClient.url);
|
||||
sanitizedExpectedUrl.searchParams.delete("sig");
|
||||
|
||||
assert.strictEqual(
|
||||
sanitizedActualUrl.toString(),
|
||||
|
@ -598,7 +592,9 @@ describe("FileClient", () => {
|
|||
);
|
||||
await fileClient.create(10);
|
||||
let progressUpdated = false;
|
||||
await fileClient.uploadRange("HelloWorld", 0, 10, {
|
||||
// fetch http client doesn't fire progress for string bodies, only blob and streams
|
||||
const body = isNode ? "HelloWorld" : new Blob(["HelloWorld"]);
|
||||
await fileClient.uploadRange(body, 0, 10, {
|
||||
onProgress: () => {
|
||||
progressUpdated = true;
|
||||
},
|
||||
|
@ -792,11 +788,16 @@ describe("FileClient", () => {
|
|||
assert.deepStrictEqual(await bodyToString(result, 2), "He");
|
||||
});
|
||||
|
||||
it("download should update progress and abort successfully", async () => {
|
||||
it("download should update progress and abort successfully", async function () {
|
||||
recorder.skip(
|
||||
undefined,
|
||||
"Abort - Recorder does not record a request if it's aborted in a 'progress' callback"
|
||||
);
|
||||
if (!isNode) {
|
||||
// because this test is using a blob response, there won't be
|
||||
// anything to abort by the time onProgress gets called.
|
||||
this.skip();
|
||||
}
|
||||
await fileClient.create(128 * 1024 * 1024);
|
||||
|
||||
let eventTriggered = false;
|
||||
|
@ -873,45 +874,11 @@ describe("FileClient", () => {
|
|||
|
||||
it("forceCloseHandle could return closeFailureCount", async () => {
|
||||
await fileClient.create(10);
|
||||
|
||||
// TODO: Open or create a handle, currently have to do this manually
|
||||
const result = (await fileClient.listHandles().byPage().next()).value;
|
||||
if (result.handleList !== undefined && result.handleList.length > 0) {
|
||||
const mockPolicyFactory = new MockPolicyFactory({ numberOfHandlesFailedToClose: 1 });
|
||||
const factories = (fileClient as any).pipeline.factories.slice(); // clone factories array
|
||||
factories.unshift(mockPolicyFactory);
|
||||
const pipeline = new Pipeline(factories);
|
||||
const mockFileClient = new ShareFileClient(fileClient.url, pipeline);
|
||||
|
||||
const handle = result.handleList[0];
|
||||
const closeResp = await mockFileClient.forceCloseHandle(handle.handleId);
|
||||
assert.equal(
|
||||
closeResp.closeFailureCount,
|
||||
1,
|
||||
"Number of handles failed to close is not as set."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("forceCloseAllHandles return correct closeFailureCount", async () => {
|
||||
await fileClient.create(10);
|
||||
|
||||
// TODO: Open or create a handle; currently have to do this manually
|
||||
const result = (await fileClient.listHandles().byPage().next()).value;
|
||||
if (result.handleList !== undefined && result.handleList.length > 0) {
|
||||
const mockPolicyFactory = new MockPolicyFactory({ numberOfHandlesFailedToClose: 1 });
|
||||
const factories = (fileClient as any).pipeline.factories.slice(); // clone factories array
|
||||
factories.unshift(mockPolicyFactory);
|
||||
const pipeline = new Pipeline(factories);
|
||||
const mockFileClient = new ShareFileClient(fileClient.url, pipeline);
|
||||
const closeResp = await mockFileClient.forceCloseAllHandles();
|
||||
assert.equal(
|
||||
closeResp.closeFailureCount,
|
||||
1,
|
||||
"Number of handles failed to close is not as set."
|
||||
);
|
||||
}
|
||||
|
||||
const closeAllResp = await fileClient.forceCloseAllHandles();
|
||||
assert.equal(
|
||||
closeAllResp.closeFailureCount,
|
||||
|
@ -941,12 +908,7 @@ describe("FileClient", () => {
|
|||
children: [
|
||||
{
|
||||
name: "Azure.Storage.File.ShareFileClient-create",
|
||||
children: [
|
||||
{
|
||||
name: "HTTP PUT",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -39,8 +39,7 @@ describe("DirectoryClient Node.js only", () => {
|
|||
});
|
||||
|
||||
it("can be created with a url and a credential", async () => {
|
||||
const factories = (dirClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = dirClient["credential"] as StorageSharedKeyCredential;
|
||||
const newClient = new ShareDirectoryClient(dirClient.url, credential);
|
||||
|
||||
const result = await newClient.getProperties();
|
||||
|
@ -53,8 +52,7 @@ describe("DirectoryClient Node.js only", () => {
|
|||
});
|
||||
|
||||
it("can be created with a url and a credential and an option bag", async () => {
|
||||
const factories = (dirClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = dirClient["credential"] as StorageSharedKeyCredential;
|
||||
const newClient = new ShareDirectoryClient(dirClient.url, credential, {
|
||||
retryOptions: {
|
||||
maxTries: 5,
|
||||
|
@ -71,8 +69,7 @@ describe("DirectoryClient Node.js only", () => {
|
|||
});
|
||||
|
||||
it("can be created with a url and a pipeline", async () => {
|
||||
const factories = (dirClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = dirClient["credential"] as StorageSharedKeyCredential;
|
||||
const pipeline = newPipeline(credential);
|
||||
const newClient = new ShareDirectoryClient(dirClient.url, pipeline);
|
||||
|
||||
|
|
|
@ -137,8 +137,7 @@ describe("FileClient Node.js only", () => {
|
|||
};
|
||||
await fileClient.setMetadata(metadata);
|
||||
|
||||
const factories = (fileClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = fileClient["credential"] as StorageSharedKeyCredential;
|
||||
const newClient = new ShareFileClient(fileClient.url, credential);
|
||||
|
||||
const result = await newClient.getProperties();
|
||||
|
@ -158,8 +157,7 @@ describe("FileClient Node.js only", () => {
|
|||
};
|
||||
await fileClient.setMetadata(metadata);
|
||||
|
||||
const factories = (fileClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = fileClient["credential"] as StorageSharedKeyCredential;
|
||||
const newClient = new ShareFileClient(fileClient.url, credential, {
|
||||
retryOptions: {
|
||||
maxTries: 5,
|
||||
|
@ -183,8 +181,7 @@ describe("FileClient Node.js only", () => {
|
|||
};
|
||||
await fileClient.setMetadata(metadata);
|
||||
|
||||
const factories = (fileClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = fileClient["credential"] as StorageSharedKeyCredential;
|
||||
const pipeline = newPipeline(credential);
|
||||
const newClient = new ShareFileClient(fileClient.url, pipeline);
|
||||
|
||||
|
@ -204,8 +201,7 @@ describe("FileClient Node.js only", () => {
|
|||
await fileClient.uploadRange(fileContent, 0, fileContent.length);
|
||||
|
||||
// Get a SAS for fileURL
|
||||
const factories = (fileClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = fileClient["credential"] as StorageSharedKeyCredential;
|
||||
const expiresOn = recorder.newDate("now");
|
||||
expiresOn.setDate(expiresOn.getDate() + 1);
|
||||
const sas = generateFileSASQueryParameters(
|
||||
|
@ -240,8 +236,7 @@ describe("FileClient Node.js only", () => {
|
|||
await fileClient.uploadRange(fileContent, 0, fileContent.length);
|
||||
|
||||
// Get a SAS for fileURL
|
||||
const factories = (fileClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = fileClient["credential"] as StorageSharedKeyCredential;
|
||||
const expiresOn = recorder.newDate("now");
|
||||
expiresOn.setDate(expiresOn.getDate() + 1);
|
||||
const sas = generateFileSASQueryParameters(
|
||||
|
|
|
@ -20,8 +20,7 @@ describe("FileServiceClient Node.js only", () => {
|
|||
|
||||
it("can be created with a url and a credential", async () => {
|
||||
const serviceClient = getBSU();
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = serviceClient["credential"] as StorageSharedKeyCredential;
|
||||
const newClient = new ShareServiceClient(serviceClient.url, credential);
|
||||
|
||||
const result = await newClient.getProperties();
|
||||
|
@ -34,8 +33,7 @@ describe("FileServiceClient Node.js only", () => {
|
|||
|
||||
it("can be created with a url and a credential and an option bag", async () => {
|
||||
const serviceClient = getBSU();
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = serviceClient["credential"] as StorageSharedKeyCredential;
|
||||
const newClient = new ShareServiceClient(serviceClient.url, credential, {
|
||||
retryOptions: { maxTries: 5 },
|
||||
});
|
||||
|
@ -50,8 +48,7 @@ describe("FileServiceClient Node.js only", () => {
|
|||
|
||||
it("can be created with a url and a pipeline", async () => {
|
||||
const serviceClient = getBSU();
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = serviceClient["credential"] as StorageSharedKeyCredential;
|
||||
const pipeline = newPipeline(credential);
|
||||
const newClient = new ShareServiceClient(serviceClient.url, pipeline);
|
||||
|
||||
|
|
|
@ -7,17 +7,17 @@ import {
|
|||
AccountSASPermissions,
|
||||
AccountSASResourceTypes,
|
||||
AccountSASServices,
|
||||
AnonymousCredential,
|
||||
generateAccountSASQueryParameters,
|
||||
SASProtocol,
|
||||
ShareClient,
|
||||
ShareFileClient,
|
||||
ShareServiceClient,
|
||||
StorageSharedKeyCredential,
|
||||
} from "../../src";
|
||||
import { AnonymousCredential } from "../../../storage-blob/src/credentials/AnonymousCredential";
|
||||
import { StorageSharedKeyCredential } from "../../../storage-blob/src/credentials/StorageSharedKeyCredential";
|
||||
import { FileSASPermissions } from "../../src/FileSASPermissions";
|
||||
import { generateFileSASQueryParameters } from "../../src/FileSASSignatureValues";
|
||||
import { newPipeline } from "../../src/Pipeline";
|
||||
import { newPipeline } from "../../../storage-blob/src/Pipeline";
|
||||
import { ShareSASPermissions } from "../../src/ShareSASPermissions";
|
||||
import { getBSU, recorderEnvSetup } from "../utils";
|
||||
import { delay, record, Recorder } from "@azure-tools/test-recorder";
|
||||
|
@ -43,9 +43,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
|
|||
const tmr = recorder.newDate("now");
|
||||
tmr.setDate(tmr.getDate() + 1);
|
||||
|
||||
// By default, credential is always the last element of pipeline factories
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const sharedKeyCredential = factories[factories.length - 1];
|
||||
const sharedKeyCredential = serviceClient["credential"];
|
||||
|
||||
const sas = generateAccountSASQueryParameters(
|
||||
{
|
||||
|
@ -72,10 +70,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
|
|||
const tmr = recorder.newDate("now");
|
||||
tmr.setDate(tmr.getDate() + 1);
|
||||
|
||||
// By default, credential is always the last element of pipeline factories
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const sharedKeyCredential = factories[factories.length - 1];
|
||||
|
||||
const sharedKeyCredential = serviceClient["credential"];
|
||||
const sas = generateAccountSASQueryParameters(
|
||||
{
|
||||
expiresOn: tmr,
|
||||
|
@ -106,9 +101,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
|
|||
const tmr = recorder.newDate("now");
|
||||
tmr.setDate(tmr.getDate() + 1);
|
||||
|
||||
// By default, credential is always the last element of pipeline factories
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const sharedKeyCredential = factories[factories.length - 1];
|
||||
const sharedKeyCredential = serviceClient["credential"];
|
||||
|
||||
const sas = generateAccountSASQueryParameters(
|
||||
{
|
||||
|
@ -137,9 +130,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
|
|||
const tmr = recorder.newDate("now");
|
||||
tmr.setDate(tmr.getDate() + 1);
|
||||
|
||||
// By default, credential is always the last element of pipeline factories
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const sharedKeyCredential = factories[factories.length - 1];
|
||||
const sharedKeyCredential = serviceClient["credential"];
|
||||
|
||||
const sas = generateAccountSASQueryParameters(
|
||||
{
|
||||
|
@ -174,9 +165,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
|
|||
const tmr = recorder.newDate("now");
|
||||
tmr.setDate(tmr.getDate() + 1);
|
||||
|
||||
// By default, credential is always the last element of pipeline factories
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const sharedKeyCredential = factories[factories.length - 1];
|
||||
const sharedKeyCredential = serviceClient["credential"];
|
||||
|
||||
const shareName = recorder.getUniqueName("share");
|
||||
const shareClient = serviceClient.getShareClient(shareName);
|
||||
|
@ -213,9 +202,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
|
|||
const tmr = recorder.newDate("now");
|
||||
tmr.setDate(tmr.getDate() + 1);
|
||||
|
||||
// By default, credential is always the last element of pipeline factories
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const sharedKeyCredential = factories[factories.length - 1];
|
||||
const sharedKeyCredential = serviceClient["credential"];
|
||||
|
||||
const shareName = recorder.getUniqueName("share");
|
||||
const shareClient = serviceClient.getShareClient(shareName);
|
||||
|
@ -272,9 +259,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
|
|||
const tmr = recorder.newDate("tmr");
|
||||
tmr.setDate(tmr.getDate() + 1);
|
||||
|
||||
// By default, credential is always the last element of pipeline factories
|
||||
const factories = (serviceClient as any).pipeline.factories;
|
||||
const sharedKeyCredential = factories[factories.length - 1];
|
||||
const sharedKeyCredential = serviceClient["credential"];
|
||||
|
||||
const shareName = recorder.getUniqueName("share");
|
||||
const shareClient = serviceClient.getShareClient(shareName);
|
||||
|
|
|
@ -83,8 +83,7 @@ describe("ShareClient Node.js only", () => {
|
|||
});
|
||||
|
||||
it("can be created with a url and a credential", async () => {
|
||||
const factories = (shareClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = shareClient["credential"] as StorageSharedKeyCredential;
|
||||
const newClient = new ShareClient(shareClient.url, credential);
|
||||
|
||||
const result = await newClient.getProperties();
|
||||
|
@ -97,8 +96,7 @@ describe("ShareClient Node.js only", () => {
|
|||
});
|
||||
|
||||
it("can be created with a url and a credential and an option bag", async () => {
|
||||
const factories = (shareClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = shareClient["credential"] as StorageSharedKeyCredential;
|
||||
const newClient = new ShareClient(shareClient.url, credential, {
|
||||
retryOptions: {
|
||||
maxTries: 5,
|
||||
|
@ -115,8 +113,7 @@ describe("ShareClient Node.js only", () => {
|
|||
});
|
||||
|
||||
it("can be created with a url and a pipeline", async () => {
|
||||
const factories = (shareClient as any).pipeline.factories;
|
||||
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
|
||||
const credential = shareClient["credential"] as StorageSharedKeyCredential;
|
||||
const pipeline = newPipeline(credential);
|
||||
const newClient = new ShareClient(shareClient.url, pipeline);
|
||||
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { assert } from "chai";
|
||||
import { Context } from "mocha";
|
||||
|
||||
import { record, Recorder } from "@azure-tools/test-recorder";
|
||||
import { AbortController } from "@azure/abort-controller";
|
||||
|
||||
import { RestError, ShareClient } from "../src";
|
||||
import { newPipeline, Pipeline } from "../src/Pipeline";
|
||||
import { getBSU, recorderEnvSetup } from "./utils";
|
||||
import { InjectorPolicyFactory } from "./utils/InjectorPolicyFactory";
|
||||
|
||||
describe("RetryPolicy", () => {
|
||||
let shareName: string;
|
||||
let shareClient: ShareClient;
|
||||
|
||||
let recorder: Recorder;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
recorder = record(this, recorderEnvSetup);
|
||||
const serviceClient = getBSU();
|
||||
shareName = recorder.getUniqueName("share");
|
||||
shareClient = serviceClient.getShareClient(shareName);
|
||||
await shareClient.create();
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
await shareClient.delete();
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("Retry Policy should work when first request fails with 500", async () => {
|
||||
let injectCounter = 0;
|
||||
const injector = new InjectorPolicyFactory(() => {
|
||||
if (injectCounter === 0) {
|
||||
injectCounter++;
|
||||
return new RestError("Server Internal Error", "ServerInternalError", 500);
|
||||
}
|
||||
return;
|
||||
});
|
||||
const factories = (shareClient as any).pipeline.factories.slice(); // clone factories array
|
||||
factories.push(injector);
|
||||
const pipeline = new Pipeline(factories);
|
||||
const injectShareClient = new ShareClient(shareClient.url, pipeline);
|
||||
|
||||
const metadata = {
|
||||
key0: "val0",
|
||||
keya: "vala",
|
||||
keyb: "valb",
|
||||
};
|
||||
await injectShareClient.setMetadata(metadata);
|
||||
|
||||
const result = await shareClient.getProperties();
|
||||
assert.deepEqual(result.metadata, metadata);
|
||||
});
|
||||
|
||||
it("Retry Policy should abort when abort event trigger during retry interval", async () => {
|
||||
let injectCounter = 0;
|
||||
const injector = new InjectorPolicyFactory(() => {
|
||||
if (injectCounter < 2) {
|
||||
injectCounter++;
|
||||
return new RestError("Server Internal Error", "ServerInternalError", 500);
|
||||
}
|
||||
return;
|
||||
});
|
||||
|
||||
const factories = (shareClient as any).pipeline.factories.slice(); // clone factories array
|
||||
factories.push(injector);
|
||||
const pipeline = new Pipeline(factories);
|
||||
const injectShareClient = new ShareClient(shareClient.url, pipeline);
|
||||
|
||||
const metadata = {
|
||||
key0: "val0",
|
||||
keya: "vala",
|
||||
keyb: "valb",
|
||||
};
|
||||
|
||||
let hasError = false;
|
||||
try {
|
||||
// Default exponential retry delay is 4000ms. Wait for 2000ms to abort which makes sure the aborter
|
||||
// happens between 2 requests
|
||||
await injectShareClient.setMetadata(metadata, {
|
||||
abortSignal: AbortController.timeout(2 * 1000),
|
||||
});
|
||||
} catch (err: any) {
|
||||
hasError = true;
|
||||
}
|
||||
assert.ok(hasError);
|
||||
});
|
||||
|
||||
it("Retry Policy should fail when requests always fail with 500", async () => {
|
||||
const injector = new InjectorPolicyFactory(() => {
|
||||
return new RestError("Server Internal Error", "ServerInternalError", 500);
|
||||
});
|
||||
|
||||
const credential = (shareClient as any).pipeline.factories[
|
||||
(shareClient as any).pipeline.factories.length - 1
|
||||
];
|
||||
const factories = newPipeline(credential, {
|
||||
retryOptions: { maxTries: 3 },
|
||||
}).factories;
|
||||
factories.push(injector);
|
||||
const pipeline = new Pipeline(factories);
|
||||
const injectShareClient = new ShareClient(shareClient.url, pipeline);
|
||||
|
||||
let hasError = false;
|
||||
try {
|
||||
const metadata = {
|
||||
key0: "val0",
|
||||
keya: "vala",
|
||||
keyb: "valb",
|
||||
};
|
||||
await injectShareClient.setMetadata(metadata);
|
||||
} catch (err: any) {
|
||||
hasError = true;
|
||||
}
|
||||
assert.ok(hasError);
|
||||
});
|
||||
});
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the MIT license.
|
||||
|
||||
import { assert } from "chai";
|
||||
import { HttpHeaders } from "../src";
|
||||
import {
|
||||
sanitizeHeaders,
|
||||
sanitizeURL,
|
||||
|
@ -11,8 +10,8 @@ import {
|
|||
} from "../src/utils/utils.common";
|
||||
import { record, Recorder } from "@azure-tools/test-recorder";
|
||||
import { recorderEnvSetup } from "./utils";
|
||||
import { URLBuilder } from "@azure/core-http";
|
||||
import { Context } from "mocha";
|
||||
import { createHttpHeaders } from "@azure/core-rest-pipeline";
|
||||
|
||||
describe("Utility Helpers", () => {
|
||||
let recorder: Recorder;
|
||||
|
@ -59,7 +58,7 @@ describe("Utility Helpers", () => {
|
|||
|
||||
it("sanitizeHeaders redacts SAS token", () => {
|
||||
const url = "https://some.url.com/container/blob?sig=sasstring";
|
||||
const headers = new HttpHeaders();
|
||||
const headers = createHttpHeaders();
|
||||
headers.set("authorization", "Bearer abcdefg");
|
||||
headers.set("x-ms-copy-source", url);
|
||||
headers.set("otherheader", url);
|
||||
|
@ -123,44 +122,30 @@ describe("Utility Helpers", () => {
|
|||
|
||||
it("isIpEndpointStyle", async () => {
|
||||
assert.equal(
|
||||
isIpEndpointStyle(
|
||||
URLBuilder.parse("https://192.0.0.10:1900/accountName/containerName/blobName")
|
||||
),
|
||||
isIpEndpointStyle(new URL("https://192.0.0.10:1900/accountName/containerName/blobName")),
|
||||
true
|
||||
);
|
||||
assert.equal(
|
||||
isIpEndpointStyle(
|
||||
URLBuilder.parse(
|
||||
new URL(
|
||||
"https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443/accountName/containerName/blobName"
|
||||
)
|
||||
),
|
||||
true
|
||||
);
|
||||
assert.equal(
|
||||
isIpEndpointStyle(
|
||||
URLBuilder.parse("https://localhost:80/accountName/containerName/blobName")
|
||||
),
|
||||
isIpEndpointStyle(new URL("https://localhost:80/accountName/containerName/blobName")),
|
||||
true
|
||||
);
|
||||
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://192.0.0.10:1900/")), true);
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://192.0.0.10")), true);
|
||||
assert.equal(isIpEndpointStyle(new URL("https://192.0.0.10:1900/")), true);
|
||||
assert.equal(isIpEndpointStyle(new URL("https://192.0.0.10")), true);
|
||||
|
||||
assert.equal(
|
||||
isIpEndpointStyle(
|
||||
URLBuilder.parse("https://2001:db8:85a3:8d3:1319:8a2e:370:7348/accountName/containerName")
|
||||
new URL("https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]/accountName/containerName")
|
||||
),
|
||||
true
|
||||
);
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://2001::1")), true);
|
||||
// assert.equal(isIpEndpointStyle(URLBuilder.parse('https://::1')), true); currently not working due to http url.ts's issue. uncomment after core lib fixed.
|
||||
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://255")), false);
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://255.255")), false);
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://a.b.c.d")), false);
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://256.1.1.1")), false);
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://255.256.1.1")), false);
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://255.255.256.1")), false);
|
||||
assert.equal(isIpEndpointStyle(URLBuilder.parse("https://255.255.255.256")), false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
BaseRequestPolicy,
|
||||
HttpOperationResponse,
|
||||
RequestPolicy,
|
||||
RequestPolicyOptions,
|
||||
RestError,
|
||||
WebResource,
|
||||
} from "../../src";
|
||||
|
||||
export interface NextInjectErrorHolder {
|
||||
nextInjectError?: RestError;
|
||||
}
|
||||
|
||||
export type Injector = () => RestError | undefined;
|
||||
|
||||
/**
|
||||
* InjectorPolicy will inject a customized error before next HTTP request.
|
||||
*/
|
||||
export class InjectorPolicy extends BaseRequestPolicy {
|
||||
/**
|
||||
* Creates an instance of InjectorPolicy.
|
||||
*
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
public constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions, injector: Injector) {
|
||||
super(nextPolicy, options);
|
||||
this.injector = injector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends request.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
public async sendRequest(request: WebResource): Promise<HttpOperationResponse> {
|
||||
const error = this.injector();
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
|
||||
private injector: Injector;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RequestPolicy, RequestPolicyFactory, RequestPolicyOptions } from "../../src";
|
||||
import { Injector, InjectorPolicy } from "./InjectorPolicy";
|
||||
|
||||
/**
|
||||
* InjectorPolicyFactory is a factory class which injects customized errors for retry policy testing.
|
||||
*/
|
||||
export class InjectorPolicyFactory implements RequestPolicyFactory {
|
||||
public readonly injector: Injector;
|
||||
|
||||
public constructor(injector: Injector) {
|
||||
this.injector = injector;
|
||||
}
|
||||
|
||||
public create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): InjectorPolicy {
|
||||
return new InjectorPolicy(nextPolicy, options, this.injector);
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
BaseRequestPolicy,
|
||||
HttpOperationResponse,
|
||||
RequestPolicy,
|
||||
RequestPolicyOptions,
|
||||
WebResource,
|
||||
} from "../../src";
|
||||
|
||||
/**
|
||||
* Mock
|
||||
*/
|
||||
export class MockPolicy extends BaseRequestPolicy {
|
||||
private responseHeaders?: { [key: string]: any };
|
||||
/**
|
||||
* Creates an instance of MockPolicy.
|
||||
*
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
public constructor(
|
||||
nextPolicy: RequestPolicy,
|
||||
options: RequestPolicyOptions,
|
||||
responseHeaders: { [key: string]: any } = {}
|
||||
) {
|
||||
super(nextPolicy, options);
|
||||
this.responseHeaders = responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends request.
|
||||
*
|
||||
* @param request -
|
||||
*/
|
||||
public async sendRequest(request: WebResource): Promise<HttpOperationResponse> {
|
||||
return this._nextPolicy.sendRequest(request).then((res) => {
|
||||
res.parsedHeaders = { ...res.parsedHeaders, ...this.responseHeaders };
|
||||
return res;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RequestPolicy, RequestPolicyFactory, RequestPolicyOptions } from "../../src";
|
||||
import { MockPolicy } from "./MockPolicy";
|
||||
|
||||
/**
|
||||
* MockPolicyFactory is a factory class which tune the response for testing.
|
||||
*/
|
||||
export class MockPolicyFactory implements RequestPolicyFactory {
|
||||
private responseHeaders?: { [key: string]: any };
|
||||
|
||||
public constructor(responseHeaders: { [key: string]: any } = {}) {
|
||||
this.responseHeaders = responseHeaders;
|
||||
}
|
||||
|
||||
public create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): MockPolicy {
|
||||
return new MockPolicy(nextPolicy, options, this.responseHeaders);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { AnonymousCredential } from "../../src/credentials/AnonymousCredential";
|
||||
import { newPipeline } from "../../src/Pipeline";
|
||||
import { AnonymousCredential } from "../../../storage-blob/src/credentials/AnonymousCredential";
|
||||
import { newPipeline } from "../../../storage-blob/src/Pipeline";
|
||||
import { ShareServiceClient } from "../../src/ShareServiceClient";
|
||||
import { createXhrHttpClient } from "@azure/test-utils";
|
||||
import { isLiveMode } from "@azure-tools/test-recorder";
|
||||
import { setTestOnlySetHttpClient } from "../../src/StorageClient";
|
||||
|
||||
export * from "./testutils.common";
|
||||
|
||||
|
@ -11,6 +14,10 @@ export function getGenericBSU(
|
|||
accountType: string,
|
||||
accountNameSuffix: string = ""
|
||||
): ShareServiceClient {
|
||||
// only needed until we can migrate to test recorder v2
|
||||
if (!isLiveMode()) {
|
||||
setTestOnlySetHttpClient(createXhrHttpClient());
|
||||
}
|
||||
const accountNameEnvVar = `${accountType}ACCOUNT_NAME`;
|
||||
const accountSASEnvVar = `${accountType}ACCOUNT_SAS`;
|
||||
|
||||
|
@ -29,6 +36,11 @@ export function getGenericBSU(
|
|||
accountSAS = accountSAS.startsWith("?") ? accountSAS : `?${accountSAS}`;
|
||||
}
|
||||
|
||||
// don't add the test account SAS value.
|
||||
if (accountSAS === "?fakeSasToken") {
|
||||
accountSAS = "";
|
||||
}
|
||||
|
||||
const credentials = new AnonymousCredential();
|
||||
const pipeline = newPipeline(credentials, {
|
||||
// Enable logger when debugging
|
||||
|
@ -118,8 +130,16 @@ export function getBrowserFile(name: string, size: number): File {
|
|||
}
|
||||
|
||||
export function getSASConnectionStringFromEnvironment(): string {
|
||||
if (!isLiveMode()) {
|
||||
setTestOnlySetHttpClient(createXhrHttpClient());
|
||||
}
|
||||
const env = (self as any).__env__;
|
||||
return `BlobEndpoint=https://${env.ACCOUNT_NAME}.blob.core.windows.net/;QueueEndpoint=https://${env.ACCOUNT_NAME}.queue.core.windows.net/;FileEndpoint=https://${env.ACCOUNT_NAME}.file.core.windows.net/;TableEndpoint=https://${env.ACCOUNT_NAME}.table.core.windows.net/;SharedAccessSignature=${env.ACCOUNT_SAS}`;
|
||||
let sasToken: string = env.ACCOUNT_SAS;
|
||||
// connection string SAS doesn't have the prefix
|
||||
if (sasToken && sasToken.startsWith("?")) {
|
||||
sasToken = sasToken.slice(1);
|
||||
}
|
||||
return `BlobEndpoint=https://${env.ACCOUNT_NAME}.blob.core.windows.net/;QueueEndpoint=https://${env.ACCOUNT_NAME}.queue.core.windows.net/;FileEndpoint=https://${env.ACCOUNT_NAME}.file.core.windows.net/;TableEndpoint=https://${env.ACCOUNT_NAME}.table.core.windows.net/;SharedAccessSignature=${sasToken}`;
|
||||
}
|
||||
|
||||
export function arraysEqual(a: Uint8Array, b: Uint8Array): boolean {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { randomBytes } from "crypto";
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import { TokenCredential } from "@azure/core-http";
|
||||
import { TokenCredential } from "@azure/core-auth";
|
||||
import { BlobServiceClient } from "@azure/storage-blob";
|
||||
|
||||
import {
|
||||
|
@ -15,8 +15,8 @@ import {
|
|||
generateAccountSASQueryParameters,
|
||||
SASProtocol,
|
||||
} from "../../src";
|
||||
import { StorageSharedKeyCredential } from "../../src/credentials/StorageSharedKeyCredential";
|
||||
import { newPipeline } from "../../src/Pipeline";
|
||||
import { StorageSharedKeyCredential } from "../../../storage-blob/src/credentials/StorageSharedKeyCredential";
|
||||
import { newPipeline } from "../../../storage-blob/src/Pipeline";
|
||||
import { ShareServiceClient } from "../../src/ShareServiceClient";
|
||||
import { extractConnectionStringParts } from "../../src/utils/utils.common";
|
||||
import { getUniqueName, SimpleTokenCredential } from "./testutils.common";
|
||||
|
@ -150,9 +150,7 @@ export function getSASConnectionStringFromEnvironment(): string {
|
|||
const tmr = new Date();
|
||||
tmr.setDate(tmr.getDate() + 1);
|
||||
const queueServiceClient = getBSU();
|
||||
// By default, credential is always the last element of pipeline factories
|
||||
const factories = (queueServiceClient as any).pipeline.factories;
|
||||
const sharedKeyCredential = factories[factories.length - 1];
|
||||
const sharedKeyCredential = queueServiceClient["credential"];
|
||||
|
||||
const sas = generateAccountSASQueryParameters(
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the MIT license.
|
||||
|
||||
import { env, RecorderEnvironmentSetup } from "@azure-tools/test-recorder";
|
||||
import { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-http";
|
||||
import { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth";
|
||||
|
||||
export function isBrowser(): boolean {
|
||||
return typeof self !== "undefined";
|
||||
|
@ -10,6 +10,7 @@ export function isBrowser(): boolean {
|
|||
|
||||
const mockAccountName = "fakestorageaccount";
|
||||
const mockAccountKey = "aaaaa";
|
||||
const mockSas = "fakeSasToken";
|
||||
const mockSDAccountName = "sd-fakestorageaccount";
|
||||
export const recorderEnvSetup: RecorderEnvironmentSetup = {
|
||||
replaceableVariables: {
|
||||
|
@ -18,18 +19,18 @@ export const recorderEnvSetup: RecorderEnvironmentSetup = {
|
|||
// 2. If the env variables are present in the recordings as plain strings, they will be replaced with the provided values in record mode
|
||||
ACCOUNT_NAME: `${mockAccountName}`,
|
||||
ACCOUNT_KEY: `${mockAccountKey}`,
|
||||
ACCOUNT_SAS: `${mockAccountKey}`,
|
||||
ACCOUNT_SAS: `${mockSas}`,
|
||||
STORAGE_CONNECTION_STRING: `DefaultEndpointsProtocol=https;AccountName=${mockAccountName};AccountKey=${mockAccountKey};EndpointSuffix=core.windows.net`,
|
||||
// Comment following line to skip user delegation key/SAS related cases in record and play
|
||||
// which depends on this environment variable
|
||||
ACCOUNT_TOKEN: `${mockAccountKey}`,
|
||||
SOFT_DELETE_ACCOUNT_NAME: `${mockSDAccountName}`,
|
||||
SOFT_DELETE_ACCOUNT_KEY: `${mockAccountKey}`,
|
||||
SOFT_DELETE_ACCOUNT_SAS: `${mockAccountKey}`,
|
||||
SOFT_DELETE_ACCOUNT_SAS: `${mockSas}`,
|
||||
SOFT_DELETE_STORAGE_CONNECTION_STRING: `DefaultEndpointsProtocol=https;AccountName=${mockSDAccountName};AccountKey=${mockAccountKey};EndpointSuffix=core.windows.net`,
|
||||
PREMIUM_FILE_ACCOUNT_NAME: `${mockAccountName}`,
|
||||
PREMIUM_FILE_ACCOUNT_KEY: `${mockAccountKey}`,
|
||||
PREMIUM_FILE_ACCOUNT_SAS: `${mockAccountKey}`,
|
||||
PREMIUM_FILE_ACCOUNT_SAS: `${mockSas}`,
|
||||
PREMIUM_FILE_STORAGE_CONNECTION_STRING: `DefaultEndpointsProtocol=https;AccountName=${mockSDAccountName};AccountKey=${mockAccountKey};EndpointSuffix=core.windows.net`,
|
||||
},
|
||||
customizationsOnRecordings: [
|
||||
|
|
|
@ -9,5 +9,10 @@
|
|||
"@azure/storage-file-share": ["./src/index"]
|
||||
}
|
||||
},
|
||||
"include": ["./src/**/*.ts", "./test/**/*.ts", "./samples-dev/**/*.ts"]
|
||||
"include": [
|
||||
"./src/**/*.ts",
|
||||
"./test/**/*.ts",
|
||||
"./samples-dev/**/*.ts",
|
||||
"../storage-blob/src/**/*.ts"
|
||||
]
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче