Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.

Commit 580a959

Browse files
feat: add from_service_account_info (#52)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/fb22f59c-8962-43c6-89b6-9796466cdaca/targets - [x] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 359562873 Source-Link: googleapis/googleapis@07932bb PiperOrigin-RevId: 355923884 Source-Link: googleapis/googleapis@5e3dace PiperOrigin-RevId: 354996675 Source-Link: googleapis/googleapis@20712b8 PiperOrigin-RevId: 352816749 Source-Link: googleapis/googleapis@ceaaf31 PiperOrigin-RevId: 350388717 Source-Link: googleapis/googleapis@dd1d232 PiperOrigin-RevId: 350246057 Source-Link: googleapis/googleapis@5206824
1 parent 673fa1c commit 580a959

File tree

13 files changed

+954
-510
lines changed

13 files changed

+954
-510
lines changed

docs/cloudbuild_v1/cloud_build.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CloudBuild
2+
----------------------------
3+
4+
.. automodule:: google.cloud.devtools.cloudbuild_v1.services.cloud_build
5+
:members:
6+
:inherited-members:
7+
8+
9+
.. automodule:: google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers
10+
:members:
11+
:inherited-members:

docs/cloudbuild_v1/services.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Services for Google Devtools Cloudbuild v1 API
22
==============================================
3+
.. toctree::
4+
:maxdepth: 2
35

4-
.. automodule:: google.cloud.devtools.cloudbuild_v1.services.cloud_build
5-
:members:
6-
:inherited-members:
6+
cloud_build

docs/cloudbuild_v1/types.rst

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Types for Google Devtools Cloudbuild v1 API
33

44
.. automodule:: google.cloud.devtools.cloudbuild_v1.types
55
:members:
6+
:undoc-members:
67
:show-inheritance:

google/cloud/devtools/cloudbuild_v1/proto/cloudbuild.proto

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import "google/protobuf/empty.proto";
2626
import "google/protobuf/field_mask.proto";
2727
import "google/protobuf/timestamp.proto";
2828

29+
option csharp_namespace = "Google.Cloud.CloudBuild.V1";
2930
option go_package = "google.golang.org/genproto/googleapis/devtools/cloudbuild/v1;cloudbuild";
3031
option java_multiple_files = true;
3132
option java_package = "com.google.cloudbuild.v1";

google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py

+184-146
Large diffs are not rendered by default.

google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py

+199-178
Large diffs are not rendered by default.

google/cloud/devtools/cloudbuild_v1/services/cloud_build/pagers.py

+26-17
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@
1515
# limitations under the License.
1616
#
1717

18-
from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
18+
from typing import (
19+
Any,
20+
AsyncIterable,
21+
Awaitable,
22+
Callable,
23+
Iterable,
24+
Sequence,
25+
Tuple,
26+
Optional,
27+
)
1928

2029
from google.cloud.devtools.cloudbuild_v1.types import cloudbuild
2130

@@ -24,7 +33,7 @@ class ListBuildsPager:
2433
"""A pager for iterating through ``list_builds`` requests.
2534
2635
This class thinly wraps an initial
27-
:class:`~.cloudbuild.ListBuildsResponse` object, and
36+
:class:`google.cloud.devtools.cloudbuild_v1.types.ListBuildsResponse` object, and
2837
provides an ``__iter__`` method to iterate through its
2938
``builds`` field.
3039
@@ -33,7 +42,7 @@ class ListBuildsPager:
3342
through the ``builds`` field on the
3443
corresponding responses.
3544
36-
All the usual :class:`~.cloudbuild.ListBuildsResponse`
45+
All the usual :class:`google.cloud.devtools.cloudbuild_v1.types.ListBuildsResponse`
3746
attributes are available on the pager. If multiple requests are made, only
3847
the most recent response is retained, and thus used for attribute lookup.
3948
"""
@@ -51,9 +60,9 @@ def __init__(
5160
Args:
5261
method (Callable): The method that was originally called, and
5362
which instantiated this pager.
54-
request (:class:`~.cloudbuild.ListBuildsRequest`):
63+
request (google.cloud.devtools.cloudbuild_v1.types.ListBuildsRequest):
5564
The initial request object.
56-
response (:class:`~.cloudbuild.ListBuildsResponse`):
65+
response (google.cloud.devtools.cloudbuild_v1.types.ListBuildsResponse):
5766
The initial response object.
5867
metadata (Sequence[Tuple[str, str]]): Strings which should be
5968
sent along with the request as metadata.
@@ -86,7 +95,7 @@ class ListBuildsAsyncPager:
8695
"""A pager for iterating through ``list_builds`` requests.
8796
8897
This class thinly wraps an initial
89-
:class:`~.cloudbuild.ListBuildsResponse` object, and
98+
:class:`google.cloud.devtools.cloudbuild_v1.types.ListBuildsResponse` object, and
9099
provides an ``__aiter__`` method to iterate through its
91100
``builds`` field.
92101
@@ -95,7 +104,7 @@ class ListBuildsAsyncPager:
95104
through the ``builds`` field on the
96105
corresponding responses.
97106
98-
All the usual :class:`~.cloudbuild.ListBuildsResponse`
107+
All the usual :class:`google.cloud.devtools.cloudbuild_v1.types.ListBuildsResponse`
99108
attributes are available on the pager. If multiple requests are made, only
100109
the most recent response is retained, and thus used for attribute lookup.
101110
"""
@@ -113,9 +122,9 @@ def __init__(
113122
Args:
114123
method (Callable): The method that was originally called, and
115124
which instantiated this pager.
116-
request (:class:`~.cloudbuild.ListBuildsRequest`):
125+
request (google.cloud.devtools.cloudbuild_v1.types.ListBuildsRequest):
117126
The initial request object.
118-
response (:class:`~.cloudbuild.ListBuildsResponse`):
127+
response (google.cloud.devtools.cloudbuild_v1.types.ListBuildsResponse):
119128
The initial response object.
120129
metadata (Sequence[Tuple[str, str]]): Strings which should be
121130
sent along with the request as metadata.
@@ -152,7 +161,7 @@ class ListBuildTriggersPager:
152161
"""A pager for iterating through ``list_build_triggers`` requests.
153162
154163
This class thinly wraps an initial
155-
:class:`~.cloudbuild.ListBuildTriggersResponse` object, and
164+
:class:`google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersResponse` object, and
156165
provides an ``__iter__`` method to iterate through its
157166
``triggers`` field.
158167
@@ -161,7 +170,7 @@ class ListBuildTriggersPager:
161170
through the ``triggers`` field on the
162171
corresponding responses.
163172
164-
All the usual :class:`~.cloudbuild.ListBuildTriggersResponse`
173+
All the usual :class:`google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersResponse`
165174
attributes are available on the pager. If multiple requests are made, only
166175
the most recent response is retained, and thus used for attribute lookup.
167176
"""
@@ -179,9 +188,9 @@ def __init__(
179188
Args:
180189
method (Callable): The method that was originally called, and
181190
which instantiated this pager.
182-
request (:class:`~.cloudbuild.ListBuildTriggersRequest`):
191+
request (google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersRequest):
183192
The initial request object.
184-
response (:class:`~.cloudbuild.ListBuildTriggersResponse`):
193+
response (google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersResponse):
185194
The initial response object.
186195
metadata (Sequence[Tuple[str, str]]): Strings which should be
187196
sent along with the request as metadata.
@@ -214,7 +223,7 @@ class ListBuildTriggersAsyncPager:
214223
"""A pager for iterating through ``list_build_triggers`` requests.
215224
216225
This class thinly wraps an initial
217-
:class:`~.cloudbuild.ListBuildTriggersResponse` object, and
226+
:class:`google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersResponse` object, and
218227
provides an ``__aiter__`` method to iterate through its
219228
``triggers`` field.
220229
@@ -223,7 +232,7 @@ class ListBuildTriggersAsyncPager:
223232
through the ``triggers`` field on the
224233
corresponding responses.
225234
226-
All the usual :class:`~.cloudbuild.ListBuildTriggersResponse`
235+
All the usual :class:`google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersResponse`
227236
attributes are available on the pager. If multiple requests are made, only
228237
the most recent response is retained, and thus used for attribute lookup.
229238
"""
@@ -241,9 +250,9 @@ def __init__(
241250
Args:
242251
method (Callable): The method that was originally called, and
243252
which instantiated this pager.
244-
request (:class:`~.cloudbuild.ListBuildTriggersRequest`):
253+
request (google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersRequest):
245254
The initial request object.
246-
response (:class:`~.cloudbuild.ListBuildTriggersResponse`):
255+
response (google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersResponse):
247256
The initial response object.
248257
metadata (Sequence[Tuple[str, str]]): Strings which should be
249258
sent along with the request as metadata.

google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def __init__(
6767
api_mtls_endpoint: str = None,
6868
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
6969
ssl_channel_credentials: grpc.ChannelCredentials = None,
70+
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
7071
quota_project_id: Optional[str] = None,
7172
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
7273
) -> None:
@@ -97,6 +98,10 @@ def __init__(
9798
``api_mtls_endpoint`` is None.
9899
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
99100
for grpc channel. It is ignored if ``channel`` is provided.
101+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
102+
A callback to provide client certificate bytes and private key bytes,
103+
both in PEM format. It is used to configure mutual TLS channel. It is
104+
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
100105
quota_project_id (Optional[str]): An optional project to use for billing
101106
and quota.
102107
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -113,6 +118,11 @@ def __init__(
113118
"""
114119
self._ssl_channel_credentials = ssl_channel_credentials
115120

121+
if api_mtls_endpoint:
122+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
123+
if client_cert_source:
124+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
125+
116126
if channel:
117127
# Sanity check: Ensure that channel and credentials are not both
118128
# provided.
@@ -122,11 +132,6 @@ def __init__(
122132
self._grpc_channel = channel
123133
self._ssl_channel_credentials = None
124134
elif api_mtls_endpoint:
125-
warnings.warn(
126-
"api_mtls_endpoint and client_cert_source are deprecated",
127-
DeprecationWarning,
128-
)
129-
130135
host = (
131136
api_mtls_endpoint
132137
if ":" in api_mtls_endpoint
@@ -170,12 +175,18 @@ def __init__(
170175
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
171176
)
172177

178+
if client_cert_source_for_mtls and not ssl_channel_credentials:
179+
cert, key = client_cert_source_for_mtls()
180+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
181+
certificate_chain=cert, private_key=key
182+
)
183+
173184
# create a new channel. The provided one is ignored.
174185
self._grpc_channel = type(self).create_channel(
175186
host,
176187
credentials=credentials,
177188
credentials_file=credentials_file,
178-
ssl_credentials=ssl_channel_credentials,
189+
ssl_credentials=self._ssl_channel_credentials,
179190
scopes=scopes or self.AUTH_SCOPES,
180191
quota_project_id=quota_project_id,
181192
options=[

google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc_asyncio.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(
111111
api_mtls_endpoint: str = None,
112112
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
113113
ssl_channel_credentials: grpc.ChannelCredentials = None,
114+
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
114115
quota_project_id=None,
115116
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
116117
) -> None:
@@ -142,6 +143,10 @@ def __init__(
142143
``api_mtls_endpoint`` is None.
143144
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
144145
for grpc channel. It is ignored if ``channel`` is provided.
146+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
147+
A callback to provide client certificate bytes and private key bytes,
148+
both in PEM format. It is used to configure mutual TLS channel. It is
149+
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
145150
quota_project_id (Optional[str]): An optional project to use for billing
146151
and quota.
147152
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -158,6 +163,11 @@ def __init__(
158163
"""
159164
self._ssl_channel_credentials = ssl_channel_credentials
160165

166+
if api_mtls_endpoint:
167+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
168+
if client_cert_source:
169+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
170+
161171
if channel:
162172
# Sanity check: Ensure that channel and credentials are not both
163173
# provided.
@@ -167,11 +177,6 @@ def __init__(
167177
self._grpc_channel = channel
168178
self._ssl_channel_credentials = None
169179
elif api_mtls_endpoint:
170-
warnings.warn(
171-
"api_mtls_endpoint and client_cert_source are deprecated",
172-
DeprecationWarning,
173-
)
174-
175180
host = (
176181
api_mtls_endpoint
177182
if ":" in api_mtls_endpoint
@@ -215,12 +220,18 @@ def __init__(
215220
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
216221
)
217222

223+
if client_cert_source_for_mtls and not ssl_channel_credentials:
224+
cert, key = client_cert_source_for_mtls()
225+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
226+
certificate_chain=cert, private_key=key
227+
)
228+
218229
# create a new channel. The provided one is ignored.
219230
self._grpc_channel = type(self).create_channel(
220231
host,
221232
credentials=credentials,
222233
credentials_file=credentials_file,
223-
ssl_credentials=ssl_channel_credentials,
234+
ssl_credentials=self._ssl_channel_credentials,
224235
scopes=scopes or self.AUTH_SCOPES,
225236
quota_project_id=quota_project_id,
226237
options=[

0 commit comments

Comments
 (0)