@Beta public class LeonardoMlService extends Object
LeonardoMlFoundation
.
Be aware that this class is in Beta (as indicated by the annotation) and therefore subject to breaking changes.
Constructor and Description |
---|
LeonardoMlService(ScpCfService mlService)
Create an instance with the ML service information provided.
|
Modifier and Type | Method and Description |
---|---|
protected URI |
combineServiceUriWithRequestPath(URI originalRequestUriOrNull)
Combines the service URI with the original request path, query, and fragment.
|
static LeonardoMlService |
create(String cfServiceType,
String serviceUrlKey)
Generic creation of a service instance.
|
<R> R |
invoke(org.apache.http.client.methods.HttpRequestBase request,
Function<org.apache.http.HttpResponse,R> resultProcessor)
Invokes the given request against the service and returns results.
|
public LeonardoMlService(@Nonnull ScpCfService mlService)
mlService
- service information - ideally provided from LeonardoMlFoundation
's methods.IllegalArgumentException
- if there is no service location info available in given service or if it is not a URI.create(String, String)
@Nonnull public static LeonardoMlService create(@Nonnull String cfServiceType, @Nonnull String serviceUrlKey) throws CloudPlatformException
cfServiceType
- the Cloud Foundry service type to look for in the environmentserviceUrlKey
- 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 typerequest
- 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 failsCloudPlatformException
- 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 © 2020 SAP SE. All rights reserved.