@zowe/provisioning-for-zowe-sdk
Version:
Zowe SDK to interact with the z/OS provisioning APIs
86 lines • 4.75 kB
JavaScript
;
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ListRegistryInstances = void 0;
const core_for_zowe_sdk_1 = require("@zowe/core-for-zowe-sdk");
const ProvisioningValidator_1 = require("./ProvisioningValidator");
const ProvisioningConstants_1 = require("./ProvisioningConstants");
/**
* Get info about all provisioned instances.
* @export
* @class ListRegistryInstances
*/
class ListRegistryInstances {
/**
* This operation returns registry of provisioned instances.
* @param {AbstractSession} session - z/OSMF connection info
* @param {string} zOSMFVersion - the URI path that identifies the version of the provisioning service.
* @param {string} filteredQuery - URI path with filters for listing filtered registry instances.
* @returns {Promise<IProvisionedInstances>} z/OSMF response object, @see {IProvisionedInstances}
* @memberof ListRegistryInstances
*/
static listRegistryCommon(session, zOSMFVersion, filteredQuery) {
return __awaiter(this, void 0, void 0, function* () {
ProvisioningValidator_1.ProvisioningValidator.validateSession(session);
ProvisioningValidator_1.ProvisioningValidator.validateNotEmptyString(zOSMFVersion, core_for_zowe_sdk_1.nozOSMFVersion.message);
const query = filteredQuery ? filteredQuery : this.getResourcesQuery(zOSMFVersion);
return core_for_zowe_sdk_1.ZosmfRestClient.getExpectJSON(session, query);
});
}
/**
* This operation returns registry of provisioned instances filtered by type and external name.
* @param {AbstractSession} session - z/OSMF connection info
* @param {string} zOSMFVersion - the URI path that identifies the version of the provisioning service.
* @param {string} type - system type of the instance.
* @param {string} externalName - regular expression, specifies the external name of the instance.
* @returns {Promise<IProvisionedInstances>} z/OSMF response object, @see {IProvisionedInstances}
* @memberof ListRegistryInstances
*/
static listFilteredRegistry(session, zOSMFVersion, type, externalName) {
return __awaiter(this, void 0, void 0, function* () {
ProvisioningValidator_1.ProvisioningValidator.validateSession(session);
ProvisioningValidator_1.ProvisioningValidator.validateNotEmptyString(zOSMFVersion, core_for_zowe_sdk_1.nozOSMFVersion.message);
const query = this.getResourcesQuery(zOSMFVersion, type, externalName);
return this.listRegistryCommon(session, zOSMFVersion, query);
});
}
/**
* Builds URI path from provided parameters.
* @param {string} zOSMFVersion - the URI path that identifies the version of the provisioning service.
* @param {string} type - system type of the instance.
* @param {string} externalName - regular expression, specifies the external name of the instance.
* @returns {string} URI path for the REST call.
* @memberof ListRegistryInstances
*/
static getResourcesQuery(zOSMFVersion, type, externalName) {
let query = `${ProvisioningConstants_1.ProvisioningConstants.RESOURCE}/${zOSMFVersion}/${ProvisioningConstants_1.ProvisioningConstants.INSTANCES_RESOURCE}`;
if (!(type == null)) {
query += `?${ProvisioningConstants_1.ProvisioningConstants.RESOURCE_TYPE}=${type}`;
}
if (!(externalName == null)) {
query += type ? "&" : "?";
query += `${ProvisioningConstants_1.ProvisioningConstants.RESOURCE_EXTERNAL_NAME}=${externalName}`;
}
return query;
}
}
exports.ListRegistryInstances = ListRegistryInstances;
//# sourceMappingURL=ListRegistryInstances.js.map