Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(spanner): add *Client samples #10145

Merged
merged 2 commits into from
Nov 1, 2022

Conversation

coryan
Copy link
Contributor

@coryan coryan commented Oct 31, 2022

Add examples showing how to override the default endpoint and default authentication.

Fixes #10141 and fixes #10142


This change is Reviewable

@product-auto-label product-auto-label bot added api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples. labels Oct 31, 2022
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: bded4fb97a97d665e36be04ae360763253623620

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@codecov
Copy link

codecov bot commented Oct 31, 2022

Codecov Report

Base: 93.98% // Head: 93.97% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (cc51bea) compared to base (a0d16ae).
Patch coverage: 70.21% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10145      +/-   ##
==========================================
- Coverage   93.98%   93.97%   -0.02%     
==========================================
  Files        1525     1526       +1     
  Lines      140517   140564      +47     
==========================================
+ Hits       132065   132092      +27     
- Misses       8452     8472      +20     
Impacted Files Coverage Δ
google/cloud/spanner/samples/client_samples.cc 70.21% <70.21%> (ø)
google/cloud/internal/async_connection_ready.cc 89.36% <0.00%> (-4.26%) ⬇️
...e/cloud/pubsublite/internal/alarm_registry_impl.cc 97.05% <0.00%> (-2.95%) ⬇️
...cloud/pubsub/internal/subscription_session_test.cc 97.98% <0.00%> (-0.84%) ⬇️
google/cloud/storage/parallel_upload.cc 98.28% <0.00%> (-0.35%) ⬇️
...le/cloud/storage/internal/curl_download_request.cc 89.63% <0.00%> (+0.33%) ⬆️
google/cloud/pubsub/subscriber_connection_test.cc 98.36% <0.00%> (+0.54%) ⬆️
...integration_tests/schema_admin_integration_test.cc 100.00% <0.00%> (+1.11%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@devbww devbww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ typo in description.

google/cloud/spanner/doc/spanner-main.dox Outdated Show resolved Hide resolved
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: a06a840fb56a616af625295774cc8b09352ab9e3

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@coryan coryan marked this pull request as ready for review October 31, 2022 19:10
@coryan coryan requested a review from a team as a code owner October 31, 2022 19:10
(argv.at(0), argv.at(1), argv.at(2), argv.at(3));
}

void DatabaseAdminClientSetEndpoint(std::vector<std::string> const& argv) {
Copy link
Member

@dbolduc dbolduc Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment about generated Admin APIs having generated samples:

void SetClientEndpoint(std::vector<std::string> const& argv) {
if (!argv.empty()) {
throw google::cloud::testing_util::Usage{"set-client-endpoint"};
}
//! [set-client-endpoint]
// This configuration is common with Private Google Access:
// https://cloud.google.com/vpc/docs/private-google-access
auto options = google::cloud::Options{}.set<google::cloud::EndpointOption>(
"private.googleapis.com");
auto client = google::cloud::spanner_admin::DatabaseAdminClient(
google::cloud::spanner_admin::MakeDatabaseAdminConnection(options));
//! [set-client-endpoint]
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected these InstanceAdminClient and DatabaseAdminClient samples to have disappeared then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, fixed now.

@coryan coryan force-pushed the doc-spanner-add-client-samples branch from a06a840 to 729ac10 Compare October 31, 2022 20:54
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: 729ac105afc7d47ddb8cf5d9dc9d55fd9efff1d8

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@coryan coryan force-pushed the doc-spanner-add-client-samples branch from 729ac10 to 7d1fb56 Compare November 1, 2022 12:47
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: 7d1fb566ba64cfec8b0e59f19940ff15f3aaf3a3

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

Comment on lines 30 to 35
void ClientSetEndpoint(std::vector<std::string> const& argv) {
if (argv.size() != 3) {
throw google::cloud::testing_util::Usage{
"client-set-endpoint <project-id> <instance-id> <database-id>"};
}
//! [client-set-endpoint]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to be an unreasonable stickler for consistency, you could rename this to SetClientEndpoint / [set-client-endpoint]...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah ... if we have set-client-endpoint and with-service-account tags in both of the admin samples, then why not the same here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

(argv.at(0), argv.at(1), argv.at(2));
}

void ClientWithServiceAccount(std::vector<std::string> const& argv) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this to WithServiceAccount / [with-service-account]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Add examples showing how to override the default endpoint and default
authentication.
@coryan coryan force-pushed the doc-spanner-add-client-samples branch from 7d1fb56 to cc51bea Compare November 1, 2022 14:21
@coryan coryan enabled auto-merge (squash) November 1, 2022 14:21
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: cc51bea8049fc4042867908f5bf26d85ba5c5b59

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@coryan coryan merged commit 4c9fc8d into googleapis:main Nov 1, 2022
@coryan coryan deleted the doc-spanner-add-client-samples branch November 1, 2022 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spanner default authentication credentials Spanner default endpoints
4 participants