Search in sources :

Example 11 with ListEnvironmentsResponse

use of com.ibm.watson.discovery.v1.model.ListEnvironmentsResponse in project java-sdk by watson-developer-cloud.

the class Discovery method listEnvironments.

/**
 * List environments.
 *
 * <p>List existing environments for the service instance.
 *
 * @param listEnvironmentsOptions the {@link ListEnvironmentsOptions} containing the options for
 *     the call
 * @return a {@link ServiceCall} with a result of type {@link ListEnvironmentsResponse}
 */
public ServiceCall<ListEnvironmentsResponse> listEnvironments(ListEnvironmentsOptions listEnvironmentsOptions) {
    if (listEnvironmentsOptions == null) {
        listEnvironmentsOptions = new ListEnvironmentsOptions.Builder().build();
    }
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listEnvironments");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    builder.query("version", String.valueOf(this.version));
    if (listEnvironmentsOptions.name() != null) {
        builder.query("name", String.valueOf(listEnvironmentsOptions.name()));
    }
    ResponseConverter<ListEnvironmentsResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ListEnvironmentsResponse>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : ListEnvironmentsResponse(com.ibm.watson.discovery.v1.model.ListEnvironmentsResponse) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder)

Aggregations

ListEnvironmentsResponse (com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse)7 ListEnvironmentsOptions (com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsOptions)5 Test (org.junit.Test)5 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)4 Environment (com.ibm.watson.developer_cloud.discovery.v1.model.Environment)4 ListEnvironmentsResponse (com.ibm.watson.discovery.v1.model.ListEnvironmentsResponse)4 CreateEnvironmentOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions)2 GetEnvironmentOptions (com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 Authenticator (com.ibm.cloud.sdk.core.security.Authenticator)1 IamAuthenticator (com.ibm.cloud.sdk.core.security.IamAuthenticator)1 WatsonServiceUnitTest (com.ibm.watson.common.WatsonServiceUnitTest)1 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 AddDocumentOptions (com.ibm.watson.developer_cloud.discovery.v1.model.AddDocumentOptions)1 Collection (com.ibm.watson.developer_cloud.discovery.v1.model.Collection)1 Configuration (com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)1 CreateCollectionOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions)1