Skip to content

Commit e68c72e

Browse files
authored
feat(oauth2): add quickstart, README, etc. (#12754)
This will make the library more usable (I think) by including a quickstart, README, landing page for Doxygen, etc.
1 parent 8ecdff6 commit e68c72e

20 files changed

Lines changed: 459 additions & 23 deletions

BUILD.bazel

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ TRANSITION_LIBRARIES = GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES
3030

3131
GA_LIBRARIES = GOOGLE_CLOUD_CPP_GA_LIBRARIES
3232

33+
NO_MOCK_LIBRARIES = ["oauth2"]
34+
3335
[cc_library(
3436
name = "experimental-{library}".format(library = library),
3537
deps = [
@@ -49,7 +51,7 @@ GA_LIBRARIES = GOOGLE_CLOUD_CPP_GA_LIBRARIES
4951
library_dir = google_cloud_cpp_library_dir_name(library),
5052
),
5153
],
52-
) for library in EXPERIMENTAL_LIBRARIES]
54+
) for library in EXPERIMENTAL_LIBRARIES if library not in NO_MOCK_LIBRARIES]
5355

5456
[cc_library(
5557
name = "experimental-{library}".format(library = library),
@@ -95,7 +97,7 @@ GA_LIBRARIES = GOOGLE_CLOUD_CPP_GA_LIBRARIES
9597
library_dir = google_cloud_cpp_library_dir_name(library),
9698
),
9799
],
98-
) for library in GA_LIBRARIES + TRANSITION_LIBRARIES]
100+
) for library in GA_LIBRARIES + TRANSITION_LIBRARIES if library not in NO_MOCK_LIBRARIES]
99101

100102
cc_library(
101103
name = "bigquery-mocks",
@@ -162,14 +164,6 @@ cc_library(
162164
],
163165
)
164166

165-
cc_library(
166-
name = "oauth2",
167-
testonly = True,
168-
deps = [
169-
"//google/cloud/oauth2:google_cloud_cpp_oauth2",
170-
],
171-
)
172-
173167
cc_library(
174168
name = "experimental-opentelemetry",
175169
deprecation = "this library is now GA, please use //:opentelemetry instead.",

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ if (GOOGLE_CLOUD_CPP_USE_INSTALLED_COMMON)
259259
endif ()
260260
if (GOOGLE_CLOUD_CPP_ENABLE_REST)
261261
find_package(google_cloud_cpp_rest_internal CONFIG REQUIRED)
262-
find_package(google_cloud_cpp_oauth2 CONFIG REQUIRED)
263262
endif ()
264263
if (GOOGLE_CLOUD_CPP_ENABLE_REST AND GOOGLE_CLOUD_CPP_ENABLE_GRPC)
265264
find_package(google_cloud_cpp_rest_protobuf_internal CONFIG REQUIRED)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ See each library's `README.md` file for more information about:
301301
- [Notebooks API](google/cloud/notebooks/README.md)
302302
[\[quickstart\]](google/cloud/notebooks/quickstart/README.md)
303303
[\[reference\]](https://cloud.google.com/cpp/docs/reference/notebooks/latest)
304+
- [OAuth2 Access Token Generation](google/cloud/oauth2/README.md)
305+
[\[quickstart\]](google/cloud/oauth2/quickstart/README.md)
306+
[\[reference\]](https://cloud.google.com/cpp/docs/reference/oauth2/latest)
304307
- [Cloud Optimization API](google/cloud/optimization/README.md)
305308
[\[quickstart\]](google/cloud/optimization/quickstart/README.md)
306309
[\[reference\]](https://cloud.google.com/cpp/docs/reference/optimization/latest)

ci/cloudbuild/builds/check-api.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ else
3434
readonly ENABLED_FEATURES="__ga_libraries__,opentelemetry"
3535
mapfile -t library_list < <(cmake -DCMAKE_MODULE_PATH="${PWD}/cmake" -P cmake/print-ga-libraries.cmake 2>&1)
3636
# These libraries are not "features", but they are part of the public API
37-
library_list+=("common" "grpc_utils" "oauth2")
37+
library_list+=("common" "grpc_utils")
3838
# This is a GA library, not included in __ga_libraries__
3939
library_list+=("opentelemetry")
4040
fi

ci/cloudbuild/builds/checkers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ time {
203203
done
204204

205205
mapfile -t libraries < <(features::libraries)
206-
for library in "${libraries[@]}" opentelemetry; do
206+
for library in "${libraries[@]}" opentelemetry oauth2; do
207207
ci/generate-markdown/update-library-readme.sh "${library}"
208208
done
209209
}

ci/cloudbuild/builds/cmake-install.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ expected_dirs+=(
9696
# no RPC services in google/cloud/metastore/logging
9797
./include/google/cloud/metastore/logging
9898
./include/google/cloud/metastore/logging/v1
99-
# mocks and opentelemetry/* are hand-crafted directories
99+
# mocks, oauth2, and opentelemetry/* are hand-crafted directories
100100
./include/google/cloud/mocks
101+
./include/google/cloud/oauth2
101102
./include/google/cloud/opentelemetry
102103
./include/google/cloud/opentelemetry/internal
103104
# orgpolicy/v1 is not automatically added. It is used by
@@ -200,8 +201,8 @@ env -C "${out_dir}" ctest "${ctest_args[@]}"
200201
# Tests the installed artifacts by building and running the quickstarts.
201202
# shellcheck disable=SC2046
202203
feature_list="$(printf "%s;" $(features::libraries))"
203-
# GCS+gRPC and OpenTelemetry also have quickstarts.
204-
feature_list="${feature_list}experimental-storage_grpc;opentelemetry"
204+
# GCS+gRPC, OAuth2, and OpenTelemetry also have quickstarts.
205+
feature_list="${feature_list}experimental-storage_grpc;oauth2;opentelemetry"
205206
cmake -G Ninja \
206207
-S "${PROJECT_ROOT}/ci/verify_quickstart" \
207208
-B "${PROJECT_ROOT}/cmake-out/quickstart" \

ci/cloudbuild/builds/lib/features.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,28 @@ function features::libraries() {
5959
printf "%s\n" "${feature_list[@]}" | sort -u
6060
}
6161

62+
function features::_internal_extra() {
63+
local list=(
64+
experimental-bigquery_rest
65+
experimental-storage_grpc
66+
oauth2
67+
opentelemetry
68+
)
69+
printf "%s\n" "${list[@]}"
70+
}
71+
6272
function features::list_full() {
6373
local feature_list
6474
mapfile -t feature_list < <(features::libraries)
65-
feature_list+=(opentelemetry experimental-storage_grpc grafeas)
66-
printf "%s\n" "${feature_list[@]}" | sort -u
75+
local extra_list
76+
mapfile -t extra_list < <(features::_internal_extra)
77+
printf "%s\n" "${feature_list[@]}" "${extra_list[@]}" | sort -u
6778
}
6879

6980
function features::list_full_cmake() {
70-
echo "__ga_libraries__,__experimental_libraries__,experimental-storage_grpc,opentelemetry,experimental-bigquery_rest"
81+
local feature_list
82+
mapfile -t feature_list < <(features::list_full)
83+
local concat
84+
concat="$(printf ",%s" "${feature_list[@]}" "${extra_list[@]}")"
85+
echo "${concat:1}"
7186
}

ci/generate-markdown/generate-readme.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ file="README.md"
3737
mapfile -t features < <(cmake -DCMAKE_MODULE_PATH="${PWD}/cmake" -P cmake/print-ga-features.cmake 2>&1 | LC_ALL=C sort)
3838
sed '/<!-- inject-GA-features-start -->/q' "${file}"
3939
for feature in "${features[@]}"; do
40-
description="$(sed -n '1 s/# \(.*\) C++ Client Library/\1/p' "google/cloud/${feature}/README.md")"
40+
if [[ "${feature}" == "oauth2" ]]; then
41+
description="OAuth2 Access Token Generation"
42+
else
43+
description="$(sed -n '1 s/# \(.*\) C++ Client Library/\1/p' "google/cloud/${feature}/README.md")"
44+
fi
4145
printf -- '- [%s](google/cloud/%s/README.md)\n' "${description}" "${feature}"
4246
printf -- ' [[quickstart]](google/cloud/%s/quickstart/README.md)\n' "${feature}"
4347
printf -- ' [[reference]](https://cloud.google.com/cpp/docs/reference/%s/latest)\n' "${feature}"

cmake/GoogleCloudCppFeatures.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ set(GOOGLE_CLOUD_CPP_LEGACY_FEATURES
2727
# Protobuf messages. We do not bother to have an internal library that depends
2828
# on Protobuf but not gRPC. So these libraries must depend on
2929
# `google_cloud_cpp_grpc_utils`.
30-
set(GOOGLE_CLOUD_CPP_REST_ONLY_FEATURES "storage;experimental-bigquery_rest")
30+
set(GOOGLE_CLOUD_CPP_REST_ONLY_FEATURES
31+
"oauth2;storage;experimental-bigquery_rest")
3132

3233
set(GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES # cmake-format: sorted
3334
# This is WIP, it needs a number of hand-crafted APIs.
@@ -110,6 +111,7 @@ set(GOOGLE_CLOUD_CPP_GA_LIBRARIES
110111
"networksecurity"
111112
"networkservices"
112113
"notebooks"
114+
"oauth2"
113115
"optimization"
114116
"orgpolicy"
115117
"osconfig"
@@ -365,11 +367,17 @@ macro (google_cloud_cpp_enable_cleanup)
365367
OR (compute IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
366368
OR (compute_features)
367369
OR (experimental-bigquery_rest IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
370+
OR (oauth2 IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
368371
OR (opentelemetry IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
369372
OR (sql IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
370373
OR (generator IN_LIST GOOGLE_CLOUD_CPP_ENABLE))
371374
set(GOOGLE_CLOUD_CPP_ENABLE_REST ON)
375+
# Backwards compatibility. In the original release of `oauth2` we
376+
# automatically compiled the library if REST was enabled
377+
list(APPEND GOOGLE_CLOUD_CPP_ENABLE oauth2)
372378
endif ()
379+
380+
list(REMOVE_DUPLICATES GOOGLE_CLOUD_CPP_ENABLE)
373381
endmacro ()
374382

375383
# Configure CMake to build the features listed in `GOOGLE_CLOUD_CPP_ENABLE`.

google/cloud/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ endif ()
6060

6161
if (GOOGLE_CLOUD_CPP_ENABLE_REST)
6262
include("${CMAKE_CURRENT_SOURCE_DIR}/google_cloud_cpp_rest_internal.cmake")
63-
add_subdirectory(oauth2)
6463
endif ()
6564

6665
if (GOOGLE_CLOUD_CPP_ENABLE_REST AND GOOGLE_CLOUD_CPP_ENABLE_GRPC)

0 commit comments

Comments
 (0)