UNPKG

@zowe/cli

Version:

Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.

68 lines 4.08 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 }); const imperative_1 = require("@zowe/imperative"); const rest_1 = require("../../../rest"); const WorkflowConstants_1 = require("./WorkflowConstants"); const WorkflowValidator_1 = require("./WorkflowValidator"); const util_1 = require("util"); /** * Class to handle starting of zOSMF workflow instance */ class StartWorkflow { /** * Create a zOSMF workflow instance * @param {AbstractSession} session - z/OSMF connection info * @param {string} workflowKey - Unique key that workflow instant got assigned by zOSMF * @param {string} resolveConflict - Indicates how variable conflicts are to be handled when * the Workflows task reads in the output file from a step. * Allowed values are: outputFileValue, existingValue, * leaveConflict(have to resolve conflict manually) * @param {string} step - Specifies the step name that will run. * @param {string} subsequent - If the workflow contains any subsequent automated steps, * this property indicates whether z/OSMF is to perform the steps. * @param {string} zOSMFVersion - Identifies the version of the zOSMF workflow service. * @returns {Promise} */ static startWorkflow(session, workflowKey, resolveConflict, step, subsequent, zOSMFVersion = WorkflowConstants_1.WorkflowConstants.ZOSMF_VERSION) { return __awaiter(this, void 0, void 0, function* () { WorkflowValidator_1.WorkflowValidator.validateSession(session); WorkflowValidator_1.WorkflowValidator.validateNotEmptyString(workflowKey, WorkflowConstants_1.noWorkflowKey.message); WorkflowValidator_1.WorkflowValidator.validateNotEmptyString(zOSMFVersion, WorkflowConstants_1.nozOSMFVersion.message); const data = {}; if (resolveConflict) { data.resolveConflictByUsing = resolveConflict; } if (step) { // TODO error if stepName doesn't exist + add to unit and system tests data.stepName = step; } if (!util_1.isNullOrUndefined(subsequent)) { data.performSubsequent = subsequent; } let resourcesQuery = `${WorkflowConstants_1.WorkflowConstants.RESOURCE}/${zOSMFVersion}/`; resourcesQuery += `${WorkflowConstants_1.WorkflowConstants.WORKFLOW_RESOURCE}/${workflowKey}/${WorkflowConstants_1.WorkflowConstants.START_WORKFLOW}`; return rest_1.ZosmfRestClient.putExpectString(session, resourcesQuery, [imperative_1.Headers.APPLICATION_JSON], data); }); } } exports.StartWorkflow = StartWorkflow; //# sourceMappingURL=Start.js.map