liveperson-functions-cli
Version:
LivePerson Functions CLI
130 lines (129 loc) • 6.3 kB
TypeScript
import { Namespace, NamespaceOptions } from '../types/namespace';
import { Entity } from '../types/entity';
export interface IRestClient {
/**
* Creates a new namespace with the specified name under the provided account.
* Given the namespace exists it will not recreate it or throw an error.
* @param accountId
* @param namespace
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
createNamespace(accountId: string, namespace: string, options: NamespaceOptions): Promise<Namespace>;
/**
* Delete the specified namespace including all of the entities included in it.
* Given the namespace did not exist it will throw no error.
* @param accountId
* @param namespace
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
deleteNamespace(accountId: string, namespace: string): Promise<void>;
/**
* Returns a list of all custom namespaces created for the specified account.
* Please be aware built in namespaces are not included e.g. `faas`
* @param accountId
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
getListOfNamespaces(accountId: string): Promise<Namespace[]>;
/**
* Will create or update properties in specified session. If a key is omitted
* it will not cause the deletion of a property, for this leverage the delete
* method directly.
* @param accountId
* @param namespace
* @param properties
* @param [sessionId] Optional if not provided will use default session
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
setOrUpdatePropertiesInNamespace(accountId: string, namespace: string, properties: Entity, sessionId?: string): Promise<Entity>;
/**
* Returns the specified session with all of its properties. If session
* does not exist it will return an empty object
* @param accountId
* @param namespace
* @param [sessionId] Optional if not provided will use default session
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
getAllPropertiesInSession(accountId: string, namespace: string, sessionId?: string): Promise<Entity>;
/**
* Returns only the specified properties from the specified session.
* @param accountId
* @param namespace
* @param propertyNames that should be looked up
* @param [sessionId] Optional if not provided will use default session
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
getSelectedPropertiesInSession(accountId: string, namespace: string, propertyNames: string[], sessionId?: string): Promise<Entity>;
/**
* Gets the value of the specified propertyName.
* @param accountId
* @param namespace
* @param propertyName
* @param [sessionId] Optional if not provided will use default session
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
getPropertyInSession(accountId: string, namespace: string, propertyName: string, sessionId?: string): Promise<unknown>;
/**
* Deletes the specified property from the specified session.
* Will not throw an error if deleting an non existing property.
* @param accountId
* @param namespace
* @param propertyName
* @param [sessionId] Optional if not provided will use default session
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
deletePropertyInSession(accountId: string, namespace: string, propertyName: string, sessionId?: string): Promise<void>;
/**
* Deletes the specified session along with all it properties.
* Will not throw an error if deleting an non existing session.
* @param accountId
* @param namespace
* @param sessionId
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
deleteSession(accountId: string, namespace: string, sessionId: string): Promise<void>;
/**
* Returns a list of all entities within the specified namespace. Please be aware this includes
* also the default session __default__
* @param accountId
* @param namespace
*
* @throws RestError when returned status code is not successfull or unexpected issue occured
*/
getListOfSessions(accountId: string, namespace: string): Promise<string[]>;
}
export declare class RestClient implements IRestClient {
private readonly baseUrl;
private readonly apiKey;
private readonly protocol;
constructor(baseUrl: string, apiKey: string);
createNamespace(accountId: string, namespace: string, options: NamespaceOptions): Promise<Namespace>;
deleteNamespace(accountId: string, namespace: string): Promise<void>;
getListOfNamespaces(accountId: string): Promise<Namespace[]>;
setOrUpdatePropertiesInNamespace(accountId: string, namespace: string, properties: Entity, sessionId?: string): Promise<Entity>;
getAllPropertiesInSession(accountId: string, namespace: string, sessionId?: string): Promise<Entity>;
getSelectedPropertiesInSession(accountId: string, namespace: string, propertyNames: string[], sessionId?: string): Promise<Entity>;
getPropertyInSession(accountId: string, namespace: string, propertyName: string, sessionId?: string): Promise<unknown>;
deletePropertyInSession(accountId: string, namespace: string, propertyName: string, sessionId?: string): Promise<void>;
deleteSession(accountId: string, namespace: string, sessionId: string): Promise<void>;
getListOfSessions(accountId: string, namespace: string): Promise<string[]>;
private performRequestWithDeadline;
/**
* Helper Method returning an object containing all relevant headers.
*/
private generateHeaders;
/**
* This method takes an error returned by the bent library and turn it into
* either an RestError or a NetworkError
* @param error object from bent
*/
private transform;
}