@zowe/zos-workflows-for-zowe-sdk
Version:
Zowe SDK to interact with the z/OS workflows APIs
68 lines • 4.16 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.StartWorkflow = void 0;
const imperative_1 = require("@zowe/imperative");
const core_for_zowe_sdk_1 = require("@zowe/core-for-zowe-sdk");
const WorkflowConstants_1 = require("./WorkflowConstants");
const WorkflowValidator_1 = require("./WorkflowValidator");
/**
* 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_1, workflowKey_1, resolveConflict_1, step_1, subsequent_1) {
return __awaiter(this, arguments, void 0, function* (session, workflowKey, resolveConflict, step, subsequent, zOSMFVersion = WorkflowConstants_1.WorkflowConstants.ZOSMF_VERSION) {
WorkflowValidator_1.WorkflowValidator.validateSession(session);
WorkflowValidator_1.WorkflowValidator.validateNotEmptyString(workflowKey, WorkflowConstants_1.noWorkflowKey.message);
WorkflowValidator_1.WorkflowValidator.validateNotEmptyString(zOSMFVersion, core_for_zowe_sdk_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 (!(subsequent == null)) {
data.performSubsequent = subsequent;
}
let resourcesQuery = `${WorkflowConstants_1.WorkflowConstants.RESOURCE}/${zOSMFVersion}/`;
resourcesQuery += `${WorkflowConstants_1.WorkflowConstants.WORKFLOW_RESOURCE}/${workflowKey}/${WorkflowConstants_1.WorkflowConstants.START_WORKFLOW}`;
return core_for_zowe_sdk_1.ZosmfRestClient.putExpectString(session, resourcesQuery, [imperative_1.Headers.APPLICATION_JSON], data);
});
}
}
exports.StartWorkflow = StartWorkflow;
//# sourceMappingURL=Start.js.map