Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ZosmfRestClient

Wrapper for invoke z/OSMF API through the RestClient to perform common error handling and checking and resolve promises according to generic types

export

Hierarchy

  • RestClient
    • ZosmfRestClient

Index

Constructors

constructor

  • Creates an instance of AbstractRestClient.

    memberof

    AbstractRestClient

    Parameters

    • mSession: AbstractSession

      representing connection to this api

    Returns ZosmfRestClient

Properties

Private mBytesReceived

mBytesReceived: number

Bytes received from the server response so far

memberof

AbstractRestClient

Private mContentLength

mContentLength: number

If we get a response containing a Content-Length header, it is saved here

memberof

AbstractRestClient

Private mData

mData: Buffer

Contains buffered data from REST chucks

memberof

AbstractRestClient

Private mIsJson

mIsJson: boolean

Indicates if payload data is JSON to be stringified before writing

memberof

AbstractRestClient

Private mLogger

mLogger: Logger

Instance of logger

memberof

AbstractRestClient

Private mNormalizeRequestNewlines

mNormalizeRequestNewlines: boolean

Indicates if request data should have its newlines normalized to /n before sending each chunk to the server

memberof

AbstractRestClient

Private mNormalizeResponseNewlines

mNormalizeResponseNewlines: boolean

Indicates if response data should have its newlines normalized for the current platform (\r\n for windows, otherwise \n)

memberof

AbstractRestClient

Private mReject

mReject: ImperativeReject

Reject for errors when obtaining data

memberof

AbstractRestClient

Private mReqHeaders

mReqHeaders: any[]

Save req headers

memberof

AbstractRestClient

Private mRequest

mRequest: HTTP_VERB

Save request

memberof

AbstractRestClient

Private mRequestStream

mRequestStream: Readable

stream for outgoing request data to the server

memberof

AbstractRestClient

Private mResolve

mResolve: RestClientResolve

Resolved when all data has been obtained

memberof

AbstractRestClient

Private mResource

mResource: string

Save resource

memberof

AbstractRestClient

Private mResponse

mResponse: any

Contain response from http(s) request

memberof

AbstractRestClient

Private mResponseStream

mResponseStream: Writable

Stream for incoming response data from the server. If specified, response data will not be buffered

memberof

AbstractRestClient

Private mTask

mTask: ITaskWithStatus

Task used to display progress bars or other user feedback mechanisms Automatically updated if task is specified and streams are provided for upload/download

memberof

AbstractRestClient

Private mWriteData

mWriteData: any

Save write data

memberof

AbstractRestClient

Accessors

data

  • get data(): Buffer
  • Return http(s) response body as a buffer

    readonly
    memberof

    AbstractRestClient

    Returns Buffer

dataString

  • get dataString(): string
  • Return http(s) response body as a string

    readonly
    memberof

    AbstractRestClient

    Returns string

log

  • get log(): Logger

requestFailure

  • get requestFailure(): boolean
  • Return whether or not a REST request was successful by HTTP status code

    readonly
    memberof

    AbstractRestClient

    Returns boolean

requestSuccess

  • get requestSuccess(): boolean
  • Return whether or not a REST request was successful by HTTP status code

    readonly
    memberof

    AbstractRestClient

    Returns boolean

response

  • get response(): any
  • Return http(s) response object

    readonly
    memberof

    AbstractRestClient

    Returns any

session

  • get session(): Session
  • Return this session object

    readonly
    memberof

    AbstractRestClient

    Returns Session

Methods

Protected appendHeaders

  • appendHeaders(headers: any[] | undefined): any[]
  • Append z/OSMF specific headers to the callers headers for cases where a header is common to every request.

    memberof

    ZosmfRestClient

    Parameters

    • headers: any[] | undefined

      current header array

    Returns any[]

performRest

  • performRest(resource: string, request: HTTP_VERB, reqHeaders?: any[], writeData?: any, responseStream?: Writable, requestStream?: Readable, normalizeResponseNewLines?: boolean, normalizeRequestNewLines?: boolean, task?: ITaskWithStatus): Promise<string>
  • Perform the actual http REST call with appropriate user input

    deprecated
    • since version 4.4.9. Changed to wrapper for request(). Please use request() directly.
              It will be removed in version 5.0.0
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    Parameters

    • resource: string

      URI for this request

    • request: HTTP_VERB

      REST request type GET|PUT|POST|DELETE

    • Optional reqHeaders: any[]

      option headers to include with request

    • Optional writeData: any

      data to write on this REST request

    • Optional responseStream: Writable

      stream for incoming response data from the server. If specified, response data will not be buffered

    • Optional requestStream: Readable

      stream for outgoing request data to the server

    • Optional normalizeResponseNewLines: boolean

      streaming only - true if you want newlines to be \r\n on windows when receiving data from the server to responseStream. Don't set this for binary responses

    • Optional normalizeRequestNewLines: boolean

      streaming only - true if you want \r\n to be replaced with \n when sending data to the server from requestStream. Don't set this for binary requests

    • Optional task: ITaskWithStatus

      task that will automatically be updated to report progress of upload or download to user

    Returns Promise<string>

Protected processError

  • processError(original: IImperativeError): IImperativeError
  • Process an error encountered in the rest client

    memberof

    ZosmfRestClient

    Parameters

    • original: IImperativeError

      the original error automatically built by the abstract rest client

    Returns IImperativeError

    • the processed error with details added

request

  • request(options: IRestOptions): Promise<string>
  • Perform the actual http REST call with appropriate user input

    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    AbstractRestClient

    Parameters

    • options: IRestOptions

    Returns Promise<string>

Static deleteExpectBuffer

  • deleteExpectBuffer(session: AbstractSession, resource: string, reqHeaders?: any[]): Promise<Buffer>
  • REST HTTP DELETE operation

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • Optional reqHeaders: any[]

      headers to include in the REST request

    Returns Promise<Buffer>

    • response body content from http(s) call

Static deleteExpectFullResponse

  • deleteExpectFullResponse(session: AbstractSession, options: IOptionsFullResponse): Promise<IRestClientResponse>
  • REST HTTP delete operation returning full HTTP(S) Response

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • options: IOptionsFullResponse

      list of parameters

    Returns Promise<IRestClientResponse>

    • response content from http(s) call

Static deleteExpectJSON

  • deleteExpectJSON<T>(session: AbstractSession, resource: string, reqHeaders?: any[]): Promise<T>
  • Wrap post for common error handling and supporting generic JSON types

    static
    template

    T - object type to return

    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Type parameters

    • T: object

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      the API URI that we are targeting

    • Optional reqHeaders: any[]

      headers for the http(s) request

    Returns Promise<T>

    • object on promise

Static deleteExpectString

  • deleteExpectString(session: AbstractSession, resource: string, reqHeaders?: any[]): Promise<string>
  • REST HTTP DELETE operation

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • Optional reqHeaders: any[]

      headers to include in the REST request

    Returns Promise<string>

    • response body content from http(s) call

Static deleteStreamed

  • deleteStreamed(session: AbstractSession, resource: string, reqHeaders: any[], responseStream: Writable, normalizeResponseNewLines?: boolean, task?: ITaskWithStatus): Promise<string>
  • REST HTTP DELETE operation

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • reqHeaders: any[]

      headers to include in the REST request

    • responseStream: Writable

      stream to which the response data will be written

    • Optional normalizeResponseNewLines: boolean

      streaming only - true if you want newlines to be \r\n on windows when receiving data from the server to responseStream. Don't set this for binary responses

    • Optional task: ITaskWithStatus

      task used to update the user on the progress of their request

    Returns Promise<string>

    • empty string - data is not buffered for streamed requests

Static getExpectBuffer

  • getExpectBuffer(session: AbstractSession, resource: string, reqHeaders?: any[]): Promise<Buffer>
  • REST HTTP GET operation

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • Optional reqHeaders: any[]

      headers to include in the REST request

    Returns Promise<Buffer>

    • response body content from http(s) call

Static getExpectFullResponse

  • getExpectFullResponse(session: AbstractSession, options: IOptionsFullResponse): Promise<IRestClientResponse>
  • REST HTTP GET operation returning full HTTP(S) Response

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • options: IOptionsFullResponse

      URI for which this request should go against

    Returns Promise<IRestClientResponse>

    • full response or filtered based on provided params

Static getExpectJSON

  • getExpectJSON<T>(session: AbstractSession, resource: string, reqHeaders?: any[]): Promise<T>
  • Wrap get for common error handling and supporting generic JSON types

    static
    template

    T - object type to return

    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Type parameters

    • T: object

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      the API URI that we are targeting

    • Optional reqHeaders: any[]

      headers for the http(s) request

    Returns Promise<T>

    • object on promise

Static getExpectString

  • getExpectString(session: AbstractSession, resource: string, reqHeaders?: any[]): Promise<string>
  • REST HTTP GET operation

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • Optional reqHeaders: any[]

      headers to include in the REST request

    Returns Promise<string>

    • response body content from http(s) call

Static getStreamed

  • getStreamed(session: AbstractSession, resource: string, reqHeaders: any[], responseStream: Writable, normalizeResponseNewLines?: boolean, task?: ITaskWithStatus): Promise<string>
  • REST HTTP GET operation - streaming the response to a writable stream

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • reqHeaders: any[]

      headers to include in the REST request

    • responseStream: Writable

      the stream to which the response data will be written

    • Optional normalizeResponseNewLines: boolean

      streaming only - true if you want newlines to be \r\n on windows when receiving data from the server to responseStream. Don't set this for binary responses

    • Optional task: ITaskWithStatus

      task used to update the user on the progress of their request

    Returns Promise<string>

    • empty string - data is not buffered for this request

Static hasQueryString

  • hasQueryString(query: string): boolean
  • Helper method to return an indicator for whether or not a URI contains a query string.

    static
    memberof

    RestClient

    Parameters

    • query: string

      URI

    Returns boolean

    • true if query is contained within URI

Static postExpectBuffer

  • postExpectBuffer(session: AbstractSession, resource: string, reqHeaders?: any[], data?: any): Promise<Buffer>
  • REST HTTP POST operation

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • Optional reqHeaders: any[]

      headers to include in the REST request

    • Optional data: any

      payload data

    Returns Promise<Buffer>

    • response body content from http(s) call

Static postExpectFullResponse

  • postExpectFullResponse(session: AbstractSession, options: IOptionsFullResponse): Promise<IRestClientResponse>
  • REST HTTP post operation returning full HTTP(S) Response

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • options: IOptionsFullResponse

      list of parameters

    Returns Promise<IRestClientResponse>

    • response content from http(s) call

Static postExpectJSON

  • postExpectJSON<T>(session: AbstractSession, resource: string, reqHeaders?: any[], payload?: any): Promise<T>
  • Wrap post for common error handling and supporting generic JSON types

    static
    template

    T - object type to return

    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Type parameters

    • T: object

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      the API URI that we are targeting

    • Optional reqHeaders: any[]

      headers for the http(s) request

    • Optional payload: any

      data to write on the http(s) request

    Returns Promise<T>

    • object on promise

Static postExpectString

  • postExpectString(session: AbstractSession, resource: string, reqHeaders?: any[], data?: any): Promise<string>
  • REST HTTP POST operation

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • Optional reqHeaders: any[]

      headers to include in the REST request

    • Optional data: any

      payload data

    Returns Promise<string>

    • response body content from http(s) call

Static postStreamed

  • postStreamed(session: AbstractSession, resource: string, reqHeaders: any[], responseStream: Writable, requestStream: Readable, normalizeResponseNewLines?: boolean, normalizeRequestNewLines?: boolean, task?: ITaskWithStatus): Promise<string>
  • REST HTTP POST operation streaming both the request and the response

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • reqHeaders: any[]

      headers to include in the REST request

    • responseStream: Writable

      stream to which the response data will be written

    • requestStream: Readable

      stream from which payload data will be read

    • Optional normalizeResponseNewLines: boolean

      streaming only - true if you want newlines to be \r\n on windows when receiving data from the server to responseStream. Don't set this for binary responses

    • Optional normalizeRequestNewLines: boolean

      streaming only - true if you want \r\n to be replaced with \n when sending data to the server from requestStream. Don't set this for binary requests

    • Optional task: ITaskWithStatus

      task used to update the user on the progress of their request

    Returns Promise<string>

    • empty string - data is not buffered for this request

Static postStreamedRequestOnly

  • postStreamedRequestOnly(session: AbstractSession, resource: string, reqHeaders: any[], requestStream: Readable, normalizeRequestNewLines?: boolean, task?: ITaskWithStatus): Promise<string>
  • REST HTTP POST operation, streaming only the request and not the response

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • reqHeaders: any[]

      headers to include in the REST request

    • requestStream: Readable

      stream from which payload data will be read

    • Optional normalizeRequestNewLines: boolean

      streaming only - true if you want \r\n to be replaced with \n when sending data to the server from requestStream. Don't set this for binary requests

    • Optional task: ITaskWithStatus

      task used to update the user on the progress of their request

    Returns Promise<string>

    • string of the response

Static putExpectBuffer

  • putExpectBuffer(session: AbstractSession, resource: string, reqHeaders: any[], data: any): Promise<Buffer>
  • REST HTTP PUT operation

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • reqHeaders: any[]

      headers to include in the REST request

    • data: any

      payload data

    Returns Promise<Buffer>

    • response body content from http(s) call

Static putExpectFullResponse

  • putExpectFullResponse(session: AbstractSession, options: IOptionsFullResponse): Promise<IRestClientResponse>
  • REST HTTP PUT operation returning full HTTP(S) Response

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • options: IOptionsFullResponse

      list of parameters

    Returns Promise<IRestClientResponse>

    • response content from http(s) call

Static putExpectJSON

  • putExpectJSON<T>(session: AbstractSession, resource: string, reqHeaders: any[], payload: any): Promise<T>
  • Wrap put for common error handling and supporting generic JSON types

    static
    template

    T - object type to return

    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Type parameters

    • T: object

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      the API URI that we are targeting

    • reqHeaders: any[]

      headers for the http(s) request

    • payload: any

      data to write on the http(s) request

    Returns Promise<T>

    • object on promise

Static putExpectString

  • putExpectString(session: AbstractSession, resource: string, reqHeaders: any[], data: any): Promise<string>
  • REST HTTP PUT operation

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • reqHeaders: any[]

      headers to include in the REST request

    • data: any

      payload data

    Returns Promise<string>

    • response body content from http(s) call

Static putStreamed

  • putStreamed(session: AbstractSession, resource: string, reqHeaders: any[], responseStream: Writable, requestStream: Readable, normalizeResponseNewLines?: boolean, normalizeRequestNewLines?: boolean, task?: ITaskWithStatus): Promise<string>
  • REST HTTP PUT operation with streamed response and request

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • reqHeaders: any[]

      headers to include in the REST request

    • responseStream: Writable

      stream to which the response data will be written

    • requestStream: Readable

      stream from which payload data will be read

    • Optional normalizeResponseNewLines: boolean

      streaming only - true if you want newlines to be \r\n on windows when receiving data from the server to responseStream. Don't set this for binary responses

    • Optional normalizeRequestNewLines: boolean

      streaming only - true if you want \r\n to be replaced with \n when sending data to the server from requestStream. Don't set this for binary requests

    • Optional task: ITaskWithStatus

      task used to update the user on the progress of their request

    Returns Promise<string>

    • empty string - data is not buffered for streamed requests

Static putStreamedRequestOnly

  • putStreamedRequestOnly(session: AbstractSession, resource: string, reqHeaders: any[], requestStream: Readable, normalizeRequestNewLines?: boolean, task?: ITaskWithStatus): Promise<string>
  • REST HTTP PUT operation with only streamed request, buffers response data and returns it

    static
    throws

    if the request gets a status code outside of the 200 range or other connection problems occur (e.g. connection refused)

    memberof

    RestClient

    Parameters

    • session: AbstractSession

      representing connection to this api

    • resource: string

      URI for which this request should go against

    • reqHeaders: any[]

      headers to include in the REST request

    • requestStream: Readable

      stream from which payload data will be read

    • Optional normalizeRequestNewLines: boolean

      streaming only - true if you want \r\n to be replaced with \n when sending data to the server from requestStream. Don't set this for binary requests

    • Optional task: ITaskWithStatus

      task used to update the user on the progress of their request

    Returns Promise<string>

    • string of the response

Generated using TypeDoc