@azure/keyvault-certificates
Version:
Azure Key Vault Certificates
106 lines (105 loc) • 4.13 kB
JavaScript
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, {
DeleteCertificatePollOperation: () => DeleteCertificatePollOperation
});
module.exports = __toCommonJS(operation_exports);
var import_keyVaultCertificatePoller = require("../keyVaultCertificatePoller.js");
var import_transformations = require("../../transformations.js");
var import_tracing = require("../../tracing.js");
class DeleteCertificatePollOperation extends import_keyVaultCertificatePoller.KeyVaultCertificatePollOperation {
constructor(state, client, operationOptions = {}) {
super(state, { cancelMessage: "Canceling the deletion of a certificate is not supported." });
this.state = state;
this.client = client;
this.operationOptions = operationOptions;
}
state;
client;
operationOptions;
/**
* The DELETE operation applies to any certificate stored in Azure Key Vault. DELETE cannot be applied
* to an individual version of a certificate. This operation requires the certificates/delete permission.
*/
deleteCertificate(certificateName, options = {}) {
return import_tracing.tracingClient.withSpan(
"DeleteCertificatePoller.deleteCertificate",
options,
async (updatedOptions) => {
const response = await this.client.deleteCertificate(certificateName, updatedOptions);
return (0, import_transformations.getDeletedCertificateFromDeletedCertificateBundle)(response);
}
);
}
/**
* Retrieves the deleted certificate information plus its attributes, such as retention interval, scheduled permanent deletion and the
* current deletion recovery level. This operation requires the certificates/get permission.
*/
async getDeletedCertificate(certificateName, options = {}) {
return import_tracing.tracingClient.withSpan(
"DeleteCertificatePoller.getDeletedCertificate",
options,
async (updatedOptions) => {
const response = await this.client.getDeletedCertificate(certificateName, updatedOptions);
return (0, import_transformations.getDeletedCertificateFromDeletedCertificateBundle)(response);
}
);
}
/**
* Reaches to the service and updates the delete certificate's poll operation.
*/
async update(options = {}) {
const state = this.state;
const { certificateName } = state;
if (options.abortSignal) {
this.operationOptions.abortSignal = options.abortSignal;
}
if (!state.isStarted) {
const deletedCertificate = await this.deleteCertificate(
certificateName,
this.operationOptions
);
state.isStarted = true;
state.result = deletedCertificate;
if (!deletedCertificate.recoveryId) {
state.isCompleted = true;
}
}
if (!state.isCompleted) {
try {
state.result = await this.getDeletedCertificate(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 = {
DeleteCertificatePollOperation
});
//# sourceMappingURL=operation.js.map