src/api/api.service.ts
Properties |
|
Methods |
|
Private
constructor(apiMap: Map<string | Api>, selectionEnabled: boolean, selectionVisible: boolean)
|
||||||||||||
Defined in src/api/api.service.ts:35
|
||||||||||||
Parameters :
|
Private delegate |
Type : null | Api
|
Default value : null
|
Defined in src/api/api.service.ts:34
|
Private delegateName |
Type : null | string
|
Default value : null
|
Defined in src/api/api.service.ts:35
|
Private checkApiBeforeCall |
checkApiBeforeCall()
|
Defined in src/api/api.service.ts:276
|
Returns :
void
|
Public createEnvironment |
createEnvironment(name: string, description: string, serviceid: string)
|
Defined in src/api/api.service.ts:254
|
Returns :
Promise<null | Environment>
|
Public discover | ||||||
discover(request: DiscoverRequest)
|
||||||
Defined in src/api/api.service.ts:114
|
||||||
Parameters :
Returns :
Promise<null | DiscoverResponse>
|
Public doSearch | ||||||
doSearch(searchCriteriaMap: Map<SearchCriteria | >)
|
||||||
Defined in src/api/api.service.ts:136
|
||||||
Parameters :
Returns :
Promise<Array<ItemSummary>>
|
Public executeAuthenticatedUrl | ||||||
executeAuthenticatedUrl(url: string)
|
||||||
Defined in src/api/api.service.ts:166
|
||||||
Parameters :
Returns :
Promise<Blob>
|
Public executeDistributionFormat | ||||||||||||
executeDistributionFormat(format: DistributionFormat, params: null | Array
|
||||||||||||
Defined in src/api/api.service.ts:180
|
||||||||||||
Parameters :
Returns :
Promise<Record | Blob>
|
Public executeUrl | ||||||
executeUrl(url: string)
|
||||||
Defined in src/api/api.service.ts:173
|
||||||
Parameters :
Returns :
Promise<Blob>
|
Public getApiNames |
getApiNames()
|
Defined in src/api/api.service.ts:108
|
Returns :
Array<string>
|
Public getDetails | |||||||||
getDetails(summary: DistributionSummary, context: string)
|
|||||||||
Defined in src/api/api.service.ts:156
|
|||||||||
Parameters :
Returns :
Promise<null | DistributionDetails>
|
Public getDetailsById |
getDetailsById(id: string, context: string)
|
Defined in src/api/api.service.ts:160
|
Returns :
Promise<null | DistributionDetails>
|
Public getDictionary | ||||||
getDictionary(type: DictionaryType)
|
||||||
Defined in src/api/api.service.ts:131
|
||||||
Parameters :
Returns :
Promise<Dictionary>
|
Public getDomains | ||||||
getDomains(context: string)
|
||||||
Defined in src/api/api.service.ts:126
|
||||||
Parameters :
Returns :
Promise<null | Array>
|
Public getEnvironment | ||||||||
getEnvironment(environment: Environment)
|
||||||||
Defined in src/api/api.service.ts:246
|
||||||||
The function
Parameters :
Returns :
Promise<Environment | null>
The method is returning a Promise that resolves to either an instance of the Environment class or null. |
Public getEnvironments |
getEnvironments()
|
Defined in src/api/api.service.ts:233
|
The function
Returns :
Promise<Array<Environment>>
The method |
Public getEnvironmentTypes |
getEnvironmentTypes()
|
Defined in src/api/api.service.ts:271
|
Returns :
Promise<Array<EnvironmentType>>
|
Public getExecuteUrl | |||||||||
getExecuteUrl(format: DistributionFormat, params: null | Array
|
|||||||||
Defined in src/api/api.service.ts:189
|
|||||||||
Parameters :
Returns :
string
|
Public getFilters | ||||||
getFilters(context: string)
|
||||||
Defined in src/api/api.service.ts:121
|
||||||
Parameters :
Returns :
Promise<null | DiscoverResponse>
|
Public getOrganizationById | ||||||
getOrganizationById(id: string)
|
||||||
Defined in src/api/api.service.ts:151
|
||||||
Parameters :
Returns :
Promise<Organization | null>
|
Public getOrganizations | ||||||
getOrganizations(type: string)
|
||||||
Defined in src/api/api.service.ts:146
|
||||||
The function
Parameters :
Returns :
Promise<[] | null>
a Promise that resolves to either an array of Organization objects or null. |
Public getOriginatorUrl | |||||||||
getOriginatorUrl(distribution: DistributionSummary, params: null | Array
|
|||||||||
Defined in src/api/api.service.ts:197
|
|||||||||
Parameters :
Returns :
Promise<string>
|
Public getSelectedApiName |
getSelectedApiName()
|
Defined in src/api/api.service.ts:104
|
Returns :
string
|
Public isSelectionEnabled |
isSelectionEnabled()
|
Defined in src/api/api.service.ts:86
|
Returns :
boolean
|
Public isSelectionVisible |
isSelectionVisible()
|
Defined in src/api/api.service.ts:90
|
Returns :
boolean
|
Static make | ||||||||||||||||||||
make(api: Api, apiName: string, selectionEnabled, selectionVisible)
|
||||||||||||||||||||
Defined in src/api/api.service.ts:44
|
||||||||||||||||||||
Parameters :
Returns :
ApiService
|
Static makeSelectable | ||||||||||||||||||||
makeSelectable(apis: Map<string | Api>, nameOfDefaultApi: string, selectionEnabled, selectionVisible)
|
||||||||||||||||||||
Defined in src/api/api.service.ts:52
|
||||||||||||||||||||
Parameters :
Returns :
ApiService
|
Public removeEnvironment | ||||||
removeEnvironment(environment: Environment)
|
||||||
Defined in src/api/api.service.ts:258
|
||||||
Parameters :
Returns :
Promise<boolean>
|
Public retrieveConfigurables | ||||||||
retrieveConfigurables(key: string)
|
||||||||
Defined in src/api/api.service.ts:221
|
||||||||
The function retrieveConfigurables retrieves configurable settings based on a given key.
represents the configuration key used to retrieve configurable settings or values.
Parameters :
Returns :
Promise<string | null>
The |
Public runJobEnvironment | ||||||
runJobEnvironment(environment: Environment)
|
||||||
Defined in src/api/api.service.ts:262
|
||||||
Parameters :
Returns :
Promise<boolean>
|
Public saveConfigurables | ||||||||
saveConfigurables(value: string)
|
||||||||
Defined in src/api/api.service.ts:209
|
||||||||
The function
Parameters :
Returns :
Promise<string>
The |
Public selectApi | ||||||
selectApi(apiName: string)
|
||||||
Defined in src/api/api.service.ts:94
|
||||||
Parameters :
Returns :
void
|
Public updateEnvironment | ||||||||||||
updateEnvironment(environment: Environment, newName: string, newDescription: string)
|
||||||||||||
Defined in src/api/api.service.ts:250
|
||||||||||||
Parameters :
Returns :
Promise<null | Environment>
|
Public updateResourcesToEnvironment | |||||||||
updateResourcesToEnvironment(environment: Environment, resources: Array
|
|||||||||
Defined in src/api/api.service.ts:266
|
|||||||||
Parameters :
Returns :
Promise<null | Environment>
|
import { SearchCriteria } from './webApi/classes/searchCriteria.enum';
import { Api } from './webApi/classes/api.interface';
import { DictionaryType } from './webApi/classes/dictionaryType.enum';
import { Dictionary } from './webApi/data/dictionary.interface';
import { ItemSummary } from './webApi/data/itemSummary.interface';
import { DistributionSummary } from './webApi/data/distributionSummary.interface';
import { DistributionDetails } from './webApi/data/distributionDetails.interface';
import { ParameterValue } from './webApi/data/parameterValue.interface';
import { DiscoverResponse, DiscoverRequest } from './webApi/classes/discoverApi.interface';
import { DistributionFormat } from './webApi/data/distributionFormat.interface';
import { Environment } from './webApi/data/environments/environment.interface';
import { EnvironmentType } from './webApi/data/environments/environmentType.interface';
import { EnvironmentResource } from './webApi/data/environments/environmentResource.interface';
import { Organization } from './webApi/data/organization.interface';
import { Domain } from './webApi/data/domain.interface';
export class ApiService implements Api {
private delegate: null | Api = null;
private delegateName: null | string = null;
private constructor(
private readonly apiMap: Map<string, Api>,
private readonly selectionEnabled: boolean,
private readonly selectionVisible: boolean,
) {
}
public static make(api: Api, apiName: string, selectionEnabled = true, selectionVisible = true): ApiService {
const map = new Map();
map.set(apiName, api);
const as = new ApiService(map as Map<string, Api>, selectionEnabled, selectionVisible);
as.selectApi(apiName);
return as;
}
public static makeSelectable(
apis: Map<string, Api>,
nameOfDefaultApi: string,
selectionEnabled = true,
selectionVisible = true,
): ApiService {
// check map
if (!apis) {
console.log('Invalid API map');
throw new Error('Invalid API map');
}
// check map has at least one
if (apis.size === 0) {
console.log('Zero APIs in map');
throw new Error('Zero APIs in map');
}
// check map contains default
const temp = apis.get(nameOfDefaultApi);
if (!temp) {
console.log('Default API not found: ' + nameOfDefaultApi);
throw new Error('Default API not found: ' + nameOfDefaultApi);
}
const as = new ApiService(apis, selectionEnabled, selectionVisible);
as.selectApi(nameOfDefaultApi);
return as;
}
// -----------------
public isSelectionEnabled(): boolean {
return this.apiMap.size > 1 && this.selectionEnabled;
}
public isSelectionVisible(): boolean {
return this.selectionVisible;
}
public selectApi(apiName: string): void {
const temp = this.apiMap.get(apiName);
if (!temp) {
console.log('couldn\'t find an API called: ' + apiName + ' continue to use: ' + this.delegateName);
return;
}
this.delegateName = apiName;
this.delegate = temp;
}
public getSelectedApiName(): string {
return this.delegateName ?? '';
}
public getApiNames(): Array<string> {
return Array.from(this.apiMap.keys());
}
// -----------------
public discover(request: DiscoverRequest): Promise<null | DiscoverResponse> {
this.checkApiBeforeCall();
return this.delegate!.discover(request);
}
// -----------------
public getFilters(context: string): Promise<null | DiscoverResponse> {
this.checkApiBeforeCall();
return this.delegate!.getFilters(context);
}
public getDomains(context: string): Promise<null | Array<Domain>> {
this.checkApiBeforeCall();
return this.delegate!.getDomains(context);
}
public getDictionary(type: DictionaryType): Promise<Dictionary> {
this.checkApiBeforeCall();
return this.delegate!.getDictionary(type);
}
public doSearch(searchCriteriaMap: Map<SearchCriteria, unknown>): Promise<Array<ItemSummary>> {
this.checkApiBeforeCall();
return this.delegate!.doSearch(searchCriteriaMap);
}
/**
* The function `getOrganizations` checks the API before making a call and returns a promise that
* resolves to an array of `Organization` objects or `null`.
* @returns a Promise that resolves to either an array of Organization objects or null.
*/
public getOrganizations(type: string): Promise<Organization[] | null> {
this.checkApiBeforeCall();
return this.delegate!.getOrganizations(type);
}
public getOrganizationById(id: string): Promise<Organization | null> {
this.checkApiBeforeCall();
return this.delegate!.getOrganizationById(id);
}
public getDetails(summary: DistributionSummary, context: string): Promise<null | DistributionDetails> {
this.checkApiBeforeCall();
return this.delegate!.getDetails(summary, context);
}
public getDetailsById(id: string, context: string): Promise<null | DistributionDetails> {
this.checkApiBeforeCall();
return this.delegate!.getDetailsById(id, context);
}
// exectution
public executeAuthenticatedUrl(
url: string,
): Promise<Blob> {
this.checkApiBeforeCall();
return this.delegate!.executeAuthenticatedUrl(url);
}
public executeUrl(
url: string,
): Promise<Blob> {
this.checkApiBeforeCall();
return this.delegate!.executeUrl(url);
}
public executeDistributionFormat(
format: DistributionFormat,
params: null | Array<ParameterValue>,
asBlob: boolean,
): Promise<Record<string, unknown> | Blob> {
this.checkApiBeforeCall();
return this.delegate!.executeDistributionFormat(format, params, asBlob);
}
public getExecuteUrl(
format: DistributionFormat,
params: null | Array<ParameterValue>,
): string {
this.checkApiBeforeCall();
return this.delegate!.getExecuteUrl(format, params);
}
public getOriginatorUrl(distribution: DistributionSummary, params: null | Array<ParameterValue>): Promise<string> {
this.checkApiBeforeCall();
return this.delegate!.getOriginatorUrl(distribution, params);
}
/**
* The function `saveConfigurables` saves a configurable value after checking the API before making
* the call.
* @param {string} value - The `value` parameter in the `saveConfigurables` function is a string that
* represents the configuration data that needs to be saved.
* @returns The `saveConfigurables` method is returning a Promise that resolves to a string value.
*/
public saveConfigurables(value: string): Promise<string> {
this.checkApiBeforeCall();
return this.delegate!.saveConfigurables(value);
}
/**
* The function retrieveConfigurables retrieves configurable settings based on a given key.
* @param {string} key - The `key` parameter in the `retrieveConfigurables` function is a string that
* represents the configuration key used to retrieve configurable settings or values.
* @returns The `retrieveConfigurables` method returns a `Promise` that resolves to a `string` or
* `null`.
*/
public retrieveConfigurables(key: string): Promise<string | null> {
this.checkApiBeforeCall();
return this.delegate!.retrieveConfigurables(key);
}
// Environments
/**
* The function `getEnvironments` returns a promise that resolves to an array of `Environment` objects
* after checking the API before making the call.
* @returns The method `getEnvironments()` is returning a Promise that resolves to an array of
* `Environment` objects.
*/
public getEnvironments(): Promise<Array<Environment>> {
this.checkApiBeforeCall();
return this.delegate!.getEnvironments();
}
/**
* The function `getEnvironment` retrieves an environment object based on the provided environment
* parameter.
* @param {Environment} environment - The `environment` parameter is of type `Environment`. It
* represents the environment for which you want to retrieve information.
* @returns The method is returning a Promise that resolves to either an instance of the Environment
* class or null.
*/
public getEnvironment(environment: Environment): Promise<Environment | null> {
this.checkApiBeforeCall();
return this.delegate!.getEnvironment(environment);
}
public updateEnvironment(environment: Environment, newName: string, newDescription: string): Promise<null | Environment> {
this.checkApiBeforeCall();
return this.delegate!.updateEnvironment(environment, newName, newDescription);
}
public createEnvironment(name: string, description: string, serviceid: string): Promise<null | Environment> {
this.checkApiBeforeCall();
return this.delegate!.createEnvironment(name, description, serviceid);
}
public removeEnvironment(environment: Environment): Promise<boolean> {
this.checkApiBeforeCall();
return this.delegate!.removeEnvironment(environment);
}
public runJobEnvironment(environment: Environment): Promise<boolean> {
this.checkApiBeforeCall();
return this.delegate!.runJobEnvironment(environment);
}
public updateResourcesToEnvironment(environment: Environment, resources: Array<EnvironmentResource>): Promise<null | Environment> {
this.checkApiBeforeCall();
return this.delegate!.updateResourcesToEnvironment(environment, resources);
}
public getEnvironmentTypes(): Promise<Array<EnvironmentType>> {
this.checkApiBeforeCall();
return this.delegate!.getEnvironmentTypes();
}
private checkApiBeforeCall() {
if (!this.delegate) {
console.log('Throw: delegate API not selected');
throw new Error('delegate API not selected');
}
}
}