Files
powerpoint-toolbox/node_modules/@azure/arm-storage/dist-esm/src/storageManagementClient.js
T
2025-03-07 19:22:02 +01:00

117 lines
6.1 KiB
JavaScript

/*
* 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 { __awaiter } from "tslib";
import * as coreClient from "@azure/core-client";
import * as coreRestPipeline from "@azure/core-rest-pipeline";
import { OperationsImpl, SkusImpl, StorageAccountsImpl, DeletedAccountsImpl, UsagesImpl, ManagementPoliciesImpl, BlobInventoryPoliciesImpl, PrivateEndpointConnectionsImpl, PrivateLinkResourcesImpl, ObjectReplicationPoliciesOperationsImpl, LocalUsersOperationsImpl, EncryptionScopesImpl, BlobServicesImpl, BlobContainersImpl, FileServicesImpl, FileSharesImpl, QueueServicesImpl, QueueImpl, TableServicesImpl, TableOperationsImpl } from "./operations";
export class StorageManagementClient extends coreClient.ServiceClient {
/**
* Initializes a new instance of the StorageManagementClient class.
* @param credentials Subscription credentials which uniquely identify client subscription.
* @param subscriptionId The ID of the target subscription.
* @param options The parameter options
*/
constructor(credentials, subscriptionId, options) {
var _a, _b;
if (credentials === undefined) {
throw new Error("'credentials' cannot be null");
}
if (subscriptionId === undefined) {
throw new Error("'subscriptionId' cannot be null");
}
// Initializing default values for options
if (!options) {
options = {};
}
const defaults = {
requestContentType: "application/json; charset=utf-8",
credential: credentials
};
const packageDetails = `azsdk-js-arm-storage/17.2.1`;
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
: `${packageDetails}`;
if (!options.credentialScopes) {
options.credentialScopes = ["https://management.azure.com/.default"];
}
const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
userAgentPrefix
}, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
super(optionsWithDefaults);
if ((options === null || options === void 0 ? void 0 : options.pipeline) && options.pipeline.getOrderedPolicies().length > 0) {
const pipelinePolicies = options.pipeline.getOrderedPolicies();
const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
coreRestPipeline.bearerTokenAuthenticationPolicyName);
if (!bearerTokenAuthenticationPolicyFound) {
this.pipeline.removePolicy({
name: coreRestPipeline.bearerTokenAuthenticationPolicyName
});
this.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
scopes: `${optionsWithDefaults.baseUri}/.default`,
challengeCallbacks: {
authorizeRequestOnChallenge: coreClient.authorizeRequestOnClaimChallenge
}
}));
}
}
// Parameter assignments
this.subscriptionId = subscriptionId;
// Assigning values to Constant parameters
this.$host = options.$host || "https://management.azure.com";
this.apiVersion = options.apiVersion || "2021-09-01";
this.operations = new OperationsImpl(this);
this.skus = new SkusImpl(this);
this.storageAccounts = new StorageAccountsImpl(this);
this.deletedAccounts = new DeletedAccountsImpl(this);
this.usages = new UsagesImpl(this);
this.managementPolicies = new ManagementPoliciesImpl(this);
this.blobInventoryPolicies = new BlobInventoryPoliciesImpl(this);
this.privateEndpointConnections = new PrivateEndpointConnectionsImpl(this);
this.privateLinkResources = new PrivateLinkResourcesImpl(this);
this.objectReplicationPoliciesOperations = new ObjectReplicationPoliciesOperationsImpl(this);
this.localUsersOperations = new LocalUsersOperationsImpl(this);
this.encryptionScopes = new EncryptionScopesImpl(this);
this.blobServices = new BlobServicesImpl(this);
this.blobContainers = new BlobContainersImpl(this);
this.fileServices = new FileServicesImpl(this);
this.fileShares = new FileSharesImpl(this);
this.queueServices = new QueueServicesImpl(this);
this.queue = new QueueImpl(this);
this.tableServices = new TableServicesImpl(this);
this.tableOperations = new TableOperationsImpl(this);
this.addCustomApiVersionPolicy(options.apiVersion);
}
/** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
addCustomApiVersionPolicy(apiVersion) {
if (!apiVersion) {
return;
}
const apiVersionPolicy = {
name: "CustomApiVersionPolicy",
sendRequest(request, next) {
return __awaiter(this, void 0, void 0, function* () {
const param = request.url.split("?");
if (param.length > 1) {
const newParams = param[1].split("&").map((item) => {
if (item.indexOf("api-version") > -1) {
return item.replace(/(?<==).*$/, apiVersion);
}
else {
return item;
}
});
request.url = param[0] + "?" + newParams.join("&");
}
return next(request);
});
}
};
this.pipeline.addPolicy(apiVersionPolicy);
}
}
//# sourceMappingURL=storageManagementClient.js.map