Skip to content

Commit 2f96315

Browse files
authored
doc: update quickstarts to use google::cloud::Location (#12789)
1 parent 40b36e4 commit 2f96315

136 files changed

Lines changed: 712 additions & 562 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

google/cloud/advisorynotifications/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ this library.
1818

1919
```cc
2020
#include "google/cloud/advisorynotifications/v1/advisory_notifications_client.h"
21-
#include "google/cloud/project.h"
2221
#include <iostream>
2322
#include <string>
2423

google/cloud/advisorynotifications/quickstart/quickstart.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
//! [all]
1616
#include "google/cloud/advisorynotifications/v1/advisory_notifications_client.h"
17-
#include "google/cloud/project.h"
1817
#include <iostream>
1918
#include <string>
2019

google/cloud/aiplatform/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ this library.
1818

1919
```cc
2020
#include "google/cloud/aiplatform/v1/endpoint_client.h"
21+
#include "google/cloud/location.h"
2122
#include <iostream>
2223

2324
int main(int argc, char* argv[]) try {
@@ -26,16 +27,15 @@ int main(int argc, char* argv[]) try {
2627
return 1;
2728
}
2829

30+
auto const location = google::cloud::Location(argv[1], argv[2]);
31+
2932
namespace aiplatform = ::google::cloud::aiplatform_v1;
30-
auto const location = std::string{argv[2]};
3133
auto client = aiplatform::EndpointServiceClient(
32-
aiplatform::MakeEndpointServiceConnection(location));
34+
aiplatform::MakeEndpointServiceConnection(location.location_id()));
3335

34-
auto const parent =
35-
std::string{"projects/"} + argv[1] + "/locations/" + location;
36-
for (auto r : client.ListEndpoints(parent)) {
37-
if (!r) throw std::move(r).status();
38-
std::cout << r->DebugString() << "\n";
36+
for (auto ep : client.ListEndpoints(location.FullName())) {
37+
if (!ep) throw std::move(ep).status();
38+
std::cout << ep->DebugString() << "\n";
3939
}
4040

4141
return 0;

google/cloud/aiplatform/quickstart/quickstart.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
//! [all]
1616
#include "google/cloud/aiplatform/v1/endpoint_client.h"
17+
#include "google/cloud/location.h"
1718
#include <iostream>
1819

1920
int main(int argc, char* argv[]) try {
@@ -22,16 +23,15 @@ int main(int argc, char* argv[]) try {
2223
return 1;
2324
}
2425

26+
auto const location = google::cloud::Location(argv[1], argv[2]);
27+
2528
namespace aiplatform = ::google::cloud::aiplatform_v1;
26-
auto const location = std::string{argv[2]};
2729
auto client = aiplatform::EndpointServiceClient(
28-
aiplatform::MakeEndpointServiceConnection(location));
30+
aiplatform::MakeEndpointServiceConnection(location.location_id()));
2931

30-
auto const parent =
31-
std::string{"projects/"} + argv[1] + "/locations/" + location;
32-
for (auto r : client.ListEndpoints(parent)) {
33-
if (!r) throw std::move(r).status();
34-
std::cout << r->DebugString() << "\n";
32+
for (auto ep : client.ListEndpoints(location.FullName())) {
33+
if (!ep) throw std::move(ep).status();
34+
std::cout << ep->DebugString() << "\n";
3535
}
3636

3737
return 0;

google/cloud/alloydb/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ this library.
2828

2929
```cc
3030
#include "google/cloud/alloydb/v1/alloy_db_admin_client.h"
31+
#include "google/cloud/location.h"
3132
#include <iostream>
3233

3334
int main(int argc, char* argv[]) try {
@@ -36,14 +37,15 @@ int main(int argc, char* argv[]) try {
3637
return 1;
3738
}
3839

40+
auto const location = google::cloud::Location(argv[1], "-");
41+
3942
namespace alloydb = ::google::cloud::alloydb_v1;
4043
auto client =
4144
alloydb::AlloyDBAdminClient(alloydb::MakeAlloyDBAdminConnection());
4245

43-
auto const parent = std::string{"projects/"} + argv[1] + "/locations/-";
44-
for (auto r : client.ListClusters(parent)) {
45-
if (!r) throw std::move(r).status();
46-
std::cout << r->DebugString() << "\n";
46+
for (auto c : client.ListClusters(location.FullName())) {
47+
if (!c) throw std::move(c).status();
48+
std::cout << c->DebugString() << "\n";
4749
}
4850

4951
return 0;

google/cloud/alloydb/quickstart/quickstart.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
//! [all]
1616
#include "google/cloud/alloydb/v1/alloy_db_admin_client.h"
17+
#include "google/cloud/location.h"
1718
#include <iostream>
1819

1920
int main(int argc, char* argv[]) try {
@@ -22,14 +23,15 @@ int main(int argc, char* argv[]) try {
2223
return 1;
2324
}
2425

26+
auto const location = google::cloud::Location(argv[1], "-");
27+
2528
namespace alloydb = ::google::cloud::alloydb_v1;
2629
auto client =
2730
alloydb::AlloyDBAdminClient(alloydb::MakeAlloyDBAdminConnection());
2831

29-
auto const parent = std::string{"projects/"} + argv[1] + "/locations/-";
30-
for (auto r : client.ListClusters(parent)) {
31-
if (!r) throw std::move(r).status();
32-
std::cout << r->DebugString() << "\n";
32+
for (auto c : client.ListClusters(location.FullName())) {
33+
if (!c) throw std::move(c).status();
34+
std::cout << c->DebugString() << "\n";
3335
}
3436

3537
return 0;

google/cloud/apigateway/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ top-level [README](/README.md#building-and-installing).
2121

2222
```cc
2323
#include "google/cloud/apigateway/v1/api_gateway_client.h"
24+
#include "google/cloud/location.h"
2425
#include <iostream>
2526

2627
int main(int argc, char* argv[]) try {
@@ -29,15 +30,15 @@ int main(int argc, char* argv[]) try {
2930
return 1;
3031
}
3132

33+
auto const location = google::cloud::Location(argv[1], argv[2]);
34+
3235
namespace apigateway = ::google::cloud::apigateway_v1;
3336
auto client = apigateway::ApiGatewayServiceClient(
3437
apigateway::MakeApiGatewayServiceConnection());
3538

36-
auto const parent =
37-
std::string("projects/") + argv[1] + "/locations/" + argv[2];
38-
for (auto r : client.ListGateways(parent)) {
39-
if (!r) throw std::move(r).status();
40-
std::cout << r->DebugString() << "\n";
39+
for (auto g : client.ListGateways(location.FullName())) {
40+
if (!g) throw std::move(g).status();
41+
std::cout << g->DebugString() << "\n";
4142
}
4243

4344
return 0;

google/cloud/apigateway/quickstart/quickstart.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
//! [all]
1616
#include "google/cloud/apigateway/v1/api_gateway_client.h"
17+
#include "google/cloud/location.h"
1718
#include <iostream>
1819

1920
int main(int argc, char* argv[]) try {
@@ -22,15 +23,15 @@ int main(int argc, char* argv[]) try {
2223
return 1;
2324
}
2425

26+
auto const location = google::cloud::Location(argv[1], argv[2]);
27+
2528
namespace apigateway = ::google::cloud::apigateway_v1;
2629
auto client = apigateway::ApiGatewayServiceClient(
2730
apigateway::MakeApiGatewayServiceConnection());
2831

29-
auto const parent =
30-
std::string("projects/") + argv[1] + "/locations/" + argv[2];
31-
for (auto r : client.ListGateways(parent)) {
32-
if (!r) throw std::move(r).status();
33-
std::cout << r->DebugString() << "\n";
32+
for (auto g : client.ListGateways(location.FullName())) {
33+
if (!g) throw std::move(g).status();
34+
std::cout << g->DebugString() << "\n";
3435
}
3536

3637
return 0;

google/cloud/apikeys/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ top-level [README](/README.md#building-and-installing).
2121

2222
```cc
2323
#include "google/cloud/apikeys/v2/api_keys_client.h"
24+
#include "google/cloud/location.h"
2425
#include <iostream>
2526

2627
int main(int argc, char* argv[]) try {
@@ -29,13 +30,14 @@ int main(int argc, char* argv[]) try {
2930
return 1;
3031
}
3132

33+
auto const location = google::cloud::Location(argv[1], "global");
34+
3235
namespace apikeys = ::google::cloud::apikeys_v2;
3336
auto client = apikeys::ApiKeysClient(apikeys::MakeApiKeysConnection());
3437

35-
auto const parent = std::string{"projects/"} + argv[1] + "/locations/global";
36-
for (auto r : client.ListKeys(parent)) {
37-
if (!r) throw std::move(r).status();
38-
std::cout << r->DebugString() << "\n";
38+
for (auto k : client.ListKeys(location.FullName())) {
39+
if (!k) throw std::move(k).status();
40+
std::cout << k->DebugString() << "\n";
3941
}
4042

4143
return 0;

google/cloud/apikeys/quickstart/quickstart.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
//! [all]
1616
#include "google/cloud/apikeys/v2/api_keys_client.h"
17+
#include "google/cloud/location.h"
1718
#include <iostream>
1819

1920
int main(int argc, char* argv[]) try {
@@ -22,13 +23,14 @@ int main(int argc, char* argv[]) try {
2223
return 1;
2324
}
2425

26+
auto const location = google::cloud::Location(argv[1], "global");
27+
2528
namespace apikeys = ::google::cloud::apikeys_v2;
2629
auto client = apikeys::ApiKeysClient(apikeys::MakeApiKeysConnection());
2730

28-
auto const parent = std::string{"projects/"} + argv[1] + "/locations/global";
29-
for (auto r : client.ListKeys(parent)) {
30-
if (!r) throw std::move(r).status();
31-
std::cout << r->DebugString() << "\n";
31+
for (auto k : client.ListKeys(location.FullName())) {
32+
if (!k) throw std::move(k).status();
33+
std::cout << k->DebugString() << "\n";
3234
}
3335

3436
return 0;

0 commit comments

Comments
 (0)