Skip to content

Commit db2de4a

Browse files
chore: re-generated to pick up changes from googleapis.(#101)
* changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * chore: upgrade gapic-generator-python to 0.43.1 PiperOrigin-RevId: 364411656 Source-Author: Google APIs <[email protected]> Source-Date: Mon Mar 22 14:40:22 2021 -0700 Source-Repo: googleapis/googleapis Source-Sha: 149a3a84c29c9b8189576c7442ccb6dcf6a8f95b Source-Link: googleapis/googleapis@149a3a8
1 parent 0051777 commit db2de4a

File tree

4 files changed

+89
-143
lines changed

4 files changed

+89
-143
lines changed

packages/google-cloud-containeranalysis/google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,20 @@ def __init__(
7171
scope (Optional[Sequence[str]]): A list of scopes.
7272
quota_project_id (Optional[str]): An optional project to use for billing
7373
and quota.
74-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
75-
The client info used to send a user-agent string along with
76-
API requests. If ``None``, then default info will be used.
77-
Generally, you only need to set this if you're developing
74+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
75+
The client info used to send a user-agent string along with
76+
API requests. If ``None``, then default info will be used.
77+
Generally, you only need to set this if you're developing
7878
your own client library.
7979
"""
8080
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
8181
if ":" not in host:
8282
host += ":443"
8383
self._host = host
8484

85+
# Save the scopes.
86+
self._scopes = scopes or self.AUTH_SCOPES
87+
8588
# If no credentials are provided, then determine the appropriate
8689
# defaults.
8790
if credentials and credentials_file:
@@ -91,20 +94,17 @@ def __init__(
9194

9295
if credentials_file is not None:
9396
credentials, _ = auth.load_credentials_from_file(
94-
credentials_file, scopes=scopes, quota_project_id=quota_project_id
97+
credentials_file, scopes=self._scopes, quota_project_id=quota_project_id
9598
)
9699

97100
elif credentials is None:
98101
credentials, _ = auth.default(
99-
scopes=scopes, quota_project_id=quota_project_id
102+
scopes=self._scopes, quota_project_id=quota_project_id
100103
)
101104

102105
# Save the credentials.
103106
self._credentials = credentials
104107

105-
# Lifted into its own function so it can be stubbed out during tests.
106-
self._prep_wrapped_messages(client_info)
107-
108108
def _prep_wrapped_messages(self, client_info):
109109
# Precompute the wrapped methods.
110110
self._wrapped_methods = {

packages/google-cloud-containeranalysis/google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/grpc.py

Lines changed: 37 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -122,96 +122,69 @@ def __init__(
122122
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
123123
and ``credentials_file`` are passed.
124124
"""
125+
self._grpc_channel = None
125126
self._ssl_channel_credentials = ssl_channel_credentials
127+
self._stubs: Dict[str, Callable] = {}
126128

127129
if api_mtls_endpoint:
128130
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
129131
if client_cert_source:
130132
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
131133

132134
if channel:
133-
# Sanity check: Ensure that channel and credentials are not both
134-
# provided.
135+
# Ignore credentials if a channel was passed.
135136
credentials = False
136-
137137
# If a channel was explicitly provided, set it.
138138
self._grpc_channel = channel
139139
self._ssl_channel_credentials = None
140-
elif api_mtls_endpoint:
141-
host = (
142-
api_mtls_endpoint
143-
if ":" in api_mtls_endpoint
144-
else api_mtls_endpoint + ":443"
145-
)
146-
147-
if credentials is None:
148-
credentials, _ = auth.default(
149-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
150-
)
151-
152-
# Create SSL credentials with client_cert_source or application
153-
# default SSL credentials.
154-
if client_cert_source:
155-
cert, key = client_cert_source()
156-
ssl_credentials = grpc.ssl_channel_credentials(
157-
certificate_chain=cert, private_key=key
158-
)
159-
else:
160-
ssl_credentials = SslCredentials().ssl_credentials
161140

162-
# create a new channel. The provided one is ignored.
163-
self._grpc_channel = type(self).create_channel(
164-
host,
165-
credentials=credentials,
166-
credentials_file=credentials_file,
167-
ssl_credentials=ssl_credentials,
168-
scopes=scopes or self.AUTH_SCOPES,
169-
quota_project_id=quota_project_id,
170-
options=[
171-
("grpc.max_send_message_length", -1),
172-
("grpc.max_receive_message_length", -1),
173-
],
174-
)
175-
self._ssl_channel_credentials = ssl_credentials
176141
else:
177-
host = host if ":" in host else host + ":443"
142+
if api_mtls_endpoint:
143+
host = api_mtls_endpoint
144+
145+
# Create SSL credentials with client_cert_source or application
146+
# default SSL credentials.
147+
if client_cert_source:
148+
cert, key = client_cert_source()
149+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
150+
certificate_chain=cert, private_key=key
151+
)
152+
else:
153+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
178154

179-
if credentials is None:
180-
credentials, _ = auth.default(
181-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
182-
)
155+
else:
156+
if client_cert_source_for_mtls and not ssl_channel_credentials:
157+
cert, key = client_cert_source_for_mtls()
158+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
159+
certificate_chain=cert, private_key=key
160+
)
183161

184-
if client_cert_source_for_mtls and not ssl_channel_credentials:
185-
cert, key = client_cert_source_for_mtls()
186-
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
187-
certificate_chain=cert, private_key=key
188-
)
162+
# The base transport sets the host, credentials and scopes
163+
super().__init__(
164+
host=host,
165+
credentials=credentials,
166+
credentials_file=credentials_file,
167+
scopes=scopes,
168+
quota_project_id=quota_project_id,
169+
client_info=client_info,
170+
)
189171

190-
# create a new channel. The provided one is ignored.
172+
if not self._grpc_channel:
191173
self._grpc_channel = type(self).create_channel(
192-
host,
193-
credentials=credentials,
174+
self._host,
175+
credentials=self._credentials,
194176
credentials_file=credentials_file,
177+
scopes=self._scopes,
195178
ssl_credentials=self._ssl_channel_credentials,
196-
scopes=scopes or self.AUTH_SCOPES,
197179
quota_project_id=quota_project_id,
198180
options=[
199181
("grpc.max_send_message_length", -1),
200182
("grpc.max_receive_message_length", -1),
201183
],
202184
)
203185

204-
self._stubs = {} # type: Dict[str, Callable]
205-
206-
# Run the base constructor.
207-
super().__init__(
208-
host=host,
209-
credentials=credentials,
210-
credentials_file=credentials_file,
211-
scopes=scopes or self.AUTH_SCOPES,
212-
quota_project_id=quota_project_id,
213-
client_info=client_info,
214-
)
186+
# Wrap messages. This must be done after self._grpc_channel exists
187+
self._prep_wrapped_messages(client_info)
215188

216189
@classmethod
217190
def create_channel(
@@ -225,7 +198,7 @@ def create_channel(
225198
) -> grpc.Channel:
226199
"""Create and return a gRPC channel object.
227200
Args:
228-
address (Optional[str]): The host for the channel to use.
201+
host (Optional[str]): The host for the channel to use.
229202
credentials (Optional[~.Credentials]): The
230203
authorization credentials to attach to requests. These
231204
credentials identify this application to the service. If

packages/google-cloud-containeranalysis/google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/grpc_asyncio.py

Lines changed: 41 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def create_channel(
7777
) -> aio.Channel:
7878
"""Create and return a gRPC AsyncIO channel object.
7979
Args:
80-
address (Optional[str]): The host for the channel to use.
80+
host (Optional[str]): The host for the channel to use.
8181
credentials (Optional[~.Credentials]): The
8282
authorization credentials to attach to requests. These
8383
credentials identify this application to the service. If
@@ -155,10 +155,10 @@ def __init__(
155155
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
156156
quota_project_id (Optional[str]): An optional project to use for billing
157157
and quota.
158-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
159-
The client info used to send a user-agent string along with
160-
API requests. If ``None``, then default info will be used.
161-
Generally, you only need to set this if you're developing
158+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
159+
The client info used to send a user-agent string along with
160+
API requests. If ``None``, then default info will be used.
161+
Generally, you only need to set this if you're developing
162162
your own client library.
163163
164164
Raises:
@@ -167,96 +167,69 @@ def __init__(
167167
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
168168
and ``credentials_file`` are passed.
169169
"""
170+
self._grpc_channel = None
170171
self._ssl_channel_credentials = ssl_channel_credentials
172+
self._stubs: Dict[str, Callable] = {}
171173

172174
if api_mtls_endpoint:
173175
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
174176
if client_cert_source:
175177
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
176178

177179
if channel:
178-
# Sanity check: Ensure that channel and credentials are not both
179-
# provided.
180+
# Ignore credentials if a channel was passed.
180181
credentials = False
181-
182182
# If a channel was explicitly provided, set it.
183183
self._grpc_channel = channel
184184
self._ssl_channel_credentials = None
185-
elif api_mtls_endpoint:
186-
host = (
187-
api_mtls_endpoint
188-
if ":" in api_mtls_endpoint
189-
else api_mtls_endpoint + ":443"
190-
)
191-
192-
if credentials is None:
193-
credentials, _ = auth.default(
194-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
195-
)
196-
197-
# Create SSL credentials with client_cert_source or application
198-
# default SSL credentials.
199-
if client_cert_source:
200-
cert, key = client_cert_source()
201-
ssl_credentials = grpc.ssl_channel_credentials(
202-
certificate_chain=cert, private_key=key
203-
)
204-
else:
205-
ssl_credentials = SslCredentials().ssl_credentials
206185

207-
# create a new channel. The provided one is ignored.
208-
self._grpc_channel = type(self).create_channel(
209-
host,
210-
credentials=credentials,
211-
credentials_file=credentials_file,
212-
ssl_credentials=ssl_credentials,
213-
scopes=scopes or self.AUTH_SCOPES,
214-
quota_project_id=quota_project_id,
215-
options=[
216-
("grpc.max_send_message_length", -1),
217-
("grpc.max_receive_message_length", -1),
218-
],
219-
)
220-
self._ssl_channel_credentials = ssl_credentials
221186
else:
222-
host = host if ":" in host else host + ":443"
187+
if api_mtls_endpoint:
188+
host = api_mtls_endpoint
189+
190+
# Create SSL credentials with client_cert_source or application
191+
# default SSL credentials.
192+
if client_cert_source:
193+
cert, key = client_cert_source()
194+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
195+
certificate_chain=cert, private_key=key
196+
)
197+
else:
198+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
223199

224-
if credentials is None:
225-
credentials, _ = auth.default(
226-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
227-
)
200+
else:
201+
if client_cert_source_for_mtls and not ssl_channel_credentials:
202+
cert, key = client_cert_source_for_mtls()
203+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
204+
certificate_chain=cert, private_key=key
205+
)
228206

229-
if client_cert_source_for_mtls and not ssl_channel_credentials:
230-
cert, key = client_cert_source_for_mtls()
231-
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
232-
certificate_chain=cert, private_key=key
233-
)
207+
# The base transport sets the host, credentials and scopes
208+
super().__init__(
209+
host=host,
210+
credentials=credentials,
211+
credentials_file=credentials_file,
212+
scopes=scopes,
213+
quota_project_id=quota_project_id,
214+
client_info=client_info,
215+
)
234216

235-
# create a new channel. The provided one is ignored.
217+
if not self._grpc_channel:
236218
self._grpc_channel = type(self).create_channel(
237-
host,
238-
credentials=credentials,
219+
self._host,
220+
credentials=self._credentials,
239221
credentials_file=credentials_file,
222+
scopes=self._scopes,
240223
ssl_credentials=self._ssl_channel_credentials,
241-
scopes=scopes or self.AUTH_SCOPES,
242224
quota_project_id=quota_project_id,
243225
options=[
244226
("grpc.max_send_message_length", -1),
245227
("grpc.max_receive_message_length", -1),
246228
],
247229
)
248230

249-
# Run the base constructor.
250-
super().__init__(
251-
host=host,
252-
credentials=credentials,
253-
credentials_file=credentials_file,
254-
scopes=scopes or self.AUTH_SCOPES,
255-
quota_project_id=quota_project_id,
256-
client_info=client_info,
257-
)
258-
259-
self._stubs = {}
231+
# Wrap messages. This must be done after self._grpc_channel exists
232+
self._prep_wrapped_messages(client_info)
260233

261234
@property
262235
def grpc_channel(self) -> aio.Channel:

packages/google-cloud-containeranalysis/synth.metadata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "28a591963253d52ce3a25a918cafbdd9928de8cf",
15-
"internalRef": "361662015"
14+
"sha": "149a3a84c29c9b8189576c7442ccb6dcf6a8f95b",
15+
"internalRef": "364411656"
1616
}
1717
},
1818
{

0 commit comments

Comments
 (0)