@ui5/task-adaptation
Version:
Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment
79 lines (78 loc) • 3.57 kB
TypeScript
import { ICreateServiceInstanceParams, IGetServiceInstanceParams, IResource, IServiceKeys } from "../model/types.js";
export default class CFUtil {
/**
* Get or create service keys for service instance found by query
* @static
* @param {IGetServiceInstanceParams} getServiceInstanceParams query parameters to find a service instance by
* @param {ICreateServiceInstanceParams} [createServiceInstanceParams] parameters to create a service instance
* @return {Promise<IServiceKeys>} promise with service keys
* @memberof CFUtil
*/
static getServiceInstanceKeys(getServiceInstanceParams: IGetServiceInstanceParams, createServiceInstanceParams?: ICreateServiceInstanceParams): Promise<IServiceKeys>;
static createService(params: ICreateServiceInstanceParams): Promise<void>;
private static getOrCreateServiceKeys;
private static getServiceKeys;
private static createServiceKey;
private static deleteServiceKeyUnsafe;
private static getServiceInstance;
static processErrors(json: any): void;
static requestCfApi(url: string): Promise<IResource[]>;
static getOAuthToken(): Promise<string>;
private static cfExecute;
private static errorsToString;
private static parseJson;
/**
* Get service keys and return the first one with valid endpoints
* @private
* @static
* @param {string} serviceInstanceGuid the service instance guid
* @return {Promise<any>} the first service key with valid endpoints, or null if none found
* @memberof CFUtil
*/
private static getServiceKeyWithValidEndpoints;
/**
* Get service keys for a service instance by name. If the existing service key
* has endpoints as strings instead of objects, a new service key will be created.
* @static
* @param {string} serviceInstanceName name of the service instance
* @param {string} [spaceGuid] optional space guid, will use current space if not provided
* @return {Promise<any>} promise with service key credentials
* @memberof CFUtil
*/
static getOrCreateServiceKeyWithEndpoints(serviceInstanceName: string, spaceGuid?: string): Promise<any>;
/**
* Check if endpoints object has at least one property that is an object
* @private
* @static
* @param {any} endpoints the endpoints object to validate
* @return {boolean} true if at least one property of endpoints is an object
* @memberof CFUtil
*/
private static hasValidEndpoints;
/**
* Get all service key names for a service instance
* @private
* @static
* @param {string} serviceInstanceGuid the service instance guid
* @return {Promise<string[]>} promise with array of service key names
* @memberof CFUtil
*/
private static getAllServiceKeyNames;
/**
* Generate a unique service key name in format serviceInstanceName-key-N
* @static
* @param {string} serviceInstanceName the service instance name
* @param {string} serviceInstanceGuid the service instance guid
* @return {Promise<string>} promise with unique service key name
* @memberof CFUtil
*/
static generateUniqueServiceKeyName(serviceInstanceName: string, serviceInstanceGuid: string): Promise<string>;
/**
* Get space guid from configuration or local CF fodler
* @static
* @param {string} spaceGuid ui5.yaml options
* @return {Promise<string>} promise with space guid
* @memberof CFUtil
*/
static getSpaceGuid(spaceGuid?: string): Promise<string>;
}