|
1 | 1 | # Google Cloud IAM C++ Client Library
|
2 | 2 |
|
3 |
| -:construction: |
| 3 | +<!-- This file is automatically generated by ci/generate-markdown/generate-iam-readme.sh --> |
4 | 4 |
|
5 | 5 | This directory contains an idiomatic C++ client library for interacting with
|
6 |
| -[Cloud Identity and Access Management (IAM)](https://cloud.google.com/iam/), |
7 |
| -a service for fine-grained access control and visibility for centrally |
8 |
| -managing cloud resources. |
| 6 | +[Cloud IAM](https://cloud.google.com/iam/). |
| 7 | + |
| 8 | +Please note that the Google Cloud C++ client libraries do **not** follow |
| 9 | +[Semantic Versioning](https://semver.org/). |
| 10 | + |
| 11 | +## Supported Platforms |
| 12 | + |
| 13 | +* Windows, macOS, Linux |
| 14 | +* C++11 (and higher) compilers (we test with GCC \>= 5.4, Clang >= 3.8, and MSVC \>= 2019) |
| 15 | +* Environments with or without exceptions |
| 16 | +* Bazel and CMake builds |
| 17 | + |
| 18 | +## Documentation |
| 19 | + |
| 20 | +* Official documentation about the [Cloud IAM][cloud-iam-docs] service |
| 21 | +* [Reference doxygen documentation][doxygen-link] for each release of this client library |
| 22 | +* Detailed header comments in our [public `.h`][source-link] files |
| 23 | + |
| 24 | +[doxygen-link]: https://googleapis.dev/cpp/google-cloud-iam/latest/ |
| 25 | +[cloud-iam-docs]: https://cloud.google.com/iam/docs/ |
| 26 | +[source-link]: https://github.com/googleapis/google-cloud-cpp/tree/main/google/cloud/iam |
| 27 | + |
| 28 | +## Quickstart |
| 29 | + |
| 30 | +The [quickstart/](quickstart/README.md) directory contains a minimal environment |
| 31 | +to get started using this client library in a larger project. The following |
| 32 | +"Hello World" program is used in this quickstart, and should give you a taste of |
| 33 | +this library. |
| 34 | + |
| 35 | +```cc |
| 36 | +#include "google/cloud/iam/iam_client.h" |
| 37 | +#include <iostream> |
| 38 | +#include <stdexcept> |
| 39 | + |
| 40 | +int main(int argc, char* argv[]) try { |
| 41 | + if (argc != 2) { |
| 42 | + std::cerr << "Usage: " << argv[0] << " <project-id>\n"; |
| 43 | + return 1; |
| 44 | + } |
| 45 | + |
| 46 | + std::string const project_id = argv[1]; |
| 47 | + |
| 48 | + // Create a namespace alias to make the code easier to read. |
| 49 | + namespace iam = google::cloud::iam; |
| 50 | + iam::IAMClient client(iam::MakeIAMConnection()); |
| 51 | + std::cout << "Service Accounts for project: " << project_id << "\n"; |
| 52 | + int count = 0; |
| 53 | + for (auto const& service_account : |
| 54 | + client.ListServiceAccounts("projects/" + project_id)) { |
| 55 | + if (!service_account) { |
| 56 | + throw std::runtime_error(service_account.status().message()); |
| 57 | + } |
| 58 | + std::cout << service_account->name() << "\n"; |
| 59 | + ++count; |
| 60 | + } |
| 61 | + |
| 62 | + if (count == 0) std::cout << "No Service Accounts found.\n"; |
| 63 | + return 0; |
| 64 | +} catch (std::exception const& ex) { |
| 65 | + std::cerr << "Standard exception raised: " << ex.what() << "\n"; |
| 66 | + return 1; |
| 67 | +} |
| 68 | +``` |
| 69 | +
|
| 70 | +* Packaging maintainers or developers that prefer to install the library in a |
| 71 | + fixed directory (such as `/usr/local` or `/opt`) should consult the |
| 72 | + [packaging guide](/doc/packaging.md). |
| 73 | +* Developers wanting to use the libraries as part of a larger CMake or Bazel |
| 74 | + project should consult the [quickstart guides](#quickstart) for the library |
| 75 | + or libraries they want to use. |
| 76 | +* Developers wanting to compile the library just to run some of the examples or |
| 77 | + tests should read the current document. |
| 78 | +* Contributors and developers to `google-cloud-cpp` should consult the guide to |
| 79 | + [setup a development workstation][howto-setup-dev-workstation]. |
| 80 | +
|
| 81 | +[howto-setup-dev-workstation]: /doc/contributor/howto-guide-setup-development-workstation.md |
| 82 | +
|
| 83 | +## Installation |
| 84 | +
|
| 85 | +Please consult the [packaging guide](../../../doc/packaging.md) for detailed |
| 86 | +instructions to install the Google Cloud C++ client libraries. |
| 87 | +If your project uses [CMake](https://cmake.org) or [Bazel](https://bazel.build) |
| 88 | +check the [quickstart](quickstart/README.md) example for instructions to use |
| 89 | +this library in your project. |
| 90 | +
|
| 91 | +## Contributing changes |
| 92 | +
|
| 93 | +See [`CONTRIBUTING.md`](../../../CONTRIBUTING.md) for details on how to |
| 94 | +contribute to this project, including how to build and test your changes |
| 95 | +as well as how to properly format your code. |
| 96 | +
|
| 97 | +## Licensing |
| 98 | +
|
| 99 | +Apache 2.0; see [`LICENSE`](../../../LICENSE) for details. |
9 | 100 |
|
10 |
| -This library is **experimental**. Its APIS are subject to change without notice. |
|
0 commit comments