# Core package

The Zowe SDK Core package contains functionality that is shared across all other SDK packages, such as `@zowe/zos-files-for-zowe-sdk`.

Important! You must install the Core package to satisfy the peer dependency requirement for all other SDK packages.

## Core libraries

The following libraries are included in this package:

- apiml - Defines the `Services` class, which facilitates managing services hosted by the Zowe API Mediation Layer. It defines methods to load API ML config data for installed CLI plug-ins, obtain data from the API ML services endpoint, and convert this data to a config JSON file.

- auth - Contains the `Login` and `Logout` classes, which let you handle login and logout from the Zowe API Mediation Layer (or other token-based authentication services). Use the functions `Login.apimlLogin` and `Logout.apimlLogout` to store a web token in a local "base profile", which enables a secure connection to the server.

- rest - Defines the `ZosmfRestClient` class, which lets you access z/OSMF REST APIs and is an extension of the Imperative CLI Framework `RestClient` class. It provides convenience methods, such as `appendHeaders` and `processError`, that can be used for any z/OSMF request.

- utils - Contains miscellaneous utility methods, such as `ProfileUtils.loadDefaultProfile`, which automatically loads the username, host, port, etc... that is defined in your default profile configuration. To learn about all available utilities, refer to the comments in the `core/utils` source code.

## Index

### Classes

- ApimlConstants
- Login
- LoginConstants
- Logout
- LogoutConstants
- ProfileConstants
- Services
- ZosmfHeaders
- ZosmfRestClient

### Interfaces

- IAltProfile
- IApimlProfileInfo
- IApimlService
- IApimlServiceApiInfo
- IApimlServiceAuthentication
- IApimlSvcAttrsLoaded
- IAutoInitRpt
- IBaseProfileOverride
- IHeaderContent
- IProfileRpt

### Functions

- asyncPool
- getErrorContext
- padLeft
- readStdin
- sleep
- trimLineToTerminalWidth

### Object literals

- noSession
- nozOSMFVersion

## Functions

### asyncPool

- asyncPool(poolLimit: number, array: any[], iteratorFn: (item: any, array: any[]) => Promise<any>): Promise<any>

- - Defined in @zowe/core-for-zowe-sdk/src/utils/CoreUtils.ts:171

  Execute multiple promises in a pool with a maximum number of promises executing at once

  #### Parameters

  - ##### poolLimit: number

    limit of how many promises should execute at once

  - ##### array: any[]

    array of objects to convert to promises with iteratorFn

  - ##### iteratorFn: (item: any, array: any[]) => Promise<any>

    the function that turns an entry in the array into a promise

    - - (item: any, array: any[]): Promise<any>

      - #### Parameters

        - ##### item: any

        - ##### array: any[]

        #### Returns Promise<any>

### getErrorContext

- getErrorContext(content: string | string[], lineIndex: number): string

- - Defined in @zowe/core-for-zowe-sdk/src/utils/CoreUtils.ts:74

  Produces formatted context of a given error in the specified location of the contents

  NOTE: The lineIndex is zero-based indexed

  #### Parameters

  - ##### content: string | string[]

    Indicates the contents or the file path to the file containing the contents to get the error from

  - ##### lineIndex: number

    Zero-basd indexed location of the error to be printed

  #### Returns string

  Few lines (separated by \n) containing error context

### padLeft

- padLeft(str: string, len: number, padChar?: string): string

- - Defined in @zowe/core-for-zowe-sdk/src/utils/CoreUtils.ts:26

  Adds padding in case you want a longer string.

  deprecated
    - use string.padStart instead

  #### Parameters

  - ##### str: string

    string to add the padding to

  - ##### len: number

    final length of the padded string

  - ##### Default value padChar: string = " "

  #### Returns string

  Padded string

### readStdin

- readStdin(): Promise<Buffer>

- - Defined in @zowe/core-for-zowe-sdk/src/utils/CoreUtils.ts:135

  Utility function to read complete standard in contents from a handler Can be awaited from async methods

  #### Returns Promise<Buffer>

### sleep

- sleep(ms?: number): Promise<void>

- - Defined in @zowe/core-for-zowe-sdk/src/utils/CoreUtils.ts:127

  This is a simple sleep function to help when waiting for a certain period of time before continuing.

  example
    Sleeping within code

    async function doStuff() { await CoreUtils.sleep(10000); console.log("You will see this message 10 seconds after function was entered"); }

  #### Parameters

  - ##### Default value ms: number = 1000

  #### Returns Promise<void>

  Resolves after the specified time is up.

### trimLineToTerminalWidth

- trimLineToTerminalWidth(str: string): string

- - Defined in @zowe/core-for-zowe-sdk/src/utils/CoreUtils.ts:50

  Trims a given line based on the terminal's width. It also replaces tabs with spaces.

  #### Parameters

  - ##### str: string

    string to be trimmed

  #### Returns string

  Trimmed string

## Object literals

### Const noSession

noSession: object

- Defined in @zowe/core-for-zowe-sdk/src/utils/CommonConstants.ts:31

Error message that no session was supplied.

static
memberof

  CommonConstants

### message

message: string = apiErrorHeader.message + ` No session was supplied.`

- Defined in @zowe/core-for-zowe-sdk/src/utils/CommonConstants.ts:32

### Const nozOSMFVersion

nozOSMFVersion: object

- Defined in @zowe/core-for-zowe-sdk/src/utils/CommonConstants.ts:20

Error message that no z/OSMF version parameter string was supplied.

static
memberof

  CommonConstants

### message

message: string = apiErrorHeader.message + ` No z/OSMF version parameter was supplied.`

- Defined in @zowe/core-for-zowe-sdk/src/utils/CommonConstants.ts:21

Generated using TypeDoc