@broadcom/endevor-bridge-for-git-for-zowe-cli
Version:
Endevor Bridge for Git plug-in for Zowe CLI
148 lines • 6.68 kB
JavaScript
"use strict";
/*
* Copyright (c) 2019 Broadcom. All Rights Reserved. The term
* "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This software and all information contained therein is
* confidential and proprietary and shall not be duplicated,
* used, disclosed, or disseminated in any way except as
* authorized by the applicable license agreement, without the
* express written permission of Broadcom. All authorized
* reproductions must be marked with this language.
*
* EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO
* THE EXTENT PERMITTED BY APPLICABLE LAW, BROADCOM PROVIDES THIS
* SOFTWARE WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT
* LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL BROADCOM
* BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR
* DAMAGE, DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE,
* INCLUDING WITHOUT LIMITATION, LOST PROFITS, BUSINESS
* INTERRUPTION, GOODWILL, OR LOST DATA, EVEN IF BROADCOM IS
* EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZosmfSession = void 0;
const imperative_1 = require("@zowe/imperative");
const api_1 = require("../../api");
const object_1 = require("../../utils/object");
const BaseProfileDefinitions_1 = require("./BaseProfileDefinitions");
/**
* Utility Methods for z/OSMF Session
*/
class ZosmfSession extends api_1.OptionUtils {
/**
* Creates the z/OSMF connection session if and only if all the required options are provided
*
* @param args command arguments
* @param profile z/OSMF profile
* @param baseProfile Base profile
*/
getSession(args, profile, baseProfile) {
const session = {
type: imperative_1.SessConstants.AUTH_TYPE_BASIC,
hostname: this.getOption(true, ZosmfSession.ZOSMF_OPTION_HOST, args, profile, baseProfile),
port: Number(this.getOption(true, ZosmfSession.ZOSMF_OPTION_PORT, args, profile, baseProfile, imperative_1.AbstractSession.DEFAULT_PORT)),
user: this.getOption(false, ZosmfSession.ZOSMF_OPTION_USER, args, profile),
password: this.getOption(false, ZosmfSession.ZOSMF_OPTION_PASSWORD, args, profile),
rejectUnauthorized: this.getOption(true, ZosmfSession.ZOSMF_OPTION_REJECT_UNAUTHORIZED, args, profile, baseProfile, imperative_1.AbstractSession.DEFAULT_REJECT_UNAUTHORIZED_SETTING),
basePath: this.getOption(false, ZosmfSession.ZOSMF_OPTION_BASE_PATH, args, profile)
};
if ((0, object_1.isNil)(session.user) || (0, object_1.isNil)(session.password)) {
session.type = imperative_1.SessConstants.AUTH_TYPE_TOKEN;
session.tokenType = this.getOption(false, BaseProfileDefinitions_1.BaseProfileDefinitions.BASE_OPTION_TOKEN_TYPE, args, null, baseProfile);
session.tokenValue = this.getOption(false, BaseProfileDefinitions_1.BaseProfileDefinitions.BASE_OPTION_TOKEN_VALUE, args, null, baseProfile);
}
if (this.optionValidator.isMissingCredentials(session)) {
this.optionValidator.addMissingOption(ZosmfSession.ZOSMF_OPTION_USER);
this.optionValidator.addMissingOption(ZosmfSession.ZOSMF_OPTION_PASSWORD);
}
if (!this.optionValidator.isMissingOptions(ZosmfSession.ZOSMF_SESSION_OPTION_GROUP)) {
return new imperative_1.Session(session);
}
}
getOptionPrefix() {
return ZosmfSession.OPTION_PREFIX;
}
}
exports.ZosmfSession = ZosmfSession;
ZosmfSession.PROFILE_TYPE = "zosmf";
ZosmfSession.OPTION_PREFIX = "zosmf-";
ZosmfSession.ZOSMF_SESSION_OPTION_GROUP = "z/OSMF connection options (alternatively use a 'zosmf' profile)";
/**
* Option used in profile creation and commands for hostname for z/OSMF
*/
ZosmfSession.ZOSMF_OPTION_HOST = {
name: "zosmf-host", aliases: ["zosmfh"],
description: "The z/OSMF server host name.",
type: "string",
required: false,
group: ZosmfSession.ZOSMF_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for port for z/OSMF
*/
ZosmfSession.ZOSMF_OPTION_PORT = {
name: "zosmf-port", aliases: ["zosmfp"],
description: "The z/OSMF server port." +
api_1.OptionUtils.defaultValueDescription(imperative_1.AbstractSession.DEFAULT_PORT),
type: "number",
required: false,
group: ZosmfSession.ZOSMF_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for username / ID for z/OSMF
*/
ZosmfSession.ZOSMF_OPTION_USER = {
name: "zosmf-user", aliases: ["zosmfu"],
description: "Mainframe (z/OSMF) username, which can be the same as your TSO login.",
type: "string",
required: false,
group: ZosmfSession.ZOSMF_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for password/passphrase for z/OSMF
*/
ZosmfSession.ZOSMF_OPTION_PASSWORD = {
name: "zosmf-password", aliases: ["zosmfpass", "zosmfpw"],
description: "Mainframe (z/OSMF) password, which can be the same as your TSO password.",
type: "string",
required: false,
group: ZosmfSession.ZOSMF_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for rejectUnauthorized setting for connecting to z/OSMF
*/
ZosmfSession.ZOSMF_OPTION_REJECT_UNAUTHORIZED = {
name: "zosmf-reject-unauthorized", aliases: ["zosmfru"],
description: "Reject self-signed certificates. " +
api_1.OptionUtils.defaultValueDescription(imperative_1.AbstractSession.DEFAULT_REJECT_UNAUTHORIZED_SETTING),
type: "boolean",
required: false,
group: ZosmfSession.ZOSMF_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for base path for z/OSMF
*/
ZosmfSession.ZOSMF_OPTION_BASE_PATH = {
name: "zosmf-base-path", aliases: ["zosmfbp"],
description: "The base path for your API mediation layer instance. Specify this option to" +
"prepend the base path to all z/OSMF resources when making REST requests. Do not" +
"specify this option if you are not using an API mediation layer.",
type: "string",
required: false,
group: ZosmfSession.ZOSMF_SESSION_OPTION_GROUP
};
/**
* Options related to connecting to ZOSFM
* These options can be filled in if the user creates a profile
*/
ZosmfSession.ZOSMF_CONNECTION_OPTIONS = [
ZosmfSession.ZOSMF_OPTION_HOST,
ZosmfSession.ZOSMF_OPTION_PORT,
ZosmfSession.ZOSMF_OPTION_USER,
ZosmfSession.ZOSMF_OPTION_PASSWORD,
ZosmfSession.ZOSMF_OPTION_REJECT_UNAUTHORIZED,
ZosmfSession.ZOSMF_OPTION_BASE_PATH
];
//# sourceMappingURL=ZosmfSession.js.map