-
Notifications
You must be signed in to change notification settings - Fork 85
/
ArchiveWorkflow.ts
47 lines (43 loc) · 1.89 KB
/
ArchiveWorkflow.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* 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.
*
*/
import { ZosmfRestClient, nozOSMFVersion } from "@zowe/core-for-zowe-sdk";
import { AbstractSession, Headers } from "@zowe/imperative";
import { WorkflowConstants, noWorkflowKey } from "./WorkflowConstants";
import { WorkflowValidator } from "./WorkflowValidator";
import { IArchivedWorkflow } from "./doc/IArchivedWorkflow";
/**
* Class to handle archiving the workflow instance in z/OSMF
*
* @export
* @class ArchiveWorkflow
*/
export class ArchiveWorkflow {
/**
* Archives the workflow based on the workflow key
*
* @static
* @param {AbstractSession} session z/OSMF session
* @param {string} workflowKey Workflow key of the workflow to be archived
* @param {string} [zOSMFVersion=WorkflowConstants.ZOSMF_VERSION] z/OSMF REST API version
* @returns {Promise<IArchivedWorkflow>} Promise of the output of the workflow archiving
* @memberof ArchiveWorkflow
*/
public static archiveWorkflowByKey(session: AbstractSession,
workflowKey: string,
zOSMFVersion: string=WorkflowConstants.ZOSMF_VERSION): Promise<IArchivedWorkflow> {
WorkflowValidator.validateSession(session);
WorkflowValidator.validateNotEmptyString(workflowKey, noWorkflowKey.message);
WorkflowValidator.validateNotEmptyString(zOSMFVersion, nozOSMFVersion.message);
let query: string = `${WorkflowConstants.RESOURCE}/${zOSMFVersion}/${WorkflowConstants.WORKFLOW_RESOURCE}`;
query+=`/${workflowKey}/${WorkflowConstants.ARCHIVE_WORKFLOW}`;
return ZosmfRestClient.postExpectJSON(session, query, [Headers.APPLICATION_JSON], null);
}
}