import { ZosmfRestClient , nozOSMFVersion } from "@zowe/core-for-zowe-sdk" ; import { AbstractSession , Headers } from "@zowe/imperative" ; import { ProvisioningValidator } from "./ProvisioningValidator" ; import { noAccountInfo , noTemplateName , ProvisioningConstants } from "./ProvisioningConstants" ; import { IProvisionTemplateResponse } from "./doc/zosmf/IProvisionTemplateResponse" ; import { IProvisionOptionals } from "./doc/input/IProvisionOptionals" ; export class export class ProvisionPublishedTemplate { param { AbstractSession } session param { string } zOSMFVersion param { string } templateName param { string } account returns { Promise < IProvisionTemplateResponse > } see { IProvisionTemplateResponse } memberof public static async provisionTemplateCommon ( session , zOSMFVersion , templateName , account ) { ProvisioningValidator . validateSession ( session ) ; ProvisioningValidator . validateNotEmptyString ( zOSMFVersion , nozOSMFVersion . message ) ; ProvisioningValidator . validateNotEmptyString ( templateName , noTemplateName . message ) ; ProvisioningValidator . validateNotEmptyString ( account , noAccountInfo . message ) ; let resourcesQuery = `${ ProvisioningConstants . RESOURCE }/${ zOSMFVersion }/` ; resourcesQuery += `${ ProvisioningConstants . TEMPLATES_RESOURCES }/${ templateName }/` ; resourcesQuery += `${ ProvisioningConstants . ACTIONS_RESOURCES }/${ ProvisioningConstants . RESOURCE_PROVISION_RUN }` ; return ZosmfRestClient . postExpectJSON < IProvisionTemplateResponse > ( session , resourcesQuery , [ Headers . APPLICATION_JSON ] , { "account-info" : account } ) ; } param { AbstractSession } session param { string } zOSMFVersion param { string } templateName param { IProvisionOptionals } optionalParms see { IProvisionOptionals } returns { Promise < IProvisionTemplateResponse > } see { IProvisionTemplateResponse } memberof public static async provisionTemplate ( session , zOSMFVersion , templateName , optionalParms ? ) { ProvisioningValidator . validateSession ( session ) ; ProvisioningValidator . validateNotEmptyString ( zOSMFVersion , nozOSMFVersion . message ) ; ProvisioningValidator . validateNotEmptyString ( templateName , noTemplateName . message ) ; let resourcesQuery = `${ ProvisioningConstants . RESOURCE }/${ zOSMFVersion }/` ; resourcesQuery += `${ ProvisioningConstants . TEMPLATES_RESOURCES }/${ templateName }/` ; resourcesQuery += `${ ProvisioningConstants . ACTIONS_RESOURCES }/${ ProvisioningConstants . RESOURCE_PROVISION_RUN }` ; if ( optionalParms ) { return ZosmfRestClient . postExpectJSON < IProvisionTemplateResponse > ( session , resourcesQuery , [ Headers . APPLICATION_JSON ] , optionalParms ) ; } else { return ZosmfRestClient . postExpectJSON < IProvisionTemplateResponse > ( session , resourcesQuery , [ Headers . APPLICATION_JSON ] ) ; } } }