Compute Engine API C++ Client Library

An idiomatic C++ client library for the Compute Engine API, a service to create and manage cloud computing resources.

This library requires a C++14 compiler. It is supported (and tested) on multiple Linux distributions, as well as Windows and macOS. The [README][github-readme] on [GitHub][github-link] provides detailed instructions to install the necessary dependencies, as well as how to compile the client library.

Quickstart

The following shows the code that you'll run in the google/cloud/compute/quickstart/ directory, which should give you a taste of the Cloud Compute Engine API C++ client library.

#include "google/cloud/compute/disks/v1/disks_client.h"
#include <iostream>

int main(int argc, char* argv[]) try {
  if (argc != 3) {
    std::cerr << "Usage: " << argv[0] << " project-id zone-id\n";
    return 1;
  }

  namespace disks = ::google::cloud::compute_disks_v1;
  auto client = disks::DisksClient(
      google::cloud::ExperimentalTag{},
      disks::MakeDisksConnectionRest(google::cloud::ExperimentalTag{}));

  for (auto disk : client.ListDisks(argv[1], argv[2])) {
    if (!disk) throw std::move(disk).status();
    std::cout << disk->DebugString() << "\n";
  }

  return 0;
} catch (google::cloud::Status const& status) {
  std::cerr << "google::cloud::Status thrown: " << status << "\n";
  return 1;
}

Main classes

This library offers multiple *Client classes, which are listed below. Each one of these classes exposes all the RPCs for a service as member functions of the class. This library groups multiple services because they are part of the same product or are often used together. A typical example may be the administrative and data plane operations for a single product.

The library also has other classes that provide helpers, configuration parameters, and infrastructure to mock the *Client classes when testing your application.

More Information