Introduction

The IBM Watson™ Assistant Discovery Extension for IBM Cloud Private is a cognitive search and content analytics engine that you can add to applications to identify patterns, trends and actionable insights to drive better decision-making. Securely unify structured and unstructured data with pre-enriched content, and use a simplified query language to eliminate the need for manual filtering of results.

Beginning with version 4.0.0, the Node SDK returns a Promise for all methods when a callback is not specified.

The package location moved to ibm-watson. It remains available at watson-developer-cloud but is not updated there. Use ibm-watson to stay up to date.

The code examples on this tab use the client library that is provided for Java.

Maven

<dependency>
  <groupId>com.ibm.watson</groupId>
  <artifactId>ibm-watson</artifactId>
  <version>8.0.0</version>
</dependency>

Gradle

compile 'com.ibm.watson:ibm-watson:8.0.0'

GitHub

The code examples on this tab use the client library that is provided for Node.js.

Installation

npm install ibm-watson

GitHub

The code examples on this tab use the client library that is provided for Python.

Installation

pip install --upgrade "ibm-watson>=4.0.1"

GitHub

The code examples on this tab use the client library that is provided for Ruby.

Installation

gem install ibm_watson

GitHub

The code examples on this tab use the client library that is provided for Go.

go get -u github.com/watson-developer-cloud/go-sdk/...

GitHub

The code examples on this tab use the client library that is provided for Swift.

Cocoapods

pod 'IBMWatsonDiscoveryV1', '~> 3.0.0'

Carthage

github "watson-developer-cloud/swift-sdk" ~> 3.0.0

Swift Package Manager

.package(url: "https://github.com/watson-developer-cloud/swift-sdk", from: "3.0.0")

GitHub

The code examples on this tab use the client library that is provided for .NET Standard.

Package Manager

Install-Package IBM.Watson.Discovery.v1 -Version 4.0.0

.NET CLI

dotnet add package IBM.Watson.Discovery.v1 -version 4.0.0

PackageReference

<PackageReference Include="IBM.Watson.Discovery.v1" Version="4.0.0" />

GitHub

Authentication

You authenticate by providing the API key for your service instance. A Watson Assistant Discovery Extension for IBM Cloud Private cluster has a single instance of the service and a single API key.

The SDK manages the lifecycle of the tokens for the API key.

Replace {apikey} with the API key for your service instance. Replace {icp_cluster_host} and {port} with the name or IP address of the host on which your Watson Assistant Discovery Extension for IBM Cloud Private cluster is deployed and the port number on which the service listens. The default port is 443.

curl -u "apikey:{apikey}" -X {request_method} "https://{icp_cluster_host}{:port}/discovery/api/v1/{method}"

Replace {apikey} with the API key for your service instance. Replace {icp_cluster_host} and {port} with the name or IP address of the host on which your Watson Assistant Discovery Extension for IBM Cloud Private cluster is deployed and the port number on which the service listens. The default port is 443. Replace {version} with the service version date.

Discovery discovery = new Discovery("{version}");
discovery.setUsernameAndPassword("apikey","{apikey}");
discovery.setEndPoint("https://{icp_cluster_host}{:port}/discovery/api");

Replace {apikey} with the API key for your service instance. Replace {icp_cluster_host} and {port} with the name or IP address of the host on which your Watson Assistant Discovery Extension for IBM Cloud Private cluster is deployed and the port number on which the service listens. The default port is 443. Replace {version} with the service version date.

const  = require('ibm-watson/discovery/v1');

const discovery = new DiscoveryV1({
  version: '{version}',
  username: 'apikey',
  password: '{apikey}',
  url: 'https://{icp_cluster_host}{:port}/discovery/api',
});

Replace {apikey} with the API key for your service instance. Replace {icp_cluster_host} and {port} with the name or IP address of the host on which your Watson Assistant Discovery Extension for IBM Cloud Private cluster is deployed and the port number on which the service listens. The default port is 443. Replace {version} with the service version date.

from ibm_watson import DiscoveryV1

discovery = DiscoveryV1(
    version='{version}',
    username='apikey',
    password='{apikey}',
    url='https://{icp_cluster_host}{:port}/discovery/api'
)

Replace {apikey} with the API key for your service instance. Replace {icp_cluster_host} and {port} with the name or IP address of the host on which your Watson Assistant Discovery Extension for IBM Cloud Private cluster is deployed and the port number on which the service listens. The default port is 443. Replace {version} with the service version date.

require "ibm_watson"

discovery = IBMWatson::DiscoveryV1.new(
  version: "{version}",
  username: "apikey",
  password: "{apikey}",
  url:"https://{icp_cluster_host}{:port}/discovery/api"
)

Replace {apikey} with the API key for your service instance. Replace {icp_cluster_host} and {port} with the name or IP address of the host on which your Watson Assistant Discovery Extension for IBM Cloud Private cluster is deployed and the port number on which the service listens. The default port is 443. Replace {version} with the service version date.

import "github.com/watson-developer-cloud/go-sdk/discoveryv1"

discovery, discoveryErr := discoveryv1.NewDiscoveryV1(&discoveryv1.DiscoveryV1Options{
  Version:  "{version}",
  Username: "apikey",
  Password: "{apikey}",
  URL:      "https://{icp_cluster_host}{:port}/discovery/api",
})

Replace {apikey} with the API key for your service instance. Replace {icp_cluster_host} and {port} with the name or IP address of the host on which your Watson Assistant Discovery Extension for IBM Cloud Private cluster is deployed and the port number on which the service listens. The default port is 443. Replace {version} with the service version date.

let discovery = Discovery(version: "{version}", apikey: "{apikey}")
discovery.serviceURL = "https://{icp_cluster_host}{:port}/discovery/api"

Replace {apikey} with the API key for your service instance. Replace {icp_cluster_host and {port} with the name or IP address of the host on which your Watson Assistant Discovery Extension for IBM Cloud Private cluster is deployed and the port number on which the service listens. The default port is 443. Replace {version} with the service version date.

BasicAuthConfig basicAuthConfig = new BasicAuthConfig(
    username: "apikey",
    password: "{apikey}"
    );

Discovery discovery = new Discovery("{version}", basicAuthConfig);
discovery.SetEndpoint("https://{icp_cluster_host}{:port}/discovery/api");

Service endpoint

The service endpoint for Watson Assistant Discovery Extension for IBM Cloud Private is always the following base URL:

https://{icp_cluster_host}{:port}/discovery/api

Replace {icp_cluster_host} with the name or IP address of the host on which your cluster is deployed. Replace {port} with the port number on which the service listens. The default port is 443.

Use that URL in your requests to Watson Assistant Discovery Extension for IBM Cloud Private.

Set the correct service URL by calling the setEndPoint() method of the service instance.

Set the correct service URL by calling the url parameter when you create the service instance.

Set the correct service URL by calling the url parameter when you create the service instance or by calling the set_url() method of the service instance.

Set the correct service URL by calling the url parameter when you create the service instance or by calling the url= method of the service instance.

Set the correct service URL by the URL parameter when you create the service instance or by calling the SetURL= method of the service instance.

Set the correct service URL by setting the serviceURL property of the service instance.

Set the correct service URL by calling the SetEndpoint() method of the service instance.

Example

curl -u "apikey:{apikey}" -X {request_method} "https://{icp_cluster_host}{:port}/discovery/api/{method}"

Example

Discovery discovery = new Discovery("{version}");
discovery.setUsernameAndPassword("apikey","{apikey}");
discovery.setEndPoint("https://{icp_cluster_host}{:port}/discovery/api");

Example

const  = require('ibm-watson/discovery/v1');

const discovery = new DiscoveryV1({
  version: '{version}',
  username: 'apikey',
  password: '{apikey}',
  url: 'https://{icp_cluster_host}{:port}/discovery/api',
});

Examples in the constructor and after instantiation

from ibm_watson import DiscoveryV1

discovery = DiscoveryV1(
    version='{version}',
    username='apikey',
    password='{apikey}',
    url='https://{icp_cluster_host}{:port}/discovery/api'
)

or

discovery.set_url('https://{icp_cluster_host}{:port}/discovery/api')

Examples in the constructor and after instantiation

require "ibm_watson"

discovery = IBMWatson::DiscoveryV1.new(
  version: "{version}",
  username: "apikey",
  password: "{apikey}",
  url:"https://{icp_cluster_host}{:port}/discovery/api"
)

or

discovery.url = "https://{icp_cluster_host}{:port}/discovery/api"

Examples in the constructor and after instantiation

import "github.com/watson-developer-cloud/go-sdk/discoveryv1"

discovery, discoveryErr := discoveryv1.NewDiscoveryV1(&discoveryv1.DiscoveryV1Options{
  Version:  "{version}",
  Username: "apikey",
  Password: "{apikey}",
  URL:      "https://{icp_cluster_host}{:port}/discovery/api",
})

or

discovery.SetURL("https://{icp_cluster_host}{:port}/discovery/api")

Example

let discovery = Discovery(version: "{version}", apikey: "{apikey}")
discovery.serviceURL = "https://{icp_cluster_host}{:port}/discovery/api"

Example

BasicAuthConfig basicAuthConfig = new BasicAuthConfig(
    username: "apikey",
    password: "{apikey}"
    );

Discovery discovery = new Discovery("{version}", basicAuthConfig);
discovery.SetEndpoint("https://{icp_cluster_host}{:port}/discovery/api");

Disabling SSL verification

All Watson services use Secure Sockets Layer (SSL) (or Transport Layer Security (TLS)) for secure connections between the client and server. The connection is verified against the local certificate store to ensure authentication, integrity, and confidentiality.

If you use a self-signed certificate, you need to disable SSL verification to make a successful connection.

Enabling SSL verification is highly recommended. Disabling SSL jeopardizes the security of the connection and data. Disable SSL only if absolutely necessary, and take steps to enable SSL as soon as possible.

To disable SSL verification for a curl request, use the --insecure (-k) option with the request.

To disable SSL verification, create an HttpConfigOptions object and set the disableSslVerification property to true. Then pass the object to the service instance by using the configureClient method.

To disable SSL verification, set the disable_ssl_verification parameter to true when you create the service instance.

To disable SSL verification, call the disable_SSL_verification method on the service instance.

To disable SSL verification, call the configure_http_client method on the service instance and set the disable_ssl parameter to true.

To disable SSL verification, call the DisableSSLVerification method on the service instance.

To disable SSL verification, call the disableSSLVerification() method on the service instance. You cannot disable SSL verification on Linux.

To disable SSL verification, set the DisableSslVerification property to true on the service instance.

Example that disables SSL verification

curl -k -u "apikey:{apikey}" -X {request_method} "https://{icp_cluster_host}{:port}/discovery/api/v1/{method}"

Example that disables SSL verification

Discovery discovery = new Discovery("{version}");
discovery.setUsernameAndPassword("apikey","{apikey}");
discovery.setEndPoint("https://{icp_cluster_host}{:port}/discovery/api");

HttpConfigOptions configOptions = new HttpConfigOptions.Builder()
  .disableSslVerification(true)
  .build();
discovery.configureClient(configOptions);

Example that disables SSL verification

const  = require('ibm-watson/discovery/v1');

const discovery = new DiscoveryV1({
  version: '{version}',
  username: 'apikey',
  password: '{apikey}',
  url: 'https://{icp_cluster_host}{:port}/discovery/api',
  disable_ssl_verification: true,
});

Example that disables SSL verification

from ibm_watson import DiscoveryV1

discovery = DiscoveryV1(
    version='{version}',
    username='apikey',
    password='{apikey}',
    url='https://{icp_cluster_host}{:port}/discovery/api'
)
discovery.disable_SSL_verification()

Example that disables SSL verification

require "ibm_watson"

discovery = IBMWatson::DiscoveryV1.new(
  version: "{version}",
  username: "apikey",
  password: "{apikey}",
  url:"https://{icp_cluster_host}{:port}/discovery/api"
)
discovery.configure_http_client(disable_ssl: true)

Example that disables SSL verification

import "github.com/watson-developer-cloud/go-sdk/discoveryv1"

discovery, discoveryErr := discoveryv1.NewDiscoveryV1(&discoveryv1.DiscoveryV1Options{
  Version:  "{version}",
  Username: "apikey",
  Password: "{apikey}",
  URL:      "https://{icp_cluster_host}{:port}/discovery/api",
})
discovery.DisableSSLVerification()

Example that disables SSL verification


let discovery = Discovery(version: "{version}", apiKey: "{apikey}")
discovery.disableSSLVerification()

Example that disables SSL verification

BasicAuthConfig basicAuthConfig = new BasicAuthConfig(
    username: "apikey",
    password: "{apikey}"
    );

Discovery discovery = new Discovery("{version}", basicAuthConfig);
discovery.SetEndpoint("https://{icp_cluster_host}{:port}/discovery/api");
discovery.DisableSslVerification(true);

Versioning

API requests require a version parameter that takes a date in the format version=YYYY-MM-DD. When we change the API in a backwards-incompatible way, we release a new version date.

Send the version parameter with every API request. The service uses the API version for the date you specify, or the most recent version before that date. Don't default to the current date. Instead, specify a date that matches a version that is compatible with your app, and don't change it until your app is ready for a later version.

Specify the version to use on API requests with the version parameter when you create the service instance. The service uses the API version for the date you specify, or the most recent version before that date. Don't default to the current date. Instead, specify a date that matches a version that is compatible with your app, and don't change it until your app is ready for a later version.

This documentation describes the current version of Watson Assistant Discovery Extension for IBM Cloud Private, 2018-08-01. In some cases, differences in earlier versions are noted in the descriptions of parameters and response models.

Error handling

Watson Assistant Discovery Extension for IBM Cloud Private uses standard HTTP response codes to indicate whether a method completed successfully. HTTP response codes in the 2xx range indicate success. A response in the 4xx range is some sort of failure, and a response in the 5xx range usually indicates an internal system error that cannot be resolved by the user. Response codes are listed with the method.

ErrorResponse

Name Description
code
integer
The HTTP response code.
error
string
General description of an error.

The Java SDK generates an exception for any unsuccessful method invocation. All methods that accept an argument can also throw an IllegalArgumentException.

Exception Description
IllegalArgumentException An illegal argument was passed to the method.

When the Java SDK receives an error response from the Watson Assistant Discovery Extension for IBM Cloud Private service, it generates an exception from the com.ibm.watson.developer_cloud.service.exception package. All service exceptions contain the following fields.

Field Description
statusCode The HTTP response code that is returned.
message A message that describes the error.

When the Node SDK receives an error response from the Watson Assistant Discovery Extension for IBM Cloud Private service, it creates an Error object with information that describes the error that occurred. This error object is passed as the first parameter to the callback function for the method. The contents of the error object are as shown in the following table.

Error

Field Description
code The HTTP response code that is returned.
message A message that describes the error.

The Python SDK generates an exception for any unsuccessful method invocation. When the Python SDK receives an error response from the Watson Assistant Discovery Extension for IBM Cloud Private service, it generates an ApiException that contains the following fields.

Field Description
code The HTTP response code that is returned.
message A message that describes the error.
info A dictionary of additional information about the error.

When the Ruby SDK receives an error response from the Watson Assistant Discovery Extension for IBM Cloud Private service, it generates an ApiException that contains the following fields.

Field Description
code The HTTP response code that is returned.
message A message that describes the error.
info A dictionary of additional information about the error.

The Go SDK generates an error for any unsuccessful service instantiation and method invocation. You can check for the error immediately. The contents of the error object are as shown in the following table.

Error

Field Description
code The HTTP response code that is returned.
message A message that describes the error.

The Swift SDK returns a WatsonError in the completionHandler any unsuccessful method invocation. This error type is an enum that conforms to LocalizedError and contains an errorDescription property that returns an error message. Some of the WatsonError cases contain associated values that reveal more information about the error.

Field Description
errorDescription A message that describes the error.

When the .NET Standard SDK receives an error response from the Discovery service, it generates a ServiceResponseException that contains the following fields.

Field Description
Message A message that describes the error.
CodeDescription The HTTP response code that is returned.

Example error handling

try {
  // Invoke a Watson Assistant Discovery Extension for IBM Cloud Private method
} catch (NotFoundException e) {
  // Handle Not Found (404) exception
} catch (RequestTooLargeException e) {
  // Handle Request Too Large (413) exception
} catch (ServiceResponseException e) {
  // Base class for all exceptions caused by error responses from the service
  System.out.println("Service returned status code "
    + e.getStatusCode() + ": " + e.getMessage());
}

Example error handling

discovery.method(params)
  .catch(err => {
    console.log('error:', err);
  });

Example error handling

from ibm_watson import ApiException
try:
    # Invoke a Watson Assistant Discovery Extension for IBM Cloud Private method
except ApiException as ex:
    print "Method failed with status code " + str(ex.code) + ": " + ex.message

Example error handling

require "ibm_watson"
begin
  # Invoke a Watson Assistant Discovery Extension for IBM Cloud Private method
rescue IBMWatson::ApiException => ex
  print "Method failed with status code #{ex.code}: #{ex.error}"
end

Example error handling

import "github.com/watson-developer-cloud/go-sdk/discoveryv1"

// Instantiate a service
discovery, discoveryErr := discoveryv1.NewDiscoveryV1(&discoveryv1.DiscoveryV1Options{})

// Check for error
if discoveryErr != nil {
  panic(discoveryErr)
}

// Call a method
response, responseErr := discovery.methodName(&methodOptions)

// Check for error
if responseErr != nil {
  panic(responseErr)
}

Example error handling

discovery.method() {
  response, error in

  if let error = error {
    switch error {
    case let .http(statusCode, message, metadata):
      switch statusCode {
      case .some(404):
        // Handle Not Found (404) exception
        print("Not found")
      case .some(413):
        // Handle Request Too Large (413) exception
        print("Payload too large")
      default:
        if let statusCode = statusCode {
          print("Error - code: \(statusCode), \(message ?? "")")
        }
      }
    default:
      print(error.localizedDescription)
    }
    return
  }

  guard let result = response?.result else {
    print(error?.localizedDescription ?? "unknown error")
    return
  }

  print(result)
}

Example error handling

try
{
    // Invoke a Watson discovery method
}
catch(ServiceResponseException e)
{
    Console.WriteLine("Error: " + e.Message);
}
catch (Exception e)
{
    Console.WriteLine("Error: " + e.Message);
}

Data handling

Additional headers

Some Watson services accept special parameters in headers that are passed with the request.

You can pass request header parameters in all requests or in a single request to the service.

To pass a request header, use the --header (-H) option with a curl request.

To pass header parameters with every request, use the setDefaultHeaders method of the service object.

To pass header parameters in a single request, use the addHeader method as a modifier on the request before you execute it.

To pass header parameters with every request, specify the headers parameter when you create the service object.

To pass header parameters in a single request, use the headers method as a modifier on the request before you execute it.

To pass header parameters with every request, specify the set_default_headers method of the service object.

To pass header parameters in a single request, include headers as a dict in the request.

To pass header parameters with every request, specify the add_default_headers method of the service object.

To pass header parameters in a single request, specify the headers method as a chainable method in the request.

To pass header parameters with every request, specify the SetDefaultHeaders method of the service object.

To pass header parameters in a single request, specify the Headers as a map in the request.

To pass header parameters with every request, add them to the defaultHeaders property of the service object.

To pass header parameters in a single request, pass the headers parameter to the request method.

To pass header parameters in a single request, use the WithHeader() method as a modifier on the request before you execute it.

Example header parameter in a request

curl -u "apikey:{apikey}" -X {request_method} --header "Request-Header: {header_value}" "https://{icp_cluster_host}{:port}/discovery/api/{method}"

Example header parameter in a request

ReturnType returnValue = discovery.methodName(parameters)
  .addHeader("Custom-Header", "{header_value}")
  .execute();

Example header parameter in a request

const parameters = {
  {parameters}
};

discovery.methodName(
  parameters,
  headers: {
    'Custom-Header': '{header_value}'
  })
   .then(result => {
    console.log(response);
  })
  .catch(err => {
    console.log('error:', err);
  });

Example header parameter in a request

response = discovery.methodName(
    parameters,
    headers = {
        'Custom-Header': '{header_value}'
    })

Example header parameter in a request

response = discovery.headers(
  "Custom-Header" => "{header_value}"
).methodName(parameters)

Example header parameter in a request

response, _ := discoveryv1.methodName(
  &methodOptions{
    Headers: map[string]string{
      "Accept": "application/json",
    },
  },
)

Example header parameter in a request

let customHeader: [String: String] = ["Custom-Header": "{header_value}"]
discovery.methodName(parameters, headers: customHeader) {
  response, error in
}

Example header parameter in a request

BasicAuthConfig basicAuthConfig = new BasicAuthConfig(
    username: "apikey",
    password: "{apikey}"
    );
Discovery discovery = new Discovery("{version}", basicAuthConfig);
discovery.SetEndpoint("https://{icp_cluster_host}{:port}/discovery/api");
discovery.WithHeader("Custom-Header", "header_value");

Response details

Watson Assistant Discovery Extension for IBM Cloud Private might return information to the application in response headers.

To access all response headers that the service returns, include the --include (-i) option with a curl request. To see detailed response data for the request, including request headers, response headers, and additional debugging information, include the --verbose (-v) option with the request.

Example request to access response headers

curl -u "apikey:{apikey}" -X {request_method} --include "https://{icp_cluster_host}{:port}/discovery/api/{method}"

To access information in the response headers, use one of the request methods that returns details with the response: executeWithDetails(), enqueueWithDetails(), or rxWithDetails(). These methods return a Response<T> object, where T is the expected response model. Use the getResult() method to access the response object for the method, and use the getHeaders() method to access information in response headers.

Example request to access response headers

Response<ReturnType> response = discovery.methodName(parameters)
  .executeWithDetails();
// Access response from methodName
ReturnType returnValue = response.getResult();
// Access information in response headers
Headers responseHeaders = response.getHeaders();

To access information in the response headers, add the return_response parameter set to true and specify the headers attribute on the response object that is returned by the method. To access information in the response object, use the following properties.

Property Description
result Returns the response for the service-specific method.
headers Returns the response header information.
status Returns the HTTP status code.

Example request to access response headers

const parameters = {
  {parameters}
};

parameters.return_response = true;

discovery.methodName(parameters)
  .then(response => {
    console.log(response.headers);
  })
  .catch(err => {
    console.log('error:', err);
  });

The return value from all service methods is a DetailedResponse object. To access information in the result object or response headers, use the following methods.

DetailedResponse

Method Description
get_result() Returns the response for the service-specific method.
get_headers() Returns the response header information.
get_status_code() Returns the HTTP status code.

Example request to access response headers

discovery.set_detailed_response(True)
response = discovery.methodName(parameters)
# Access response from methodName
print(json.dumps(response.get_result(), indent=2))
# Access information in response headers
print(response.get_headers())
# Access HTTP response status
print(response.get_status_code())

The return value from all service methods is a DetailedResponse object. To access information in the response object, use the following properties.

DetailedResponse

Property Description
result Returns the response for the service-specific method.
headers Returns the response header information.
status Returns the HTTP status code.

Example request to access response headers

response = discovery.methodName(parameters)
# Access response from methodName
print response.result
# Access information in response headers
print response.headers
# Access HTTP response status
print response.status

The return value from all service methods is a DetailedResponse object. To access information in the response object or response headers, use the following methods.

DetailedResponse

Method Description
GetResult() Returns the response for the service-specific method.
GetHeaders() Returns the response header information.
GetStatusCode() Returns the HTTP status code.

Example request to access response headers

import "github.com/IBM/go-sdk-core/core"
response, _ := discoveryv1.methodName(&methodOptions{})

// Access result
core.PrettyPrint(response.GetResult(), "Result ")

// Access response headers
core.PrettyPrint(response.GetHeaders(), "Headers ")

// Access status code
core.PrettyPrint(response.GetStatusCode(), "Status Code ")

All response data is available in the WatsonResponse<T> object that is returned in each method's completionHandler.

Example request to access response headers

discovery.methodName(parameters) {
  response, error in

  guard let result = response?.result else {
    print(error?.localizedDescription ?? "unknown error")
    return
  }
  print(result) // The data returned by the service
  print(response?.statusCode)
  print(response?.headers)
}

The response contains fields for response headers, response JSON, and the status code.

DetailedResponse

Property Description
Result Returns the result for the service-specific method.
Response Returns the raw JSON response for the service-specific method.
Headers Returns the response header information.
StatusCode Returns the HTTP status code.

Example request to access response headers

var results = discovery.MethodName(parameters);

var result = results.Result;            //  The result object
var responseHeaders = results.Headers;  //  The response headers
var responseJson = results.Response;    //  The raw response JSON
var statusCode = results.StatusCode;    //  The response status code

Synchronous and asynchronous requests

The Java SDK supports both synchronous (blocking) and asynchronous (non-blocking) execution of service methods. All service methods implement the ServiceCall interface.

  • To call a method synchronously, use the execute method of the ServiceCall interface. You can call the execute method directly from an instance of the service.
  • To call a method asynchronously, use the enqueue method of the ServiceCall interface to receive a callback when the response arrives. The ServiceCallback interface of the method's argument provides onResponse and onFailure methods that you override to handle the callback.

The Ruby SDK supports both synchronous (blocking) and asynchronous (non-blocking) execution of service methods. All service methods implement the Concurrent::Async module. When you use the synchronous or asynchronous methods, an IVar object is returned. You access the DetailedResponse object by calling ivar_object.value.

For more information about the Ivar object, see the IVar class docs.

  • To call a method synchronously, either call the method directly or use the .await chainable method of the Concurrent::Async module.

    Calling a method directly (without .await) returns a DetailedResponse object.

  • To call a method asynchronously, use the .async chainable method of the Concurrent::Async module.

You can call the .await and .async methods directly from an instance of the service.

Example synchronous request

ReturnType returnValue = discovery.method(parameters).execute();

Example asynchronous request

discovery.method(parameters).enqueue(new ServiceCallback<ReturnType>() {
  @Override public void onResponse(ReturnType response) {
    . . .
  }
  @Override public void onFailure(Exception e) {
    . . .
  }
});

Example synchronous request

response = discovery.method_name(parameters)

or

response = discovery.await.method_name(parameters)

Example asynchronous request

response = discovery.async.method_name(parameters)

Methods

List environments

List existing environments for the service instance.

List existing environments for the service instance.

List existing environments for the service instance.

List existing environments for the service instance.

List existing environments for the service instance.

List existing environments for the service instance.

List existing environments for the service instance.

GET /v1/environments
(discovery *DiscoveryV1) ListEnvironments(listEnvironmentsOptions *ListEnvironmentsOptions) (*core.DetailedResponse, error)
ServiceCall<ListEnvironmentsResponse> listEnvironments(ListEnvironmentsOptions listEnvironmentsOptions)
listEnvironments(params, [callback()])
list_environments(self, name=None, **kwargs)
list_environments(name: nil)
func listEnvironments(
    name: String? = nil,
    headers: [String: String]? = nil,
    completionHandler: @escaping (WatsonResponse<ListEnvironmentsResponse>?, WatsonError?) -> Void)
Request

Instantiate the ListEnvironmentsOptions struct and set the fields to provide parameter values for the ListEnvironments method.

Use the ListEnvironmentsOptions.Builder to create a ListEnvironmentsOptions object that contains the parameter values for the listEnvironments method.

Query Parameters

  • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

    Constraints: Value must match regular expression ^\d{4}-\d{2}-\d{2}$

  • Show only the environment with the given name.

The ListEnvironments options.

The listEnvironments options.

parameters

  • Show only the environment with the given name.

parameters

  • Show only the environment with the given name.

parameters

  • Show only the environment with the given name.

parameters

  • Show only the environment with the given name.

Response

Object containing an array of configured environments information.

Object containing an array of configured environments information.

Example:

Object containing an array of configured environments information.

Example:

Object containing an array of configured environments information.

Example:

Object containing an array of configured environments information.

Example:

Object containing an array of configured environments information.

Example:

Object containing an array of configured environments information.

Example:

Status Code

  • Successful response.

  • Bad request.

Example responses

Get environment info

GET /v1/environments/{environment_id}
(discovery *DiscoveryV1) GetEnvironment(getEnvironmentOptions *GetEnvironmentOptions) (*core.DetailedResponse, error)
ServiceCall<Environment> getEnvironment(GetEnvironmentOptions getEnvironmentOptions)
getEnvironment(params, [callback()])
get_environment(self, environment_id, **kwargs)
get_environment(environment_id:)
func getEnvironment(
    environmentID: String,
    headers: [String: String]? = nil,
    completionHandler: @escaping (WatsonResponse<Environment>?, WatsonError?) -> Void)
Request

Instantiate the GetEnvironmentOptions struct and set the fields to provide parameter values for the GetEnvironment method.

Use the GetEnvironmentOptions.Builder to create a GetEnvironmentOptions object that contains the parameter values for the getEnvironment method.

Path Parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

Query Parameters

  • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

    Constraints: Value must match regular expression ^\d{4}-\d{2}-\d{2}$

The GetEnvironment options.

The getEnvironment options.

parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

Response

Details about an environment.

Details about an environment.

Example:

Details about an environment.

Example:

Details about an environment.

Example:

Details about an environment.

Example:

Details about an environment.

Example:

Details about an environment.

Example:

Status Code

  • Environment fetched.

  • Bad request.

Example responses

Add configuration

Creates a new configuration.

If the input configuration contains the configuration_id, created, or updated properties, then they are ignored and overridden by the system, and an error is not returned so that the overridden fields do not need to be removed when copying a configuration.

The configuration can contain unrecognized JSON fields. Any such fields are ignored and do not generate an error. This makes it easier to use newer configuration files with older versions of the API and the service. It also makes it possible for the tooling to add additional metadata and information to the configuration.

Creates a new configuration.

If the input configuration contains the configuration_id, created, or updated properties, then they are ignored and overridden by the system, and an error is not returned so that the overridden fields do not need to be removed when copying a configuration.

The configuration can contain unrecognized JSON fields. Any such fields are ignored and do not generate an error. This makes it easier to use newer configuration files with older versions of the API and the service. It also makes it possible for the tooling to add additional metadata and information to the configuration.

Creates a new configuration.

If the input configuration contains the configuration_id, created, or updated properties, then they are ignored and overridden by the system, and an error is not returned so that the overridden fields do not need to be removed when copying a configuration.

The configuration can contain unrecognized JSON fields. Any such fields are ignored and do not generate an error. This makes it easier to use newer configuration files with older versions of the API and the service. It also makes it possible for the tooling to add additional metadata and information to the configuration.

Creates a new configuration.

If the input configuration contains the configuration_id, created, or updated properties, then they are ignored and overridden by the system, and an error is not returned so that the overridden fields do not need to be removed when copying a configuration.

The configuration can contain unrecognized JSON fields. Any such fields are ignored and do not generate an error. This makes it easier to use newer configuration files with older versions of the API and the service. It also makes it possible for the tooling to add additional metadata and information to the configuration.

Creates a new configuration.

If the input configuration contains the configuration_id, created, or updated properties, then they are ignored and overridden by the system, and an error is not returned so that the overridden fields do not need to be removed when copying a configuration.

The configuration can contain unrecognized JSON fields. Any such fields are ignored and do not generate an error. This makes it easier to use newer configuration files with older versions of the API and the service. It also makes it possible for the tooling to add additional metadata and information to the configuration.

Creates a new configuration.

If the input configuration contains the configuration_id, created, or updated properties, then they are ignored and overridden by the system, and an error is not returned so that the overridden fields do not need to be removed when copying a configuration.

The configuration can contain unrecognized JSON fields. Any such fields are ignored and do not generate an error. This makes it easier to use newer configuration files with older versions of the API and the service. It also makes it possible for the tooling to add additional metadata and information to the configuration.

Creates a new configuration.

If the input configuration contains the configuration_id, created, or updated properties, then they are ignored and overridden by the system, and an error is not returned so that the overridden fields do not need to be removed when copying a configuration.

The configuration can contain unrecognized JSON fields. Any such fields are ignored and do not generate an error. This makes it easier to use newer configuration files with older versions of the API and the service. It also makes it possible for the tooling to add additional metadata and information to the configuration.

POST /v1/environments/{environment_id}/configurations
(discovery *DiscoveryV1) CreateConfiguration(createConfigurationOptions *CreateConfigurationOptions) (*core.DetailedResponse, error)
ServiceCall<Configuration> createConfiguration(CreateConfigurationOptions createConfigurationOptions)
createConfiguration(params, [callback()])
create_configuration(self, environment_id, name, description=None, conversions=None, enrichments=None, normalizations=None, source=None, **kwargs)
create_configuration(environment_id:, name:, description: nil, conversions: nil, enrichments: nil, normalizations: nil, source: nil)
func createConfiguration(
    environmentID: String,
    name: String,
    description: String? = nil,
    conversions: Conversions? = nil,
    enrichments: Enrichments? = nil,
    normalizations: Normalizations? = nil,
    source: Source? = nil,
    headers: [String: String]? = nil,
    completionHandler: @escaping (WatsonResponse<Configuration>?, WatsonError?) -> Void)
Request

Instantiate the CreateConfigurationOptions struct and set the fields to provide parameter values for the CreateConfiguration method.

Use the CreateConfigurationOptions.Builder to create a CreateConfigurationOptions object that contains the parameter values for the createConfiguration method.

Path Parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

Query Parameters

  • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

    Constraints: Value must match regular expression ^\d{4}-\d{2}-\d{2}$

Input an object that enables you to customize how your content is ingested and what enrichments are added to your data.

name is required and must be unique within the current environment. All other properties are optional.

If the input configuration contains the configuration_id, created, or updated properties, then they will be ignored and overridden by the system (an error is not returned so that the overridden fields do not need to be removed when copying a configuration).

The configuration can contain unrecognized JSON fields. Any such fields will be ignored and will not generate an error. This makes it easier to use newer configuration files with older versions of the API and the service. It also makes it possible for the tooling to add additional metadata and information to the configuration.

Example:

The CreateConfiguration options.

The createConfiguration options.

parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The name of the configuration.

    Constraints: 0 ≤ length ≤ 255

  • The description of the configuration, if available.

  • The document conversion settings for the configuration.

  • An array of document enrichment settings for the configuration.

  • An array of document normalization settings for the configuration.

  • Object containing source parameters for the configuration.

parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The name of the configuration.

    Constraints: 0 ≤ length ≤ 255

  • The description of the configuration, if available.

  • The document conversion settings for the configuration.

  • An array of document enrichment settings for the configuration.

  • An array of document normalization settings for the configuration.

  • Object containing source parameters for the configuration.

parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The name of the configuration.

    Constraints: 0 ≤ length ≤ 255

  • The description of the configuration, if available.

  • The document conversion settings for the configuration.

  • An array of document enrichment settings for the configuration.

  • An array of document normalization settings for the configuration.

  • Object containing source parameters for the configuration.

parameters

  • The ID of the environment.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The name of the configuration.

    Constraints: 0 ≤ length ≤ 255

  • The description of the configuration, if available.

  • The document conversion settings for the configuration.

  • An array of document enrichment settings for the configuration.

  • An array of document normalization settings for the configuration.

  • Object containing source parameters for the configuration.

    Response

    A custom configuration for the environment.

    A custom configuration for the environment.

    Example:

    A custom configuration for the environment.

    Example:

    A custom configuration for the environment.

    Example:

    A custom configuration for the environment.

    Example: