@controlplane/cli
Version:
Control Plane Corporation CLI
46 lines • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.K8sCrdExporter = void 0;
const api_1 = require("../rest/api");
const client_1 = require("../session/client");
class K8sCrdExporter {
constructor(session) {
this.session = session;
// Initialize
this.client = null;
}
// Public Methods //
async batch(request, namespace, keep) {
// Get the client
const client = await this.getClient();
// Construct the request path
let path = `/batch?org=${this.session.context.org}`;
// Add the namespace if provided
if (namespace) {
path += `&namespace=${namespace}`;
}
// Add the keep parameter if provided
if (keep !== undefined) {
path += `&keep=${String(keep)}`;
}
// Submit the batch request and return the response
return await client.post(path, request);
}
// Private Methods //
async getClient() {
// If the client is already created, return it
if (this.client) {
return this.client;
}
// Get the service endpoint
const serviceEndpoint = await (0, api_1.getDiscoveryEndpoint)(this.session.request.endpoint, 'k8s-crd-exporter');
// Create the client
const client = (0, client_1.makeSessionClient)(this.session, serviceEndpoint);
// Save the created client
this.client = client;
// Return the client
return client;
}
}
exports.K8sCrdExporter = K8sCrdExporter;
//# sourceMappingURL=index.js.map