@azure/keyvault-certificates
Version:
Azure Key Vault Certificates
144 lines (143 loc) • 5.36 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, {
CertificateOperationPollOperation: () => CertificateOperationPollOperation
});
module.exports = __toCommonJS(operation_exports);
var import_keyVaultCertificatePoller = require("../keyVaultCertificatePoller.js");
var import_transformations = require("../../transformations.js");
var import_tracing = require("../../tracing.js");
class CertificateOperationPollOperation extends import_keyVaultCertificatePoller.KeyVaultCertificatePollOperation {
constructor(state, client, operationOptions = {}) {
super(state);
this.state = state;
this.client = client;
this.operationOptions = operationOptions;
}
state;
client;
operationOptions;
/**
* Cancels a certificate creation operation that is already in progress. This operation requires the certificates/update permission.
*/
cancelCertificateOperation(certificateName, options = {}) {
return import_tracing.tracingClient.withSpan(
"CertificateOperationPoller.cancelCertificateOperation",
options,
async (updatedOptions) => {
const response = await this.client.updateCertificateOperation(
certificateName,
{ cancellationRequested: true },
updatedOptions
);
return (0, import_transformations.getCertificateOperationFromCoreOperation)(certificateName, response);
}
);
}
/**
* 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(
"CertificateOperationPoller.getCertificate",
options,
async (updatedOptions) => {
const result = await this.client.getCertificate(certificateName, "", updatedOptions);
return (0, import_transformations.getCertificateWithPolicyFromCertificateBundle)(result);
}
);
}
/**
* Gets the certificate operation.
*/
getPlainCertificateOperation(certificateName, options = {}) {
return import_tracing.tracingClient.withSpan(
"CertificateOperationPoller.getPlainCertificateOperation",
options,
async (updatedOptions) => {
const response = await this.client.getCertificateOperation(certificateName, updatedOptions);
return (0, import_transformations.getCertificateOperationFromCoreOperation)(certificateName, response);
}
);
}
/**
* Reaches to the service and updates the poll operation.
*/
async update(options = {}) {
const state = this.state;
const certificateName = state.certificateName;
if (options.abortSignal) {
this.operationOptions.abortSignal = options.abortSignal;
}
if (!state.isStarted) {
state.isStarted = true;
state.result = await this.getCertificate(certificateName, this.operationOptions);
state.certificateOperation = await this.getPlainCertificateOperation(
certificateName,
this.operationOptions
);
} else if (!state.isCompleted) {
state.certificateOperation = await this.getPlainCertificateOperation(
certificateName,
this.operationOptions
);
}
if (state.certificateOperation && state.certificateOperation.status !== "inProgress") {
state.isCompleted = true;
state.result = await this.getCertificate(certificateName, this.operationOptions);
if (state.certificateOperation.error) {
state.error = new Error(state.certificateOperation.error.message);
}
}
return this;
}
/**
* Reaches to the service and cancels the certificate's operation, also updating the poll operation.
*/
async cancel(options = {}) {
const state = this.state;
const certificateName = state.certificateName;
if (options.abortSignal) {
this.operationOptions.abortSignal = options.abortSignal;
}
state.certificateOperation = await this.cancelCertificateOperation(
certificateName,
this.operationOptions
);
this.state.isCancelled = true;
return this;
}
/**
* Serializes the certificate's poll operation
*/
toString() {
const state = {
certificateOperation: this.state.certificateOperation,
...(0, import_keyVaultCertificatePoller.cleanState)(this.state)
};
return JSON.stringify({
state
});
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
CertificateOperationPollOperation
});
//# sourceMappingURL=operation.js.map