@broadcom/endevor-bridge-for-git-for-zowe-cli
Version:
Endevor Bridge for Git plug-in for Zowe CLI
161 lines • 7.36 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.EndevorSession = 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 Endevor Session
*/
class EndevorSession extends api_1.OptionUtils {
/**
* Creates the Endevor connection session if and only if all the required options are provided
*
* @param args command arguments
* @param profile Endevor profile
* @param baseProfile Base profile
*/
createSession(args, profile, baseProfile) {
const session = {
type: imperative_1.SessConstants.AUTH_TYPE_BASIC,
protocol: this.getOption(true, EndevorSession.ENDEVOR_OPTION_PROTOCOL, args, profile, baseProfile, "http"),
hostname: this.getOption(true, EndevorSession.ENDEVOR_OPTION_HOST, args, profile, baseProfile),
port: Number(this.getOption(true, EndevorSession.ENDEVOR_OPTION_PORT, args, profile, baseProfile)),
user: this.getOption(false, EndevorSession.ENDEVOR_OPTION_USER, args, profile, baseProfile),
password: this.getOption(false, EndevorSession.ENDEVOR_OPTION_PASSWORD, args, profile, baseProfile),
rejectUnauthorized: this.getOption(true, EndevorSession.ENDEVOR_OPTION_REJECT_UNAUTHORIZED, args, profile, baseProfile, imperative_1.AbstractSession.DEFAULT_REJECT_UNAUTHORIZED_SETTING),
basePath: this.getOption(true, EndevorSession.ENDEVOR_OPTION_BASE_PATH, args, profile, baseProfile, EndevorSession.DEFAULT_BASE_PATH)
};
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(EndevorSession.ENDEVOR_OPTION_USER);
this.optionValidator.addMissingOption(EndevorSession.ENDEVOR_OPTION_PASSWORD);
}
if (!this.optionValidator.isMissingOptions(EndevorSession.ENDEVOR_SESSION_OPTION_GROUP)) {
return new imperative_1.Session(session);
}
}
getOptionPrefix() {
return EndevorSession.OPTION_PREFIX;
}
}
exports.EndevorSession = EndevorSession;
EndevorSession.PROFILE_TYPE = "endevor";
EndevorSession.OPTION_PREFIX = "endevor-";
EndevorSession.ENDEVOR_SESSION_OPTION_GROUP = "Endevor options (alternatively use an 'endevor' profile)";
EndevorSession.DEFAULT_BASE_PATH = "EndevorService/rest";
/**
* Option used in profile creation and commands for protocol for Endevor
*/
EndevorSession.ENDEVOR_OPTION_PROTOCOL = {
name: "endevor-protocol", aliases: ["endevorprot"],
description: "The Endevor SCM Rest API protocol. " +
api_1.OptionUtils.defaultValueDescription("http"),
type: "string",
required: false,
group: EndevorSession.ENDEVOR_SESSION_OPTION_GROUP,
allowableValues: { values: ["http", "https"], caseSensitive: false }
};
/**
* Option used in profile creation and commands for hostname for Endevor
*/
EndevorSession.ENDEVOR_OPTION_HOST = {
name: "endevor-host", aliases: ["endevorh"],
description: "The Endevor Rest API hostname.",
type: "string",
required: false,
group: EndevorSession.ENDEVOR_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for port for Endevor
*/
EndevorSession.ENDEVOR_OPTION_PORT = {
name: "endevor-port", aliases: ["endevorp"],
description: "The Endevor Rest API port.",
type: "number",
required: false,
group: EndevorSession.ENDEVOR_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for username / ID for Endevor
*/
EndevorSession.ENDEVOR_OPTION_USER = {
name: "endevor-user", aliases: ["endevoru"],
description: "Mainframe (Endevor) username, which can be the same as your TSO login.",
type: "string",
required: false,
group: EndevorSession.ENDEVOR_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for password/passphrase for Endevor
*/
EndevorSession.ENDEVOR_OPTION_PASSWORD = {
name: "endevor-password", aliases: ["endevorpass", "endevorpw"],
description: "Mainframe (Endevor) password, which can be the same as your TSO password.",
type: "string",
required: false,
group: EndevorSession.ENDEVOR_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for rejectUnauthorized setting for connecting to Endevor
*/
EndevorSession.ENDEVOR_OPTION_REJECT_UNAUTHORIZED = {
name: "endevor-reject-unauthorized", aliases: ["endevorru"],
description: "Reject self-signed certificates. " +
api_1.OptionUtils.defaultValueDescription(imperative_1.AbstractSession.DEFAULT_REJECT_UNAUTHORIZED_SETTING),
type: "boolean",
required: false,
group: EndevorSession.ENDEVOR_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for base path for Endevor
*/
EndevorSession.ENDEVOR_OPTION_BASE_PATH = {
name: "endevor-base-path", aliases: ["endevorbp"],
description: "The Endevor SCM Rest API base path. " +
api_1.OptionUtils.defaultValueDescription(EndevorSession.DEFAULT_BASE_PATH),
type: "string",
required: false,
group: EndevorSession.ENDEVOR_SESSION_OPTION_GROUP
};
/**
* Options related to connecting to Endevor
* These options can be filled in if the user creates a profile
*/
EndevorSession.ENDEVOR_CONNECTION_OPTIONS = [
EndevorSession.ENDEVOR_OPTION_PROTOCOL,
EndevorSession.ENDEVOR_OPTION_HOST,
EndevorSession.ENDEVOR_OPTION_PORT,
EndevorSession.ENDEVOR_OPTION_USER,
EndevorSession.ENDEVOR_OPTION_PASSWORD,
EndevorSession.ENDEVOR_OPTION_REJECT_UNAUTHORIZED,
EndevorSession.ENDEVOR_OPTION_BASE_PATH
];
//# sourceMappingURL=EndevorSession.js.map