UNPKG

@zowe/provisioning-for-zowe-sdk

Version:

Zowe SDK to interact with the z/OS provisioning APIs

70 lines 4.11 kB
"use strict"; /* * 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.PerformAction = void 0; const core_for_zowe_sdk_1 = require("@zowe/core-for-zowe-sdk"); const imperative_1 = require("@zowe/imperative"); const ProvisioningValidator_1 = require("./ProvisioningValidator"); const ProvisioningConstants_1 = require("./ProvisioningConstants"); /** * Perform an action on published software service template. * @export * @class PerformAction */ class PerformAction { /** * Performs an action against a provisioned software service instance. * @param {AbstractSession} session - z/OSMF connection info * @param {string} zOSMFVersion - the URI path variable that identifies the version of the z/OSMF software services template service. * The following value is valid: 1.0. * @param {string} instanceId - the object-id of provisioned instance in the registry. * @param {string} actionName - name of the action to perform. * @returns {Promise<IPerformActionResponse>} z/OSMF response object, @see {IPerformActionResponse} * @memberof PerformAction */ static doProvisioningActionCommon(session, zOSMFVersion, instanceId, actionName) { 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); ProvisioningValidator_1.ProvisioningValidator.validateNotEmptyString(instanceId, ProvisioningConstants_1.noInstanceId.message); ProvisioningValidator_1.ProvisioningValidator.validateNotEmptyString(actionName, ProvisioningConstants_1.noActionName.message); const resourcesQuery = this.getResourcesQuery(zOSMFVersion, instanceId, actionName); return core_for_zowe_sdk_1.ZosmfRestClient.postExpectJSON(session, resourcesQuery, [imperative_1.Headers.APPLICATION_JSON]); }); } /** * Builds a resources query from passed parameters which is needed for z/OSMF api URI. * @param {string} zOSMFVersion - the URI path variable that identifies the version of the z/OSMF software services template service. * The following value is valid: 1.0. * @param {string} instanceId - the object-id of provisioned instance in the registry. * @param {string} actionName - name of the action to perform. * @returns {string} URI for z/OSMF REST call * @memberof PerformAction */ static getResourcesQuery(zOSMFVersion, instanceId, actionName) { let resourcesQuery = `${ProvisioningConstants_1.ProvisioningConstants.RESOURCE}/${zOSMFVersion}/`; resourcesQuery += `${ProvisioningConstants_1.ProvisioningConstants.INSTANCES_RESOURCE}/${instanceId}/`; resourcesQuery += `${ProvisioningConstants_1.ProvisioningConstants.ACTIONS_RESOURCES}/${actionName}`; return resourcesQuery; } } exports.PerformAction = PerformAction; //# sourceMappingURL=PerformAction.js.map