Commit iniziale

This commit is contained in:
Paolo A
2025-02-18 22:59:07 +00:00
commit 4bbf35cefb
6879 changed files with 623784 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import { AbortSignalLike } from "@azure/abort-controller";
import { OperationOptions } from "@azure/core-client";
import { KeyVaultClient } from "../../generated/keyVaultClient.js";
import { DeletedKey } from "../../keysModels.js";
import { KeyVaultKeyPollOperation, KeyVaultKeyPollOperationState } from "../keyVaultKeyPoller.js";
/**
* An interface representing the state of a delete key's poll operation
*/
export interface DeleteKeyPollOperationState extends KeyVaultKeyPollOperationState<DeletedKey> {
}
export declare class DeleteKeyPollOperation extends KeyVaultKeyPollOperation<DeleteKeyPollOperationState, DeletedKey> {
state: DeleteKeyPollOperationState;
private vaultUrl;
private client;
private operationOptions;
constructor(state: DeleteKeyPollOperationState, vaultUrl: string, client: KeyVaultClient, operationOptions?: OperationOptions);
/**
* Sends a delete request for the given Key Vault Key's name to the Key Vault service.
* Since the Key Vault Key won't be immediately deleted, we have {@link beginDeleteKey}.
*/
private deleteKey;
/**
* The getDeletedKey method returns the specified deleted key along with its properties.
* This operation requires the keys/get permission.
*/
private getDeletedKey;
/**
* Reaches to the service and updates the delete key's poll operation.
*/
update(options?: {
abortSignal?: AbortSignalLike;
fireProgress?: (state: DeleteKeyPollOperationState) => void;
}): Promise<DeleteKeyPollOperation>;
}
//# sourceMappingURL=operation.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../../src/lro/delete/operation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAoB,UAAU,EAAwB,MAAM,qBAAqB,CAAC;AAGzF,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,6BAA6B,CAAC,UAAU,CAAC;CAAG;AAEjG,qBAAa,sBAAuB,SAAQ,wBAAwB,CAClE,2BAA2B,EAC3B,UAAU,CACX;IAEU,KAAK,EAAE,2BAA2B;IACzC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,gBAAgB;gBAHjB,KAAK,EAAE,2BAA2B,EACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,EACtB,gBAAgB,GAAE,gBAAqB;IAKjD;;;OAGG;IACH,OAAO,CAAC,SAAS;IAOjB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACU,MAAM,CACjB,OAAO,GAAE;QACP,WAAW,CAAC,EAAE,eAAe,CAAC;QAC9B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;KACxD,GACL,OAAO,CAAC,sBAAsB,CAAC;CAmCnC"}

View File

@@ -0,0 +1,75 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteKeyPollOperation = void 0;
const tracing_js_1 = require("../../tracing.js");
const transformations_js_1 = require("../../transformations.js");
const keyVaultKeyPoller_js_1 = require("../keyVaultKeyPoller.js");
class DeleteKeyPollOperation extends keyVaultKeyPoller_js_1.KeyVaultKeyPollOperation {
constructor(state, vaultUrl, client, operationOptions = {}) {
super(state, { cancelMessage: "Canceling the deletion of a key is not supported." });
this.state = state;
this.vaultUrl = vaultUrl;
this.client = client;
this.operationOptions = operationOptions;
}
/**
* Sends a delete request for the given Key Vault Key's name to the Key Vault service.
* Since the Key Vault Key won't be immediately deleted, we have {@link beginDeleteKey}.
*/
deleteKey(name, options = {}) {
return tracing_js_1.tracingClient.withSpan("DeleteKeyPoller.deleteKey", options, async (updatedOptions) => {
const response = await this.client.deleteKey(this.vaultUrl, name, updatedOptions);
return (0, transformations_js_1.getKeyFromKeyBundle)(response);
});
}
/**
* The getDeletedKey method returns the specified deleted key along with its properties.
* This operation requires the keys/get permission.
*/
getDeletedKey(name, options = {}) {
return tracing_js_1.tracingClient.withSpan("DeleteKeyPoller.getDeletedKey", options, async (updatedOptions) => {
const response = await this.client.getDeletedKey(this.vaultUrl, name, updatedOptions);
return (0, transformations_js_1.getKeyFromKeyBundle)(response);
});
}
/**
* Reaches to the service and updates the delete key's poll operation.
*/
async update(options = {}) {
const state = this.state;
const { name } = state;
if (options.abortSignal) {
this.operationOptions.abortSignal = options.abortSignal;
}
if (!state.isStarted) {
const deletedKey = await this.deleteKey(name, this.operationOptions);
state.isStarted = true;
state.result = deletedKey;
if (!deletedKey.properties.recoveryId) {
state.isCompleted = true;
}
}
if (!state.isCompleted) {
try {
state.result = await this.getDeletedKey(name, this.operationOptions);
state.isCompleted = true;
}
catch (error) {
if (error.statusCode === 403) {
// At this point, the resource exists but the user doesn't have access to it.
state.isCompleted = true;
}
else if (error.statusCode !== 404) {
state.error = error;
state.isCompleted = true;
throw error;
}
}
}
return this;
}
}
exports.DeleteKeyPollOperation = DeleteKeyPollOperation;
//# sourceMappingURL=operation.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
import { DeleteKeyPollOperationState } from "./operation.js";
import { DeletedKey } from "../../keysModels.js";
import { KeyVaultKeyPoller, KeyVaultKeyPollerOptions } from "../keyVaultKeyPoller.js";
/**
* Class that creates a poller that waits until a key finishes being deleted.
*/
export declare class DeleteKeyPoller extends KeyVaultKeyPoller<DeleteKeyPollOperationState, DeletedKey> {
constructor(options: KeyVaultKeyPollerOptions);
}
//# sourceMappingURL=poller.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"poller.d.ts","sourceRoot":"","sources":["../../../../src/lro/delete/poller.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEtF;;GAEG;AACH,qBAAa,eAAgB,SAAQ,iBAAiB,CAAC,2BAA2B,EAAE,UAAU,CAAC;gBACjF,OAAO,EAAE,wBAAwB;CAuB9C"}

View File

@@ -0,0 +1,24 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteKeyPoller = void 0;
const operation_js_1 = require("./operation.js");
const keyVaultKeyPoller_js_1 = require("../keyVaultKeyPoller.js");
/**
* Class that creates a poller that waits until a key finishes being deleted.
*/
class DeleteKeyPoller extends keyVaultKeyPoller_js_1.KeyVaultKeyPoller {
constructor(options) {
const { vaultUrl, client, name, operationOptions, intervalInMs = 2000, resumeFrom } = options;
let state;
if (resumeFrom) {
state = JSON.parse(resumeFrom).state;
}
const operation = new operation_js_1.DeleteKeyPollOperation(Object.assign(Object.assign({}, state), { name }), vaultUrl, client, operationOptions);
super(operation);
this.intervalInMs = intervalInMs;
}
}
exports.DeleteKeyPoller = DeleteKeyPoller;
//# sourceMappingURL=poller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../src/lro/delete/poller.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,iDAAqF;AAErF,kEAAsF;AAEtF;;GAEG;AACH,MAAa,eAAgB,SAAQ,wCAA0D;IAC7F,YAAY,OAAiC;QAC3C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,YAAY,GAAG,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAE9F,IAAI,KAA8C,CAAC;QAEnD,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;QACvC,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,qCAAsB,iCAErC,KAAK,KACR,IAAI,KAEN,QAAQ,EACR,MAAM,EACN,gBAAgB,CACjB,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAxBD,0CAwBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { DeleteKeyPollOperation, DeleteKeyPollOperationState } from \"./operation.js\";\nimport { DeletedKey } from \"../../keysModels.js\";\nimport { KeyVaultKeyPoller, KeyVaultKeyPollerOptions } from \"../keyVaultKeyPoller.js\";\n\n/**\n * Class that creates a poller that waits until a key finishes being deleted.\n */\nexport class DeleteKeyPoller extends KeyVaultKeyPoller<DeleteKeyPollOperationState, DeletedKey> {\n constructor(options: KeyVaultKeyPollerOptions) {\n const { vaultUrl, client, name, operationOptions, intervalInMs = 2000, resumeFrom } = options;\n\n let state: DeleteKeyPollOperationState | undefined;\n\n if (resumeFrom) {\n state = JSON.parse(resumeFrom).state;\n }\n\n const operation = new DeleteKeyPollOperation(\n {\n ...state,\n name,\n },\n vaultUrl,\n client,\n operationOptions,\n );\n\n super(operation);\n\n this.intervalInMs = intervalInMs;\n }\n}\n"]}

View File

@@ -0,0 +1,63 @@
import { OperationOptions } from "@azure/core-client";
import { Poller, PollOperation, PollOperationState } from "@azure/core-lro";
import { KeyVaultClient } from "../generated/keyVaultClient.js";
/**
* Common parameters to a Key Vault Key Poller.
*/
export interface KeyVaultKeyPollerOptions {
vaultUrl: string;
client: KeyVaultClient;
name: string;
operationOptions?: OperationOptions;
intervalInMs?: number;
resumeFrom?: string;
}
/**
* An interface representing the state of a Key Vault Key Poller's operation.
*/
export interface KeyVaultKeyPollOperationState<TResult> extends PollOperationState<TResult> {
/**
* The name of the key.
*/
name: string;
}
/**
* Common properties and methods of the Key Vault Key Pollers.
*/
export declare abstract class KeyVaultKeyPoller<TState extends KeyVaultKeyPollOperationState<TResult>, TResult> extends Poller<TState, TResult> {
/**
* Defines how much time the poller is going to wait before making a new request to the service.
*/
intervalInMs: number;
/**
* The method used by the poller to wait before attempting to update its operation.
*/
delay(): Promise<void>;
}
/**
* Optional parameters to the KeyVaultKeyPollOperation
*/
export interface KeyVaultKeyPollOperationOptions {
cancelMessage?: string;
}
/**
* Common properties and methods of the Key Vault Key Poller operations.
*/
export declare class KeyVaultKeyPollOperation<TState, TResult> implements PollOperation<TState, TResult> {
state: TState;
private cancelMessage;
constructor(state: TState, options?: KeyVaultKeyPollOperationOptions);
/**
* Meant to reach to the service and update the Poller operation.
*/
update(): Promise<PollOperation<TState, TResult>>;
/**
* Meant to reach to the service and cancel the Poller operation.
*/
cancel(): Promise<PollOperation<TState, TResult>>;
/**
* Serializes the Poller operation.
*/
toString(): string;
}
//# sourceMappingURL=keyVaultKeyPoller.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"keyVaultKeyPoller.d.ts","sourceRoot":"","sources":["../../../src/lro/keyVaultKeyPoller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B,CAAC,OAAO,CAAE,SAAQ,kBAAkB,CAAC,OAAO,CAAC;IACzF;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,8BAAsB,iBAAiB,CACrC,MAAM,SAAS,6BAA6B,CAAC,OAAO,CAAC,EACrD,OAAO,CACP,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACI,YAAY,EAAE,MAAM,CAAQ;IAEnC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAE,YAAW,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC;IAIrF,KAAK,EAAE,MAAM;IAHtB,OAAO,CAAC,aAAa,CAAc;gBAG1B,KAAK,EAAE,MAAM,EACpB,OAAO,GAAE,+BAAoC;IAO/C;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAI9D;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAI9D;;OAEG;IACI,QAAQ,IAAI,MAAM;CAK1B"}

View File

@@ -0,0 +1,60 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyVaultKeyPollOperation = exports.KeyVaultKeyPoller = void 0;
const core_util_1 = require("@azure/core-util");
const core_lro_1 = require("@azure/core-lro");
/**
* Common properties and methods of the Key Vault Key Pollers.
*/
class KeyVaultKeyPoller extends core_lro_1.Poller {
constructor() {
super(...arguments);
/**
* Defines how much time the poller is going to wait before making a new request to the service.
*/
this.intervalInMs = 2000;
}
/**
* The method used by the poller to wait before attempting to update its operation.
*/
async delay() {
return (0, core_util_1.delay)(this.intervalInMs);
}
}
exports.KeyVaultKeyPoller = KeyVaultKeyPoller;
/**
* Common properties and methods of the Key Vault Key Poller operations.
*/
class KeyVaultKeyPollOperation {
constructor(state, options = {}) {
this.state = state;
this.cancelMessage = "";
if (options.cancelMessage) {
this.cancelMessage = options.cancelMessage;
}
}
/**
* Meant to reach to the service and update the Poller operation.
*/
async update() {
throw new Error("Operation not supported.");
}
/**
* Meant to reach to the service and cancel the Poller operation.
*/
async cancel() {
throw new Error(this.cancelMessage);
}
/**
* Serializes the Poller operation.
*/
toString() {
return JSON.stringify({
state: this.state,
});
}
}
exports.KeyVaultKeyPollOperation = KeyVaultKeyPollOperation;
//# sourceMappingURL=keyVaultKeyPoller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"keyVaultKeyPoller.js","sourceRoot":"","sources":["../../../src/lro/keyVaultKeyPoller.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,gDAAyC;AACzC,8CAA4E;AAyB5E;;GAEG;AACH,MAAsB,iBAGpB,SAAQ,iBAAuB;IAHjC;;QAIE;;WAEG;QACI,iBAAY,GAAW,IAAI,CAAC;IAQrC,CAAC;IANC;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,OAAO,IAAA,iBAAK,EAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;CACF;AAfD,8CAeC;AASD;;GAEG;AACH,MAAa,wBAAwB;IAGnC,YACS,KAAa,EACpB,UAA2C,EAAE;QADtC,UAAK,GAAL,KAAK,CAAQ;QAHd,kBAAa,GAAW,EAAE,CAAC;QAMjC,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;YAC1B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC7C,CAAC;IACH,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM;QACjB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM;QACjB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;CACF;AAlCD,4DAkCC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { OperationOptions } from \"@azure/core-client\";\nimport { delay } from \"@azure/core-util\";\nimport { Poller, PollOperation, PollOperationState } from \"@azure/core-lro\";\nimport { KeyVaultClient } from \"../generated/keyVaultClient.js\";\n\n/**\n * Common parameters to a Key Vault Key Poller.\n */\nexport interface KeyVaultKeyPollerOptions {\n vaultUrl: string;\n client: KeyVaultClient;\n name: string;\n operationOptions?: OperationOptions;\n intervalInMs?: number;\n resumeFrom?: string;\n}\n\n/**\n * An interface representing the state of a Key Vault Key Poller's operation.\n */\nexport interface KeyVaultKeyPollOperationState<TResult> extends PollOperationState<TResult> {\n /**\n * The name of the key.\n */\n name: string;\n}\n\n/**\n * Common properties and methods of the Key Vault Key Pollers.\n */\nexport abstract class KeyVaultKeyPoller<\n TState extends KeyVaultKeyPollOperationState<TResult>,\n TResult,\n> extends Poller<TState, TResult> {\n /**\n * Defines how much time the poller is going to wait before making a new request to the service.\n */\n public intervalInMs: number = 2000;\n\n /**\n * The method used by the poller to wait before attempting to update its operation.\n */\n async delay(): Promise<void> {\n return delay(this.intervalInMs);\n }\n}\n\n/**\n * Optional parameters to the KeyVaultKeyPollOperation\n */\nexport interface KeyVaultKeyPollOperationOptions {\n cancelMessage?: string;\n}\n\n/**\n * Common properties and methods of the Key Vault Key Poller operations.\n */\nexport class KeyVaultKeyPollOperation<TState, TResult> implements PollOperation<TState, TResult> {\n private cancelMessage: string = \"\";\n\n constructor(\n public state: TState,\n options: KeyVaultKeyPollOperationOptions = {},\n ) {\n if (options.cancelMessage) {\n this.cancelMessage = options.cancelMessage;\n }\n }\n\n /**\n * Meant to reach to the service and update the Poller operation.\n */\n public async update(): Promise<PollOperation<TState, TResult>> {\n throw new Error(\"Operation not supported.\");\n }\n\n /**\n * Meant to reach to the service and cancel the Poller operation.\n */\n public async cancel(): Promise<PollOperation<TState, TResult>> {\n throw new Error(this.cancelMessage);\n }\n\n /**\n * Serializes the Poller operation.\n */\n public toString(): string {\n return JSON.stringify({\n state: this.state,\n });\n }\n}\n"]}

View File

@@ -0,0 +1,35 @@
import { AbortSignalLike } from "@azure/abort-controller";
import { OperationOptions } from "@azure/core-client";
import { KeyVaultClient } from "../../generated/keyVaultClient.js";
import { KeyVaultKey } from "../../keysModels.js";
import { KeyVaultKeyPollOperation, KeyVaultKeyPollOperationState } from "../keyVaultKeyPoller.js";
/**
* An interface representing the state of a delete key's poll operation
*/
export interface RecoverDeletedKeyPollOperationState extends KeyVaultKeyPollOperationState<KeyVaultKey> {
}
export declare class RecoverDeletedKeyPollOperation extends KeyVaultKeyPollOperation<RecoverDeletedKeyPollOperationState, KeyVaultKey> {
state: RecoverDeletedKeyPollOperationState;
private vaultUrl;
private client;
private operationOptions;
constructor(state: RecoverDeletedKeyPollOperationState, vaultUrl: string, client: KeyVaultClient, operationOptions?: OperationOptions);
/**
* The getKey method gets a specified key and is applicable to any key stored in Azure Key Vault.
* This operation requires the keys/get permission.
*/
private getKey;
/**
* Sends a request to recover a deleted Key Vault Key based on the given name.
* Since the Key Vault Key won't be immediately recover the deleted key, we have {@link beginRecoverDeletedKey}.
*/
private recoverDeletedKey;
/**
* Reaches to the service and updates the delete key's poll operation.
*/
update(options?: {
abortSignal?: AbortSignalLike;
fireProgress?: (state: RecoverDeletedKeyPollOperationState) => void;
}): Promise<RecoverDeletedKeyPollOperation>;
}
//# sourceMappingURL=operation.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../../src/lro/recover/operation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAiB,WAAW,EAA4B,MAAM,qBAAqB,CAAC;AAG3F,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,mCACf,SAAQ,6BAA6B,CAAC,WAAW,CAAC;CAAG;AAEvD,qBAAa,8BAA+B,SAAQ,wBAAwB,CAC1E,mCAAmC,EACnC,WAAW,CACZ;IAEU,KAAK,EAAE,mCAAmC;IACjD,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,gBAAgB;gBAHjB,KAAK,EAAE,mCAAmC,EACzC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,EACtB,gBAAgB,GAAE,gBAAqB;IAKjD;;;OAGG;IACH,OAAO,CAAC,MAAM;IAgBd;;;OAGG;YACW,iBAAiB;IAc/B;;OAEG;IACU,MAAM,CACjB,OAAO,GAAE;QACP,WAAW,CAAC,EAAE,eAAe,CAAC;QAC9B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,mCAAmC,KAAK,IAAI,CAAC;KAChE,GACL,OAAO,CAAC,8BAA8B,CAAC;CAwC3C"}

View File

@@ -0,0 +1,81 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.RecoverDeletedKeyPollOperation = void 0;
const tracing_js_1 = require("../../tracing.js");
const transformations_js_1 = require("../../transformations.js");
const keyVaultKeyPoller_js_1 = require("../keyVaultKeyPoller.js");
class RecoverDeletedKeyPollOperation extends keyVaultKeyPoller_js_1.KeyVaultKeyPollOperation {
constructor(state, vaultUrl, client, operationOptions = {}) {
super(state, { cancelMessage: "Canceling the recovery of a deleted key is not supported." });
this.state = state;
this.vaultUrl = vaultUrl;
this.client = client;
this.operationOptions = operationOptions;
}
/**
* The getKey method gets a specified key and is applicable to any key stored in Azure Key Vault.
* This operation requires the keys/get permission.
*/
getKey(name, options = {}) {
return tracing_js_1.tracingClient.withSpan("RecoverDeleteKeyPoller.getKey", options, async (updatedOptions) => {
const response = await this.client.getKey(this.vaultUrl, name, (updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.version) || "", updatedOptions);
return (0, transformations_js_1.getKeyFromKeyBundle)(response);
});
}
/**
* Sends a request to recover a deleted Key Vault Key based on the given name.
* Since the Key Vault Key won't be immediately recover the deleted key, we have {@link beginRecoverDeletedKey}.
*/
async recoverDeletedKey(name, options = {}) {
return tracing_js_1.tracingClient.withSpan("RecoverDeletedKeyPoller.recoverDeleteKey", options, async (updatedOptions) => {
const response = await this.client.recoverDeletedKey(this.vaultUrl, name, updatedOptions);
return (0, transformations_js_1.getKeyFromKeyBundle)(response);
});
}
/**
* Reaches to the service and updates the delete key's poll operation.
*/
async update(options = {}) {
const state = this.state;
const { name } = state;
const operationOptions = this.operationOptions;
if (options.abortSignal) {
operationOptions.abortSignal = options.abortSignal;
}
if (!state.isStarted) {
try {
state.result = await this.getKey(name, operationOptions);
state.isCompleted = true;
}
catch (_a) {
// Nothing to do here.
}
if (!state.isCompleted) {
state.result = await this.recoverDeletedKey(name, operationOptions);
state.isStarted = true;
}
}
if (!state.isCompleted) {
try {
state.result = await this.getKey(name, operationOptions);
state.isCompleted = true;
}
catch (error) {
if (error.statusCode === 403) {
// At this point, the resource exists but the user doesn't have access to it.
state.isCompleted = true;
}
else if (error.statusCode !== 404) {
state.error = error;
state.isCompleted = true;
throw error;
}
}
}
return this;
}
}
exports.RecoverDeletedKeyPollOperation = RecoverDeletedKeyPollOperation;
//# sourceMappingURL=operation.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
import { RecoverDeletedKeyPollOperationState } from "./operation.js";
import { KeyVaultKey } from "../../keysModels.js";
import { KeyVaultKeyPoller, KeyVaultKeyPollerOptions } from "../keyVaultKeyPoller.js";
/**
* Class that deletes a poller that waits until a key finishes being deleted
*/
export declare class RecoverDeletedKeyPoller extends KeyVaultKeyPoller<RecoverDeletedKeyPollOperationState, KeyVaultKey> {
constructor(options: KeyVaultKeyPollerOptions);
}
//# sourceMappingURL=poller.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"poller.d.ts","sourceRoot":"","sources":["../../../../src/lro/recover/poller.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,mCAAmC,EACpC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEtF;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,iBAAiB,CAC5D,mCAAmC,EACnC,WAAW,CACZ;gBACa,OAAO,EAAE,wBAAwB;CAuB9C"}

View File

@@ -0,0 +1,24 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.RecoverDeletedKeyPoller = void 0;
const operation_js_1 = require("./operation.js");
const keyVaultKeyPoller_js_1 = require("../keyVaultKeyPoller.js");
/**
* Class that deletes a poller that waits until a key finishes being deleted
*/
class RecoverDeletedKeyPoller extends keyVaultKeyPoller_js_1.KeyVaultKeyPoller {
constructor(options) {
const { vaultUrl, client, name, operationOptions, intervalInMs = 2000, resumeFrom } = options;
let state;
if (resumeFrom) {
state = JSON.parse(resumeFrom).state;
}
const operation = new operation_js_1.RecoverDeletedKeyPollOperation(Object.assign(Object.assign({}, state), { name }), vaultUrl, client, operationOptions);
super(operation);
this.intervalInMs = intervalInMs;
}
}
exports.RecoverDeletedKeyPoller = RecoverDeletedKeyPoller;
//# sourceMappingURL=poller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../src/lro/recover/poller.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,iDAGwB;AAExB,kEAAsF;AAEtF;;GAEG;AACH,MAAa,uBAAwB,SAAQ,wCAG5C;IACC,YAAY,OAAiC;QAC3C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,YAAY,GAAG,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAE9F,IAAI,KAAsD,CAAC;QAE3D,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;QACvC,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,6CAA8B,iCAE7C,KAAK,KACR,IAAI,KAEN,QAAQ,EACR,MAAM,EACN,gBAAgB,CACjB,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AA3BD,0DA2BC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n RecoverDeletedKeyPollOperation,\n RecoverDeletedKeyPollOperationState,\n} from \"./operation.js\";\nimport { KeyVaultKey } from \"../../keysModels.js\";\nimport { KeyVaultKeyPoller, KeyVaultKeyPollerOptions } from \"../keyVaultKeyPoller.js\";\n\n/**\n * Class that deletes a poller that waits until a key finishes being deleted\n */\nexport class RecoverDeletedKeyPoller extends KeyVaultKeyPoller<\n RecoverDeletedKeyPollOperationState,\n KeyVaultKey\n> {\n constructor(options: KeyVaultKeyPollerOptions) {\n const { vaultUrl, client, name, operationOptions, intervalInMs = 2000, resumeFrom } = options;\n\n let state: RecoverDeletedKeyPollOperationState | undefined;\n\n if (resumeFrom) {\n state = JSON.parse(resumeFrom).state;\n }\n\n const operation = new RecoverDeletedKeyPollOperation(\n {\n ...state,\n name,\n },\n vaultUrl,\n client,\n operationOptions,\n );\n\n super(operation);\n\n this.intervalInMs = intervalInMs;\n }\n}\n"]}