import { isNullOrUndefined } from "util" ; import { ZosmfRestClient , nozOSMFVersion } from "@zowe/core-for-zowe-sdk" ; import { AbstractSession } from "@zowe/imperative" ; import { ProvisioningValidator } from "./ProvisioningValidator" ; import { ProvisioningConstants } from "./ProvisioningConstants" ; import { IProvisionedInstances } from "./doc/zosmf/IProvisionedInstances" ; export class export class ListRegistryInstances { param { AbstractSession } session param { string } zOSMFVersion param { string } filteredQuery returns { Promise < IProvisionedInstances > } see { IProvisionedInstances } memberof public static async listRegistryCommon ( session , zOSMFVersion , filteredQuery ? ) { ProvisioningValidator . validateSession ( session ) ; ProvisioningValidator . validateNotEmptyString ( zOSMFVersion , nozOSMFVersion . message ) ; const query = filteredQuery ? filteredQuery : this . getResourcesQuery ( zOSMFVersion ) ; return ZosmfRestClient . getExpectJSON < IProvisionedInstances > ( session , query ) ; } param { AbstractSession } session param { string } zOSMFVersion param { string } type param { string } externalName returns { Promise < IProvisionedInstances > } see { IProvisionedInstances } memberof public static async listFilteredRegistry ( session , zOSMFVersion , type , externalName ) { ProvisioningValidator . validateSession ( session ) ; ProvisioningValidator . validateNotEmptyString ( zOSMFVersion , nozOSMFVersion . message ) ; const query = this . getResourcesQuery ( zOSMFVersion , type , externalName ) ; return this . listRegistryCommon ( session , zOSMFVersion , query ) ; } param { string } zOSMFVersion param { string } type param { string } externalName returns { string } memberof public static getResourcesQuery ( zOSMFVersion , type ? , externalName ? ) { let query = `${ ProvisioningConstants . RESOURCE }/${ zOSMFVersion }/${ ProvisioningConstants . INSTANCES_RESOURCE }` ; if ( ! isNullOrUndefined ( type ) ) { query += `?${ ProvisioningConstants . RESOURCE_TYPE }=${ type }` ; } if ( ! isNullOrUndefined ( externalName ) ) { query += type ? "&" : "?" ; query += `${ ProvisioningConstants . RESOURCE_EXTERNAL_NAME }=${ externalName }` ; } return query ; } }