Skip to content

Commit

Permalink
Added Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesDuboisSAP committed Oct 16, 2024
1 parent 329b182 commit 9f5b2cc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/src/main/java/com/sap/ai/sdk/core/AiCoreDeployment.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,34 @@
import javax.annotation.Nonnull;
import lombok.RequiredArgsConstructor;

/** Connectivity convenience methods for AI Core with deployment. */
@RequiredArgsConstructor
public class AiCoreDeployment implements AiCoreDestination {
private final AiCoreService aiCoreService;

// the deployment id handler to be used, based on instance
@Nonnull private final Function<AiCoreDeployment, String> deploymentId;

/**
* Set the resource group.
*
* @param resourceGroup The resource group.
* @return A new instance of the AI Core service.
*/
@Nonnull
public AiCoreDeployment withResourceGroup(@Nonnull final String resourceGroup) {
aiCoreService.setResourceGroup(resourceGroup);
return this;
}

@Nonnull
@Override
public Destination destination() throws DestinationAccessException, DestinationNotFoundException {
aiCoreService.deploymentId = deploymentId.apply(this);
return aiCoreService.destination();
}

@Nonnull
@Override
public ApiClient client() {
aiCoreService.deploymentId = deploymentId.apply(this);
return aiCoreService.client();
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/com/sap/ai/sdk/core/AiCoreService.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public Destination destination() {
return builder.build();
}

/**
* Update and set the URL for the destination.
*
* @param builder The destination builder.
* @param dest The original destination reference.
*/
protected void destinationSetUrl(
@Nonnull final DefaultHttpDestination.Builder builder, @Nonnull final Destination dest) {
String uri = dest.get(DestinationProperty.URI).get();
Expand All @@ -88,6 +94,11 @@ protected void destinationSetUrl(
builder.uri(uri + "v2/inference/deployments/%s/".formatted(deploymentId));
}

/**
* Update and set the default request headers for the destination.
*
* @param builder The destination builder.
*/
protected void destinationSetHeaders(@Nonnull final DefaultHttpDestination.Builder builder) {
builder.property(AI_RESOURCE_GROUP, getResourceGroup());
}
Expand Down

0 comments on commit 9f5b2cc

Please sign in to comment.