UNPKG

@controlplane/cli

Version:

Control Plane Corporation CLI

53 lines 1.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.K8sCrdExporter = void 0; const auth_1 = require("../login/auth"); const api_1 = require("../rest/api"); const client_1 = require("../session/client"); class K8sCrdExporter { constructor(profile, org, request) { this.profile = profile; this.org = org; this.request = request; // 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.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.request.endpoint, 'k8s-crd-exporter'); // Refresh token (in case there is a refresh token) const token = await (0, auth_1.makeAuthorizationHeader)(this.profile); // Update request token this.request.token = token; // Create the client const client = (0, client_1.makeClient)(this.request, serviceEndpoint); // Save the created client this.client = client; // Return the client return client; } } exports.K8sCrdExporter = K8sCrdExporter; //# sourceMappingURL=index.js.map