Notebooks API C++ Client 2.8.0
A C++ Client Library for the Notebooks API
|
An idiomatic C++ client library for the Notebooks API. Use this API to programmatically manage notebooks in Google Cloud. Learn more about notebooks at the Vertex AI Workbench site.
While this library is GA, please note Google Cloud C++ client libraries do not follow Semantic Versioning.
This library requires a C++14 compiler. It is supported (and tested) on multiple Linux distributions, as well as Windows and macOS. The README on GitHub provides detailed instructions to install the necessary dependencies, as well as how to compile the client library.
In order to use the Notebooks API C++ client library from your own code, you'll need to configure your build system to discover and compile the Cloud C++ client libraries. In some cases your build system or package manager may need to download the libraries too. The Cloud C++ client libraries natively support Bazel and CMake as build systems. We've created a minimal, "Hello World", quickstart that includes detailed instructions on how to compile the library for use in your application. You can fetch the source from GitHub as normal:
The following shows the code that you'll run in the google/cloud/notebooks/quickstart/
directory, which should give you a taste of the Notebooks API C++ client library API.
GOOGLE_CLOUD_CPP_MANAGED_NOTEBOOK_SERVICE_ENDPOINT=...
overrides the EndpointOption
(which defaults to "notebooks.googleapis.com") used by MakeManagedNotebookServiceConnection()
.GOOGLE_CLOUD_CPP_NOTEBOOK_SERVICE_ENDPOINT=...
overrides the EndpointOption
(which defaults to "notebooks.googleapis.com") used by MakeNotebookServiceConnection()
.GOOGLE_CLOUD_CPP_ENABLE_TRACING=rpc
turns on tracing for most gRPC calls. The library injects an additional Stub decorator that prints each gRPC request and response. Unless you have configured your own logging backend, you should also set GOOGLE_CLOUD_CPP_ENABLE_CLOG
to produce any output on the program's console.GOOGLE_CLOUD_CPP_ENABLE_TRACING=rpc-streams
turns on tracing for streaming gRPC calls. This can produce a lot of output, so use with caution!GOOGLE_CLOUD_CPP_TRACING_OPTIONS=...
modifies the behavior of gRPC tracing, including whether messages will be output on multiple lines, or whether string/bytes fields will be truncated.GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes
turns on logging in the library. Basically the library always "logs" but the logging infrastructure has no backend to actually print anything until the application sets a backend or it sets this environment variable.This library never throws exceptions to signal error, but you can use exceptions to detect errors in the returned objects. In general, the library returns a StatusOr<T>
if an error is possible. This is an "outcome" type, when the operation is successful a StatusOr<T>
converts to true
in boolean context (and its .ok()
member function returns true
), the application can then use operator->
or operator*
to access the T
value. When the operation fails a StatusOr<T>
converts to false
(and .ok()
returns false
). It is undefined behavior to use the value in this case.
If you prefer to use exceptions on error, you can use the .value()
accessor. It will return the T
value or throw on error.
For operations that do not return a value the library simply returns google::cloud::Status
.
In some cases, you may need to override the default endpoint used by the client library. Use the google::cloud::EndpointOption
when initializing the client library to change this default.
For example, this will override the default endpoint for notebooks_v1::ManagedNotebookServiceClient
:
Follow these links to find examples for other *Client
classes: notebooks_v1::ManagedNotebookServiceClient notebooks_v1::NotebookServiceClient
Some applications cannot use the default authentication mechanism (known as Application Default Credentials). You can override this default using google::cloud::UnifiedCredentialsOption
. The following example shows how to explicitly load a service account key file.
Follow these links to find examples for other *Client
classes: notebooks_v1::ManagedNotebookServiceClient notebooks_v1::NotebookServiceClient
Keep in mind that we chose this as an example because it is relatively easy to understand. Consult the Best practices for managing service account keys guide for more details.
google::cloud::Credentials
objects.The library automatically retries requests that fail with transient errors, and uses exponential backoff to backoff between retries. Application developers can override the default policies.