UNPKG

@azure/keyvault-certificates

Version:
110 lines (109 loc) 4.16 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var operation_exports = {}; __export(operation_exports, { RecoverDeletedCertificatePollOperation: () => RecoverDeletedCertificatePollOperation }); module.exports = __toCommonJS(operation_exports); var import_tracing = require("../../tracing.js"); var import_transformations = require("../../transformations.js"); var import_keyVaultCertificatePoller = require("../keyVaultCertificatePoller.js"); class RecoverDeletedCertificatePollOperation extends import_keyVaultCertificatePoller.KeyVaultCertificatePollOperation { constructor(state, client, operationOptions = {}) { super(state, { cancelMessage: "Canceling the recovery of a deleted certificate is not supported." }); this.state = state; this.client = client; this.operationOptions = operationOptions; } state; client; operationOptions; /** * Gets the latest information available from a specific certificate, including the certificate's policy. This operation requires the certificates/get permission. */ getCertificate(certificateName, options = {}) { return import_tracing.tracingClient.withSpan( "RecoverDeletedCertificatePoller.getCertificate", options, async (updatedOptions) => { const result = await this.client.getCertificate(certificateName, "", updatedOptions); return (0, import_transformations.getCertificateWithPolicyFromCertificateBundle)(result); } ); } /** * Recovers the deleted certificate in the specified vault. This operation can only be performed on a soft-delete enabled vault. This operation * requires the certificate/recover permission. */ recoverDeletedCertificate(certificateName, options = {}) { return import_tracing.tracingClient.withSpan( "RecoverDeletedCertificatePoller.recoverDeletedCertificate", options, async (updatedOptions) => { const response = await this.client.recoverDeletedCertificate( certificateName, updatedOptions ); return (0, import_transformations.getCertificateWithPolicyFromCertificateBundle)(response); } ); } /** * Reaches to the service and updates the poll operation. */ async update(options = {}) { const state = this.state; const { certificateName } = state; if (options.abortSignal) { this.operationOptions.abortSignal = options.abortSignal; } if (!state.isStarted) { try { state.result = await this.getCertificate(certificateName, this.operationOptions); state.isCompleted = true; } catch (e) { } if (!state.isCompleted) { state.result = await this.recoverDeletedCertificate(certificateName, this.operationOptions); state.isStarted = true; } } if (!state.isCompleted) { try { state.result = await this.getCertificate(certificateName, this.operationOptions); state.isCompleted = true; } catch (error) { if (error.statusCode === 403) { state.isCompleted = true; } else if (error.statusCode !== 404) { state.error = error; state.isCompleted = true; throw error; } } } return this; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { RecoverDeletedCertificatePollOperation }); //# sourceMappingURL=operation.js.map