Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4f3671c

Browse files
committed
fix incorrect tests
1 parentdaec685 commit4f3671c

File tree

4 files changed

+178
-94
lines changed

4 files changed

+178
-94
lines changed

‎google/api_core/operations_v1/abstract_operations_async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(
9898
"""
9999
super().__init__(
100100
credentials=credentials,# type: ignore
101-
transport=transport,
101+
transport=transportor"rest_asyncio",
102102
client_options=client_options,
103103
client_info=client_info,
104104
)

‎google/api_core/operations_v1/abstract_operations_base_client.py

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
fromtypingimportDict,Optional,Type,Union
2020

2121
fromgoogle.api_coreimportclient_optionsasclient_options_lib# type: ignore
22+
fromgoogle.api_coreimportexceptionsascore_exceptions# type: ignore
2223
fromgoogle.api_coreimportgapic_v1# type: ignore
2324
fromgoogle.api_core.operations_v1.transports.baseimport (
2425
DEFAULT_CLIENT_INFO,
@@ -39,7 +40,6 @@
3940
fromgoogle.authimportcredentialsasga_credentials# type: ignore
4041
fromgoogle.auth.exceptionsimportMutualTLSChannelError# type: ignore
4142
fromgoogle.auth.transportimportmtls# type: ignore
42-
fromgoogle.oauth2importservice_account# type: ignore
4343

4444

4545
classAbstractOperationsBaseClientMeta(type):
@@ -143,9 +143,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
143143
Returns:
144144
AbstractOperationsClient: The constructed client.
145145
"""
146-
credentials=service_account.Credentials.from_service_account_info(info)
147-
kwargs["credentials"]=credentials
148-
returncls(*args,**kwargs)
146+
raiseNotImplementedError("`from_service_account_info` is not implemented.")
149147

150148
@classmethod
151149
deffrom_service_account_file(cls,filename:str,*args,**kwargs):
@@ -161,9 +159,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
161159
Returns:
162160
AbstractOperationsClient: The constructed client.
163161
"""
164-
credentials=service_account.Credentials.from_service_account_file(filename)
165-
kwargs["credentials"]=credentials
166-
returncls(*args,**kwargs)
162+
raiseNotImplementedError("`from_service_account_file` is not implemented.")
167163

168164
from_service_account_json=from_service_account_file
169165

@@ -362,15 +358,38 @@ def __init__(
362358
)
363359
self._transport=transport
364360
else:
365-
# TODO (WIP): This code block will fail becuase async rest layer does not support all params.
366361
Transport=type(self).get_transport_class(transport)
367-
self._transport=Transport(
368-
credentials=credentials,
369-
credentials_file=client_options.credentials_file,
370-
host=api_endpoint,
371-
scopes=client_options.scopes,
372-
client_cert_source_for_mtls=client_cert_source_func,
373-
quota_project_id=client_options.quota_project_id,
374-
client_info=client_info,
375-
always_use_jwt_access=True,
376-
)
362+
if"async"instr(Transport).lower():
363+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2136): Support the following parameters in async rest.
364+
unsupported_params= {
365+
"google.api_core.client_options.ClientOptions.credentials_file":client_options.credentials_file,
366+
"google.api_core.client_options.ClientOptions.scopes":client_options.scopes,
367+
"google.api_core.client_options.ClientOptions.quota_project_id":client_options.quota_project_id,
368+
"google.api_core.client_options.ClientOptions.client_cert_source":client_options.client_cert_source,
369+
"google.api_core.client_options.ClientOptions.api_audience":client_options.api_audience,
370+
}
371+
provided_unsupported_params= [
372+
name
373+
forname,valueinunsupported_params.items()
374+
ifvalueisnotNone
375+
]
376+
ifprovided_unsupported_params:
377+
raisecore_exceptions.AsyncRestUnsupportedParameterError(
378+
f"The following provided parameters are not supported for `transport=rest_asyncio`:{', '.join(provided_unsupported_params)}"
379+
)
380+
self._transport=Transport(
381+
credentials=credentials,
382+
host=api_endpoint,
383+
client_info=client_info,
384+
)
385+
else:
386+
self._transport=Transport(
387+
credentials=credentials,
388+
credentials_file=client_options.credentials_file,
389+
host=api_endpoint,
390+
scopes=client_options.scopes,
391+
client_cert_source_for_mtls=client_cert_source_func,
392+
quota_project_id=client_options.quota_project_id,
393+
client_info=client_info,
394+
always_use_jwt_access=True,
395+
)

‎google/api_core/operations_v1/abstract_operations_client.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
)
2929
fromgoogle.authimportcredentialsasga_credentials# type: ignore
3030
fromgoogle.longrunningimportoperations_pb2
31+
fromgoogle.oauth2importservice_account# type: ignore
3132
importgrpc
3233

3334
OptionalRetry=Union[retries.Retry,object]
@@ -98,6 +99,43 @@ def __init__(
9899
client_info=client_info,
99100
)
100101

102+
@classmethod
103+
deffrom_service_account_info(cls,info:dict,*args,**kwargs):
104+
"""Creates an instance of this client using the provided credentials
105+
info.
106+
107+
Args:
108+
info (dict): The service account private key info.
109+
args: Additional arguments to pass to the constructor.
110+
kwargs: Additional arguments to pass to the constructor.
111+
112+
Returns:
113+
AbstractOperationsClient: The constructed client.
114+
"""
115+
credentials=service_account.Credentials.from_service_account_info(info)
116+
kwargs["credentials"]=credentials
117+
returncls(*args,**kwargs)
118+
119+
@classmethod
120+
deffrom_service_account_file(cls,filename:str,*args,**kwargs):
121+
"""Creates an instance of this client using the provided credentials
122+
file.
123+
124+
Args:
125+
filename (str): The path to the service account private key json
126+
file.
127+
args: Additional arguments to pass to the constructor.
128+
kwargs: Additional arguments to pass to the constructor.
129+
130+
Returns:
131+
AbstractOperationsClient: The constructed client.
132+
"""
133+
credentials=service_account.Credentials.from_service_account_file(filename)
134+
kwargs["credentials"]=credentials
135+
returncls(*args,**kwargs)
136+
137+
from_service_account_json=from_service_account_file
138+
101139
deflist_operations(
102140
self,
103141
name:str,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp