Skip to content

Commit

Permalink
introduced new list of constants for Cloud SAP
Browse files Browse the repository at this point in the history
  • Loading branch information
Davo00 committed Oct 26, 2023
1 parent 3afb861 commit 424572c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 6 additions & 3 deletions workbench/backend/src/app/plugin/ai-data-api.dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Context } from '../../ctx.decorator';
import { AxiosRequestConfig, AxiosError } from 'axios';
import { tap, catchError } from 'rxjs/operators';
import { throwError } from 'rxjs';
import { FSM_HOSTS_CORESUITE_TO_COREINFRA } from 'src/common/constants';
import { FSM_HOSTS_CORESUITE_TO_COREINFRA, FSM_HOSTS_CORESUITE_TO_SAPCLOUD } from 'src/common/constants';

export type PluginDto = {
id: string,
Expand All @@ -28,6 +28,10 @@ export class AiDataAPIDAO {
return `https://${FSM_HOSTS_CORESUITE_TO_COREINFRA.get(host.toLowerCase()) || ''}`;
}

private resolveSAPCloudHost(host: string) {
return `https://${FSM_HOSTS_CORESUITE_TO_SAPCLOUD.get(host.toLowerCase()) || ''}`;
}

private getParams(ctx: Context) {
return {
companyId: ctx.companyId,
Expand Down Expand Up @@ -76,10 +80,9 @@ export class AiDataAPIDAO {
}

getAll(ctx: Context) {
const cloudHost = ctx.cloudHost.replace("dev.coresuite.com", "fsm-dev.cloud.sap")
return this.request<PluginFetchResultDTO>({
method: 'GET',
url: `https://${cloudHost}/optimization/api/v1/plugins`,
url: `${this.resolveSAPCloudHost(ctx.cloudHost)}/optimization/api/v1/plugins`,
headers: this.getHeaders(ctx),
params: this.getParams(ctx),
responseType: 'json',
Expand Down
12 changes: 11 additions & 1 deletion workbench/backend/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,14 @@ export const FSM_HOSTS_CORESUITE_TO_COREINFRA = new Map<string, string>()
.set('de.coresuite.com', 'ingress.de-1.coreinfra.io')
.set('us.coresuite.com', 'ingress.us-1.coreinfra.io')
.set('au.coresuite.com', 'ingress.au-1.coreinfra.io')
.set('cn.coresuite.com', 'ingress.cn-1.coreinfra.io');
.set('cn.coresuite.com', 'ingress.cn-1.coreinfra.io');

export const FSM_HOSTS_CORESUITE_TO_SAPCLOUD = new Map<string, string>()
.set('et.dev.coresuite.com', 'et.fsm-dev.cloud.sap')
.set('qt.dev.coresuite.com', 'qt.fsm-dev.cloud.sap')
.set('dt.dev.coresuite.com', 'dt.fsm-dev.cloud.sap')
.set('us.coresuite.com', 'us.fsm-dev.cloud.sap')
.set('au.coresuite.com', 'au.fsm-dev.cloud.sap')
.set('de.coresuite.com', 'de.fsm-dev.cloud.sap')
.set('eu.coresuite.com', 'eu.fsm-dev.cloud.sap')
.set('cn.coresuite.com', 'cn.fsm-dev.cloud.sap');

0 comments on commit 424572c

Please sign in to comment.