@controlplane/cli
Version:
Control Plane Corporation CLI
55 lines • 1.67 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isKindValid = exports.getDiscoveryEndpoint = exports.Kinds = exports.DATA_SERVICE_BASE_URL = void 0;
const axios_1 = require("axios");
exports.DATA_SERVICE_BASE_URL = 'https://api.cpln.io';
exports.Kinds = [
'account',
'agent',
'auditctx',
'cloudaccount',
'deployment',
'domain',
'dbcluster',
'event',
'group',
'gvc',
'identity',
'image',
'location',
'memcachecluster',
'org',
'permissions',
'policy',
'quota',
'secret',
'serviceaccount',
'spicedbcluster',
'task',
'user',
'volumeset',
'workload',
];
/**
* Get the endpoint URL based on the desired service name
* @param baseURL The base URL to get the endpoints from.
* @param serviceName The exact name of the server that appears in the /discovery endpoints.
* @returns the endpoint URL or undefiend in case the baseURL does not have /discovery or the service name is not found.
*/
async function getDiscoveryEndpoint(baseURL, serviceName) {
const response = await axios_1.default.get(`${baseURL}/discovery`);
let discovery = response.data;
return discovery.endpoints[serviceName];
}
exports.getDiscoveryEndpoint = getDiscoveryEndpoint;
/**
* Determines whether a given kind string is one of the valid kinds defined in the Kind type.
*
* @param kind - The kind name as a string.
* @returns A boolean indicating if the provided kind is a valid kind in the Kind type.
*/
function isKindValid(kind) {
return exports.Kinds.includes(kind);
}
exports.isKindValid = isKindValid;
//# sourceMappingURL=api.js.map
;