API returns "400 Request contains an invalid argument." #161
Description
Hi, I'm not sure this is bug but please allow me to file this issue.
Environment details
- OS type and version: Windows 10
- Python version:
python --version
3.8.6 - pip version:
pip --version
21.1.2 google-cloud-securitycenter
version:pip show google-cloud-securitycenter
pip show google-cloud-securitycenter
Name: google-cloud-securitycenter
Version: 1.3.0
Summary: Cloud Security Command Center API client library
Home-page: https://github.com/googleapis/python-securitycenter
Author: Google LLC
Author-email: [email protected]
License: Apache 2.0
Location: c:\w\workspaces\python\gcptest\venv\lib\site-packages
Requires: packaging, google-api-core, proto-plus, grpc-google-iam-v1
Required-by:
Steps to reproduce
- just Run my Code example
Code example
This is almost same as given code on manual.
https://cloud.google.com/security-command-center/docs/how-to-api-list-assets?hl=ja
# example
from google.cloud.securitycenter import SecurityCenterClient
< configure my credential args and organization_id>
client = SecurityCenterClient.from_service_account_info(info=credential_args)
org_name = "organizations/{org_id}".format(org_id=organization_id)
asset_iterator = client.list_assets(request={"parent": org_name})
for i, asset_result in enumerate(asset_iterator):
print(i, asset_result)
Below codes are works well. I've used this to make sure my credentials are valid,
from google.oauth2 import service_account
credential = service_account.Credentials.from_service_account_info(info=credential_args)
alternate_client = resource_manager.Client(credentials=credential)
project_iterator = alternate_client.list_projects()
for i, project in enumerate(project_iterator):
print(i, project)
When I input wrong organization_id, I got another error. so I've assumed my organization_id is correct.
google.api_core.exceptions.InvalidArgument: 400 Fail to resolve resource 'organizations/Dummy'
Stack trace
Traceback (most recent call last):
File "C:\w\workspaces\python\gcptest\venv\lib\site-packages\google\api_core\grpc_helpers.py", line 67, in error_remapped_callable
return callable_(*args, **kwargs)
File "C:\w\workspaces\python\gcptest\venv\lib\site-packages\grpc\_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\w\workspaces\python\gcptest\venv\lib\site-packages\grpc\_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "{"created":"@1623379341.990000000","description":"Error received from peer ipv4:172.217.31.138:443","file":"src/core/lib/surface/call.cc","file_line":1067,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:/w/workspaces/python/gcptest/main.py", line 29, in <module>
asset_iterator = client.list_assets(request={"parent": org_name})
File "C:\w\workspaces\python\gcptest\venv\lib\site-packages\google\cloud\securitycenter_v1\services\security_center\client.py", line 1401, in list_assets
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
File "C:\w\workspaces\python\gcptest\venv\lib\site-packages\google\api_core\gapic_v1\method.py", line 145, in __call__
return wrapped_func(*args, **kwargs)
File "C:\w\workspaces\python\gcptest\venv\lib\site-packages\google\api_core\retry.py", line 285, in retry_wrapped_func
return retry_target(
File "C:\w\workspaces\python\gcptest\venv\lib\site-packages\google\api_core\retry.py", line 188, in retry_target
return target()
File "C:\w\workspaces\python\gcptest\venv\lib\site-packages\google\api_core\grpc_helpers.py", line 69, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument.