@Beta public class LeonardoMlService extends Object
Be aware that this class is in Beta (as indicated by the annotation) and therefore subject to breaking changes.
|Constructor and Description|
Create an instance with the ML service information provided.
|Modifier and Type||Method and Description|
Combines the service URI with the original request path, query, and fragment.
Generic creation of a service instance.
Invokes the given request against the service and returns results.
public LeonardoMlService(@Nonnull ScpCfService mlService)
mlService- service information - ideally provided from
IllegalArgumentException- if there is no service location info available in given service or if it is not a URI.
@Nonnull public static LeonardoMlService create(@Nonnull String cfServiceType, @Nonnull String serviceUrlKey) throws CloudPlatformException
cfServiceType- the Cloud Foundry service type to look for in the environment
serviceUrlKey- the name of the URL entry for the specific service in the credentials section of the Cloud Foundry service information.
CloudPlatformException- if the service cannot be found or required information is missing
@Nullable public <R> R invoke(@Nonnull org.apache.http.client.methods.HttpRequestBase request, @Nonnull Function<org.apache.http.HttpResponse,R> resultProcessor) throws MlServiceFailureException, CloudPlatformException
R- result type
request- the request prepared with request entity. Only path, query and fragment of the target URI will be considered. Host and port will be set according to the URL of the machine learning service, and the target path of the given request will be appended to the path of the service URL.
resultProcessor- will be invoked with the request response for reading and returning the result. An exception thrown by the processor will be passed through.
MlServiceFailureException- if the service invocation fails
CloudPlatformException- if there is a problem authorizing the access
@Nonnull protected URI combineServiceUriWithRequestPath(@Nullable URI originalRequestUriOrNull)
originalRequestUriOrNull- The request URI to combine with the service URI. Only path, query and fragment of the target URI will be considered. Host and port will be set according to the URL of the machine learning service, and the target path of the given request will be appended to the path of the service URL.
Copyright © 2021 SAP SE. All rights reserved.