Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*/
package com.sap.cds.feature.aicore.core;

import com.sap.ai.sdk.core.AiCoreService;
import com.sap.ai.sdk.core.client.ConfigurationApi;
import com.sap.ai.sdk.core.client.DeploymentApi;
import com.sap.ai.sdk.core.client.ResourceGroupApi;
import com.sap.cds.feature.aicore.core.handler.AICoreApplicationServiceHandler;
import com.sap.cds.feature.aicore.core.handler.ActionHandler;
import com.sap.cds.feature.aicore.core.handler.ConfigurationHandler;
Expand Down Expand Up @@ -48,7 +52,14 @@ public void services(CdsRuntimeConfigurer configurer) {

if (hasBinding) {
AICoreServiceImpl service =
new AICoreServiceImpl(AICoreService.DEFAULT_NAME, runtime, multiTenancyEnabled);
new AICoreServiceImpl(
AICoreService.DEFAULT_NAME,
runtime,
multiTenancyEnabled,
new DeploymentApi(),
new ConfigurationApi(),
new ResourceGroupApi(),
new AiCoreService());
configurer.service(service);
logger.info("Registered AICoreService backed by AI Core binding.");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ public class AICoreServiceImpl extends AbstractAICoreService {
private final ResourceGroupApi resourceGroupApi;
private final AiCoreService sdkService;

public AICoreServiceImpl(String name, CdsRuntime runtime, boolean multiTenancyEnabled) {
public AICoreServiceImpl(
String name,
CdsRuntime runtime,
boolean multiTenancyEnabled,
DeploymentApi deploymentApi,
ConfigurationApi configurationApi,
ResourceGroupApi resourceGroupApi,
AiCoreService sdkService) {
super(name, runtime);
this.multiTenancyEnabled = multiTenancyEnabled;
CdsEnvironment env = runtime.getEnvironment();
Expand All @@ -82,10 +89,10 @@ public AICoreServiceImpl(String name, CdsRuntime runtime, boolean multiTenancyEn
this.tenantResourceGroupCache = newCache();
this.resourceGroupDeploymentCache = newCache();
this.deploymentLocks = newCache();
this.deploymentApi = new DeploymentApi();
this.configurationApi = new ConfigurationApi();
this.resourceGroupApi = new ResourceGroupApi();
this.sdkService = new AiCoreService();
this.deploymentApi = deploymentApi;
this.configurationApi = configurationApi;
this.resourceGroupApi = resourceGroupApi;
this.sdkService = sdkService;
Comment thread
Schmarvinius marked this conversation as resolved.
}

private static <V> Cache<String, V> newCache() {
Expand Down
Loading