Skip to main content

Discovery Service APIs

The Discovery Service package provides two main functions.

Both functions return a discovery object that can be used to obtain information about the H2O AI Cloud environment, its services, and its clients.

Configuration

Wave Apps and managed Jupyter notebooks are automatically set up so that you don't actually need to configure anything. For the local development, the H2O_CLOUD_ENVIRONMENT environment variable can be used to specify the H2O AI Cloud environment for which the discovery should be performed.

export H2O_CLOUD_ENVIRONMENT="https://<your H2O.ai Cloud domain>"

discover (synchronous)

def discover(environment: Optional[str] = None,
discovery_address: Optional[str] = None) -> Discovery
  • Obtains and returns a Discovery object from the Discovery Service.
  • Both arguments are optional. If neither is provided, the environment variable H2O_CLOUD_ENVIRONMENT is used. If that is not set, the environment variable H2O_CLOUD_DISCOVERY is used. If that is not set, a LookupError is raised.

Arguments

  • environment - The H2O AI Cloud environment URL to use (e.g. https://cloud.h2o.ai).
  • discovery_address - The address of the discovery service.

discover (asynchronous)

async def discover_async(environment: Optional[str] = None,
discovery_address: Optional[str] = None) -> Discovery
  • Obtains and returns a Discovery object from the Discovery Service.
  • Both arguments are optional. If neither is provided, the environment variable H2O_CLOUD_ENVIRONMENT is used. If that is not set, the environment variable H2O_CLOUD_DISCOVERY is used. If that is not set, a LookupError is raised.

Arguments

  • environment - The H2O AI Cloud environment URL to use (e.g. https://cloud.h2o.ai).
  • discovery_address - The address of the discovery service.

Service objects

@dataclasses.dataclass(frozen=True)
class Service()

Representation of a registered service record.

name

Name of the Service (e.g., "services/my-service-name").

display_name

Name of the Service that can be displayed on the front-end.

uri

  • URI for accessing the Service.
  • This is usually the connection string that can be passed to the client for the particular service.

version

  • Version of the service.
  • Can be the version of the API or the version of the service.
  • Clients can utilize this information to change their behavior when accessing the service or downloading the correct client version.

oauth2_scope

  • OAuth 2.0 Scope is required to access the service.
  • Clients request the access token with this scope in order to access the service.
  • If the scope is not defined (or empty), clients should use h2o_cloud_platform_scope.

python_client

  • Requirement Specifier (PEP 508) for the Python client that can be used for accessing the service.
  • Any string that can be pip installed (e.g.,"my-client==0.1.0")

from_json_dict

@classmethod
def from_json_dict(cls, json: Mapping[str, str]) -> "Service"

Create a Service from a JSON dict returned by the server.

Client Objects

@dataclasses.dataclass(frozen=True)
class Client()

Representation of a registered client record.

name

Name of the client (e.g.,"clients/h2o-public-client").

display_name

Name of the client that can be displayed on the front-end.

oauth2_client_id

Public OAuth 2.0 client ID that the client needs to use to identify itself with the IDP.

from_json_dict

@classmethod
def from_json_dict(cls, json: Mapping[str, str]) -> "Client"

Create a Client from a JSON dict returned by the server.

Environment Objects

@dataclasses.dataclass(frozen=True)
class Environment()

Representation of the information about the H2O AI Cloud environment.

h2o_cloud_environment

  • Identifier of the environment (e.g.,"https://cloud.h2o.ai").
  • This is the base URL of the environment.
  • Clients can use this to validate that they are talking to the correct environment.

issuer_url

  • OpenID Connect issuer_url.
  • This is where clients find the OpenID Connect discovery on the well-known endpoint.

h2o_cloud_platform_oauth2_scope

  • OAuth 2.0 scope that clients should use to access the H2O AI Cloud Platform.
  • This is the default scope that clients should use if the service does not define its own scope.

h2o_cloud_version

  • Version of the H2O Cloud Platform release that is running in the environment in the XC YY.MM.V format for released versions (e.g. MC 23.04.01 for managed cloud or HC 23.01.1 for hybrid cloud).
  • Can be arbitrary string for testing or special environments.

from_json_dict

@classmethod
def from_json_dict(cls, json: Mapping[str, str]) -> "Environment"

Create an Environment from a JSON dict returned by the server.

Discovery Objects

@dataclasses.dataclass(frozen=True)
class Discovery()

Representation of the discovery records.

environment

Information about the environment.

services

Map of registered services in the {"service-identifier": Service(...)} format.

clients

Map of registered clients in the {"client-identifier": Client(...)} format.


Feedback