From 37e649cbec6bcc87f71cf4dbb347fa3f3f9e1f87 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 17 Jul 2022 11:54:11 +0000 Subject: [PATCH] fix(deps): require google-api-core>=1.32.0,>=2.8.0 (#254) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 459095142 Source-Link: https://github.com/googleapis/googleapis/commit/4f1be992601ed740a581a32cedc4e7b6c6a27793 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ae686d9cde4fc3e36d0ac02efb8643b15890c1ed Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU2ODZkOWNkZTRmYzNlMzZkMGFjMDJlZmI4NjQzYjE1ODkwYzFlZCJ9 feat: add audience parameter PiperOrigin-RevId: 456827138 Source-Link: https://github.com/googleapis/googleapis/commit/23f1a157189581734c7a77cddfeb7c5bc1e440ae Source-Link: https://github.com/googleapis/googleapis-gen/commit/4075a8514f676691ec156688a5bbf183aa9893ce Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9 fix(v4beta1): remove Application and Profile services and and related protos, enums, and messages PiperOrigin-RevId: 453241222 Source-Link: https://github.com/googleapis/googleapis/commit/78374702d981a2c2c2ef787033c0584f4533a99e Source-Link: https://github.com/googleapis/googleapis-gen/commit/ae2c052743706161ac95adc5048ad5a3de8a6585 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWUyYzA1Mjc0MzcwNjE2MWFjOTVhZGM1MDQ4YWQ1YTNkZThhNjU4NSJ9 --- .github/workflows/unittest.yml | 2 +- docs/talent_v4beta1/application_service.rst | 10 - docs/talent_v4beta1/profile_service.rst | 10 - docs/talent_v4beta1/services.rst | 2 - .../services/company_service/client.py | 1 + .../company_service/transports/base.py | 16 +- .../company_service/transports/grpc.py | 2 + .../transports/grpc_asyncio.py | 2 + .../talent_v4/services/completion/client.py | 1 + .../services/completion/transports/base.py | 16 +- .../services/completion/transports/grpc.py | 2 + .../completion/transports/grpc_asyncio.py | 2 + .../services/event_service/client.py | 1 + .../services/event_service/transports/base.py | 16 +- .../services/event_service/transports/grpc.py | 2 + .../event_service/transports/grpc_asyncio.py | 2 + .../talent_v4/services/job_service/client.py | 1 + .../services/job_service/transports/base.py | 16 +- .../services/job_service/transports/grpc.py | 2 + .../job_service/transports/grpc_asyncio.py | 2 + .../services/tenant_service/client.py | 1 + .../tenant_service/transports/base.py | 16 +- .../tenant_service/transports/grpc.py | 2 + .../tenant_service/transports/grpc_asyncio.py | 2 + google/cloud/talent_v4beta1/__init__.py | 129 +- .../cloud/talent_v4beta1/gapic_metadata.json | 138 - .../services/application_service/__init__.py | 22 - .../application_service/async_client.py | 787 ---- .../services/application_service/client.py | 1047 ------ .../services/application_service/pagers.py | 157 - .../transports/__init__.py | 34 - .../application_service/transports/base.py | 249 -- .../application_service/transports/grpc.py | 378 -- .../transports/grpc_asyncio.py | 383 -- .../services/company_service/async_client.py | 56 + .../services/company_service/client.py | 57 + .../company_service/transports/base.py | 26 +- .../company_service/transports/grpc.py | 20 + .../transports/grpc_asyncio.py | 20 + .../services/completion/async_client.py | 56 + .../services/completion/client.py | 57 + .../services/completion/transports/base.py | 26 +- .../services/completion/transports/grpc.py | 20 + .../completion/transports/grpc_asyncio.py | 20 + .../services/event_service/async_client.py | 55 + .../services/event_service/client.py | 56 + .../services/event_service/transports/base.py | 26 +- .../services/event_service/transports/grpc.py | 20 + .../event_service/transports/grpc_asyncio.py | 20 + .../services/job_service/async_client.py | 62 +- .../services/job_service/client.py | 63 +- .../services/job_service/transports/base.py | 25 +- .../services/job_service/transports/grpc.py | 19 + .../job_service/transports/grpc_asyncio.py | 19 + .../services/profile_service/__init__.py | 22 - .../services/profile_service/async_client.py | 856 ----- .../services/profile_service/client.py | 1073 ------ .../services/profile_service/pagers.py | 283 -- .../profile_service/transports/__init__.py | 32 - .../profile_service/transports/base.py | 266 -- .../profile_service/transports/grpc.py | 412 --- .../transports/grpc_asyncio.py | 417 --- .../services/tenant_service/async_client.py | 56 + .../services/tenant_service/client.py | 57 + .../tenant_service/transports/base.py | 26 +- .../tenant_service/transports/grpc.py | 20 + .../tenant_service/transports/grpc_asyncio.py | 20 + google/cloud/talent_v4beta1/types/__init__.py | 120 +- .../cloud/talent_v4beta1/types/application.py | 211 -- .../types/application_service.py | 202 -- google/cloud/talent_v4beta1/types/common.py | 214 +- google/cloud/talent_v4beta1/types/event.py | 66 - google/cloud/talent_v4beta1/types/filters.py | 839 +---- .../cloud/talent_v4beta1/types/job_service.py | 84 +- google/cloud/talent_v4beta1/types/profile.py | 1327 ------- .../talent_v4beta1/types/profile_service.py | 617 ---- noxfile.py | 2 +- owlbot.py | 50 + ...cation_service_create_application_async.py | 51 - ...ication_service_create_application_sync.py | 51 - ...cation_service_delete_application_async.py | 43 - ...ication_service_delete_application_sync.py | 43 - ...plication_service_get_application_async.py | 45 - ...pplication_service_get_application_sync.py | 45 - ...ication_service_list_applications_async.py | 46 - ...lication_service_list_applications_sync.py | 46 - ...cation_service_update_application_async.py | 50 - ...ication_service_update_application_sync.py | 50 - ...ed_profile_service_create_profile_async.py | 45 - ...ted_profile_service_create_profile_sync.py | 45 - ...ed_profile_service_delete_profile_async.py | 43 - ...ted_profile_service_delete_profile_sync.py | 43 - ...rated_profile_service_get_profile_async.py | 45 - ...erated_profile_service_get_profile_sync.py | 45 - ...ted_profile_service_list_profiles_async.py | 46 - ...ated_profile_service_list_profiles_sync.py | 46 - ...d_profile_service_search_profiles_async.py | 46 - ...ed_profile_service_search_profiles_sync.py | 46 - ...ed_profile_service_update_profile_async.py | 44 - ...ted_profile_service_update_profile_sync.py | 44 - .../snippet_metadata_talent_v4beta1.json | 3099 ++++------------ scripts/fixup_talent_v4beta1_keywords.py | 15 +- setup.py | 5 +- testing/constraints-3.6.txt | 10 - testing/constraints-3.7.txt | 2 +- .../gapic/talent_v4/test_company_service.py | 52 + tests/unit/gapic/talent_v4/test_completion.py | 52 + .../gapic/talent_v4/test_event_service.py | 52 + .../unit/gapic/talent_v4/test_job_service.py | 52 + .../gapic/talent_v4/test_tenant_service.py | 52 + .../test_application_service.py | 2989 ---------------- .../talent_v4beta1/test_company_service.py | 199 ++ .../gapic/talent_v4beta1/test_completion.py | 203 +- .../talent_v4beta1/test_event_service.py | 203 +- .../gapic/talent_v4beta1/test_job_service.py | 198 ++ .../talent_v4beta1/test_profile_service.py | 3167 ----------------- .../talent_v4beta1/test_tenant_service.py | 199 ++ 117 files changed, 3066 insertions(+), 19939 deletions(-) delete mode 100644 docs/talent_v4beta1/application_service.rst delete mode 100644 docs/talent_v4beta1/profile_service.rst delete mode 100644 google/cloud/talent_v4beta1/services/application_service/__init__.py delete mode 100644 google/cloud/talent_v4beta1/services/application_service/async_client.py delete mode 100644 google/cloud/talent_v4beta1/services/application_service/client.py delete mode 100644 google/cloud/talent_v4beta1/services/application_service/pagers.py delete mode 100644 google/cloud/talent_v4beta1/services/application_service/transports/__init__.py delete mode 100644 google/cloud/talent_v4beta1/services/application_service/transports/base.py delete mode 100644 google/cloud/talent_v4beta1/services/application_service/transports/grpc.py delete mode 100644 google/cloud/talent_v4beta1/services/application_service/transports/grpc_asyncio.py delete mode 100644 google/cloud/talent_v4beta1/services/profile_service/__init__.py delete mode 100644 google/cloud/talent_v4beta1/services/profile_service/async_client.py delete mode 100644 google/cloud/talent_v4beta1/services/profile_service/client.py delete mode 100644 google/cloud/talent_v4beta1/services/profile_service/pagers.py delete mode 100644 google/cloud/talent_v4beta1/services/profile_service/transports/__init__.py delete mode 100644 google/cloud/talent_v4beta1/services/profile_service/transports/base.py delete mode 100644 google/cloud/talent_v4beta1/services/profile_service/transports/grpc.py delete mode 100644 google/cloud/talent_v4beta1/services/profile_service/transports/grpc_asyncio.py delete mode 100644 google/cloud/talent_v4beta1/types/application.py delete mode 100644 google/cloud/talent_v4beta1/types/application_service.py delete mode 100644 google/cloud/talent_v4beta1/types/profile.py delete mode 100644 google/cloud/talent_v4beta1/types/profile_service.py create mode 100644 owlbot.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_create_application_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_create_application_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_delete_application_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_delete_application_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_get_application_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_get_application_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_list_applications_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_list_applications_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_update_application_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_application_service_update_application_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_create_profile_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_create_profile_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_delete_profile_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_delete_profile_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_get_profile_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_get_profile_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_list_profiles_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_list_profiles_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_search_profiles_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_search_profiles_sync.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_update_profile_async.py delete mode 100644 samples/generated_samples/jobs_v4beta1_generated_profile_service_update_profile_sync.py delete mode 100644 testing/constraints-3.6.txt delete mode 100644 tests/unit/gapic/talent_v4beta1/test_application_service.py delete mode 100644 tests/unit/gapic/talent_v4beta1/test_profile_service.py diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 5531b014..f76daebf 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -54,4 +54,4 @@ jobs: - name: Report coverage results run: | coverage combine .coverage-results/.coverage* - coverage report --show-missing --fail-under=100 + coverage report --show-missing --fail-under=99 diff --git a/docs/talent_v4beta1/application_service.rst b/docs/talent_v4beta1/application_service.rst deleted file mode 100644 index 58e0529b..00000000 --- a/docs/talent_v4beta1/application_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -ApplicationService ------------------------------------- - -.. automodule:: google.cloud.talent_v4beta1.services.application_service - :members: - :inherited-members: - -.. automodule:: google.cloud.talent_v4beta1.services.application_service.pagers - :members: - :inherited-members: diff --git a/docs/talent_v4beta1/profile_service.rst b/docs/talent_v4beta1/profile_service.rst deleted file mode 100644 index cf00d2d8..00000000 --- a/docs/talent_v4beta1/profile_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -ProfileService --------------------------------- - -.. automodule:: google.cloud.talent_v4beta1.services.profile_service - :members: - :inherited-members: - -.. automodule:: google.cloud.talent_v4beta1.services.profile_service.pagers - :members: - :inherited-members: diff --git a/docs/talent_v4beta1/services.rst b/docs/talent_v4beta1/services.rst index 019f928f..f7b55d45 100644 --- a/docs/talent_v4beta1/services.rst +++ b/docs/talent_v4beta1/services.rst @@ -3,10 +3,8 @@ Services for Google Cloud Talent v4beta1 API .. toctree:: :maxdepth: 2 - application_service company_service completion event_service job_service - profile_service tenant_service diff --git a/google/cloud/talent_v4/services/company_service/client.py b/google/cloud/talent_v4/services/company_service/client.py index e850016b..21cfa1f7 100644 --- a/google/cloud/talent_v4/services/company_service/client.py +++ b/google/cloud/talent_v4/services/company_service/client.py @@ -449,6 +449,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def create_company( diff --git a/google/cloud/talent_v4/services/company_service/transports/base.py b/google/cloud/talent_v4/services/company_service/transports/base.py index e67abf0b..b23b9b8d 100644 --- a/google/cloud/talent_v4/services/company_service/transports/base.py +++ b/google/cloud/talent_v4/services/company_service/transports/base.py @@ -60,6 +60,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -87,11 +88,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -112,6 +108,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -124,6 +125,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/talent_v4/services/company_service/transports/grpc.py b/google/cloud/talent_v4/services/company_service/transports/grpc.py index 410b5d4d..260688bc 100644 --- a/google/cloud/talent_v4/services/company_service/transports/grpc.py +++ b/google/cloud/talent_v4/services/company_service/transports/grpc.py @@ -61,6 +61,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -156,6 +157,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py index 38ac77b9..8252cac6 100644 --- a/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py @@ -106,6 +106,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -201,6 +202,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4/services/completion/client.py b/google/cloud/talent_v4/services/completion/client.py index 100a2956..15a382d2 100644 --- a/google/cloud/talent_v4/services/completion/client.py +++ b/google/cloud/talent_v4/services/completion/client.py @@ -439,6 +439,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def complete_query( diff --git a/google/cloud/talent_v4/services/completion/transports/base.py b/google/cloud/talent_v4/services/completion/transports/base.py index 28f59a49..87033afc 100644 --- a/google/cloud/talent_v4/services/completion/transports/base.py +++ b/google/cloud/talent_v4/services/completion/transports/base.py @@ -57,6 +57,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -84,11 +85,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -109,6 +105,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -121,6 +122,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/talent_v4/services/completion/transports/grpc.py b/google/cloud/talent_v4/services/completion/transports/grpc.py index 15f044a1..2d2a85f8 100644 --- a/google/cloud/talent_v4/services/completion/transports/grpc.py +++ b/google/cloud/talent_v4/services/completion/transports/grpc.py @@ -57,6 +57,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -152,6 +153,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py index ba3c3149..fb135ab8 100644 --- a/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py @@ -102,6 +102,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -197,6 +198,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4/services/event_service/client.py b/google/cloud/talent_v4/services/event_service/client.py index 5f72f913..834d5df3 100644 --- a/google/cloud/talent_v4/services/event_service/client.py +++ b/google/cloud/talent_v4/services/event_service/client.py @@ -419,6 +419,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def create_client_event( diff --git a/google/cloud/talent_v4/services/event_service/transports/base.py b/google/cloud/talent_v4/services/event_service/transports/base.py index 53e2ce85..4b9f7676 100644 --- a/google/cloud/talent_v4/services/event_service/transports/base.py +++ b/google/cloud/talent_v4/services/event_service/transports/base.py @@ -57,6 +57,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -84,11 +85,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -109,6 +105,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -121,6 +122,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/talent_v4/services/event_service/transports/grpc.py b/google/cloud/talent_v4/services/event_service/transports/grpc.py index 4cfd5091..4d6a8d3f 100644 --- a/google/cloud/talent_v4/services/event_service/transports/grpc.py +++ b/google/cloud/talent_v4/services/event_service/transports/grpc.py @@ -57,6 +57,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -152,6 +153,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py index 5f71048b..cb151d88 100644 --- a/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py @@ -102,6 +102,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -197,6 +198,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4/services/job_service/client.py b/google/cloud/talent_v4/services/job_service/client.py index 2210ca24..07e78755 100644 --- a/google/cloud/talent_v4/services/job_service/client.py +++ b/google/cloud/talent_v4/services/job_service/client.py @@ -472,6 +472,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def create_job( diff --git a/google/cloud/talent_v4/services/job_service/transports/base.py b/google/cloud/talent_v4/services/job_service/transports/base.py index da0e24f1..4dbdd900 100644 --- a/google/cloud/talent_v4/services/job_service/transports/base.py +++ b/google/cloud/talent_v4/services/job_service/transports/base.py @@ -61,6 +61,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -88,11 +89,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -113,6 +109,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -125,6 +126,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/talent_v4/services/job_service/transports/grpc.py b/google/cloud/talent_v4/services/job_service/transports/grpc.py index 08b1d87f..879ec2f7 100644 --- a/google/cloud/talent_v4/services/job_service/transports/grpc.py +++ b/google/cloud/talent_v4/services/job_service/transports/grpc.py @@ -62,6 +62,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -158,6 +159,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py index e18c49d0..9ebcdb81 100644 --- a/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py @@ -107,6 +107,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -203,6 +204,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4/services/tenant_service/client.py b/google/cloud/talent_v4/services/tenant_service/client.py index 56fe233a..432fa236 100644 --- a/google/cloud/talent_v4/services/tenant_service/client.py +++ b/google/cloud/talent_v4/services/tenant_service/client.py @@ -424,6 +424,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def create_tenant( diff --git a/google/cloud/talent_v4/services/tenant_service/transports/base.py b/google/cloud/talent_v4/services/tenant_service/transports/base.py index e19cd228..674c1173 100644 --- a/google/cloud/talent_v4/services/tenant_service/transports/base.py +++ b/google/cloud/talent_v4/services/tenant_service/transports/base.py @@ -60,6 +60,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -87,11 +88,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -112,6 +108,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -124,6 +125,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/talent_v4/services/tenant_service/transports/grpc.py b/google/cloud/talent_v4/services/tenant_service/transports/grpc.py index 3ca6b64b..ad70019f 100644 --- a/google/cloud/talent_v4/services/tenant_service/transports/grpc.py +++ b/google/cloud/talent_v4/services/tenant_service/transports/grpc.py @@ -61,6 +61,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -156,6 +157,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py index ce003f04..ced9f982 100644 --- a/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py @@ -106,6 +106,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -201,6 +202,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: diff --git a/google/cloud/talent_v4beta1/__init__.py b/google/cloud/talent_v4beta1/__init__.py index 740e2f47..38d054d7 100644 --- a/google/cloud/talent_v4beta1/__init__.py +++ b/google/cloud/talent_v4beta1/__init__.py @@ -14,50 +14,28 @@ # limitations under the License. # -from .services.application_service import ( - ApplicationServiceAsyncClient, - ApplicationServiceClient, -) from .services.company_service import CompanyServiceAsyncClient, CompanyServiceClient from .services.completion import CompletionAsyncClient, CompletionClient from .services.event_service import EventServiceAsyncClient, EventServiceClient from .services.job_service import JobServiceAsyncClient, JobServiceClient -from .services.profile_service import ProfileServiceAsyncClient, ProfileServiceClient from .services.tenant_service import TenantServiceAsyncClient, TenantServiceClient -from .types.application import Application -from .types.application_service import ( - CreateApplicationRequest, - DeleteApplicationRequest, - GetApplicationRequest, - ListApplicationsRequest, - ListApplicationsResponse, - UpdateApplicationRequest, -) from .types.common import ( - AvailabilitySignalType, BatchOperationMetadata, - Certification, CommuteMethod, CompanySize, CompensationInfo, - ContactInfoUsage, CustomAttribute, DegreeType, DeviceInfo, EmploymentType, HtmlSanitization, - Interview, JobBenefit, JobCategory, JobLevel, Location, - Outcome, PostingRegion, - Rating, RequestMetadata, ResponseMetadata, - Skill, - SkillProficiencyLevel, SpellingCorrection, TimestampRange, Visibility, @@ -72,27 +50,9 @@ UpdateCompanyRequest, ) from .types.completion_service import CompleteQueryRequest, CompleteQueryResponse -from .types.event import ClientEvent, JobEvent, ProfileEvent +from .types.event import ClientEvent, JobEvent from .types.event_service import CreateClientEventRequest -from .types.filters import ( - ApplicationDateFilter, - ApplicationJobFilter, - ApplicationOutcomeNotesFilter, - AvailabilityFilter, - CandidateAvailabilityFilter, - CommuteFilter, - CompensationFilter, - EducationFilter, - EmployerFilter, - JobQuery, - JobTitleFilter, - LocationFilter, - PersonNameFilter, - ProfileQuery, - SkillFilter, - TimeFilter, - WorkExperienceFilter, -) +from .types.filters import CommuteFilter, CompensationFilter, JobQuery, LocationFilter from .types.histogram import HistogramQuery, HistogramQueryResult from .types.job import Job from .types.job_service import ( @@ -110,34 +70,6 @@ SearchJobsResponse, UpdateJobRequest, ) -from .types.profile import ( - Activity, - AdditionalContactInfo, - Address, - AvailabilitySignal, - Degree, - EducationRecord, - Email, - EmploymentRecord, - Patent, - PersonalUri, - PersonName, - Phone, - Profile, - Publication, - Resume, -) -from .types.profile_service import ( - CreateProfileRequest, - DeleteProfileRequest, - GetProfileRequest, - ListProfilesRequest, - ListProfilesResponse, - SearchProfilesRequest, - SearchProfilesResponse, - SummarizedProfile, - UpdateProfileRequest, -) from .types.tenant import Tenant from .types.tenant_service import ( CreateTenantRequest, @@ -149,30 +81,15 @@ ) __all__ = ( - "ApplicationServiceAsyncClient", "CompanyServiceAsyncClient", "CompletionAsyncClient", "EventServiceAsyncClient", "JobServiceAsyncClient", - "ProfileServiceAsyncClient", "TenantServiceAsyncClient", - "Activity", - "AdditionalContactInfo", - "Address", - "Application", - "ApplicationDateFilter", - "ApplicationJobFilter", - "ApplicationOutcomeNotesFilter", - "ApplicationServiceClient", - "AvailabilityFilter", - "AvailabilitySignal", - "AvailabilitySignalType", "BatchCreateJobsRequest", "BatchDeleteJobsRequest", "BatchOperationMetadata", "BatchUpdateJobsRequest", - "CandidateAvailabilityFilter", - "Certification", "ClientEvent", "CommuteFilter", "CommuteMethod", @@ -184,38 +101,24 @@ "CompleteQueryRequest", "CompleteQueryResponse", "CompletionClient", - "ContactInfoUsage", - "CreateApplicationRequest", "CreateClientEventRequest", "CreateCompanyRequest", "CreateJobRequest", - "CreateProfileRequest", "CreateTenantRequest", "CustomAttribute", - "Degree", "DegreeType", - "DeleteApplicationRequest", "DeleteCompanyRequest", "DeleteJobRequest", - "DeleteProfileRequest", "DeleteTenantRequest", "DeviceInfo", - "EducationFilter", - "EducationRecord", - "Email", - "EmployerFilter", - "EmploymentRecord", "EmploymentType", "EventServiceClient", - "GetApplicationRequest", "GetCompanyRequest", "GetJobRequest", - "GetProfileRequest", "GetTenantRequest", "HistogramQuery", "HistogramQueryResult", "HtmlSanitization", - "Interview", "Job", "JobBenefit", "JobCategory", @@ -224,54 +127,26 @@ "JobOperationResult", "JobQuery", "JobServiceClient", - "JobTitleFilter", "JobView", - "ListApplicationsRequest", - "ListApplicationsResponse", "ListCompaniesRequest", "ListCompaniesResponse", "ListJobsRequest", "ListJobsResponse", - "ListProfilesRequest", - "ListProfilesResponse", "ListTenantsRequest", "ListTenantsResponse", "Location", "LocationFilter", - "Outcome", - "Patent", - "PersonName", - "PersonNameFilter", - "PersonalUri", - "Phone", "PostingRegion", - "Profile", - "ProfileEvent", - "ProfileQuery", - "ProfileServiceClient", - "Publication", - "Rating", "RequestMetadata", "ResponseMetadata", - "Resume", "SearchJobsRequest", "SearchJobsResponse", - "SearchProfilesRequest", - "SearchProfilesResponse", - "Skill", - "SkillFilter", - "SkillProficiencyLevel", "SpellingCorrection", - "SummarizedProfile", "Tenant", "TenantServiceClient", - "TimeFilter", "TimestampRange", - "UpdateApplicationRequest", "UpdateCompanyRequest", "UpdateJobRequest", - "UpdateProfileRequest", "UpdateTenantRequest", "Visibility", - "WorkExperienceFilter", ) diff --git a/google/cloud/talent_v4beta1/gapic_metadata.json b/google/cloud/talent_v4beta1/gapic_metadata.json index f8bf14c6..ca15e97b 100644 --- a/google/cloud/talent_v4beta1/gapic_metadata.json +++ b/google/cloud/talent_v4beta1/gapic_metadata.json @@ -5,70 +5,6 @@ "protoPackage": "google.cloud.talent.v4beta1", "schema": "1.0", "services": { - "ApplicationService": { - "clients": { - "grpc": { - "libraryClient": "ApplicationServiceClient", - "rpcs": { - "CreateApplication": { - "methods": [ - "create_application" - ] - }, - "DeleteApplication": { - "methods": [ - "delete_application" - ] - }, - "GetApplication": { - "methods": [ - "get_application" - ] - }, - "ListApplications": { - "methods": [ - "list_applications" - ] - }, - "UpdateApplication": { - "methods": [ - "update_application" - ] - } - } - }, - "grpc-async": { - "libraryClient": "ApplicationServiceAsyncClient", - "rpcs": { - "CreateApplication": { - "methods": [ - "create_application" - ] - }, - "DeleteApplication": { - "methods": [ - "delete_application" - ] - }, - "GetApplication": { - "methods": [ - "get_application" - ] - }, - "ListApplications": { - "methods": [ - "list_applications" - ] - }, - "UpdateApplication": { - "methods": [ - "update_application" - ] - } - } - } - } - }, "CompanyService": { "clients": { "grpc": { @@ -295,80 +231,6 @@ } } }, - "ProfileService": { - "clients": { - "grpc": { - "libraryClient": "ProfileServiceClient", - "rpcs": { - "CreateProfile": { - "methods": [ - "create_profile" - ] - }, - "DeleteProfile": { - "methods": [ - "delete_profile" - ] - }, - "GetProfile": { - "methods": [ - "get_profile" - ] - }, - "ListProfiles": { - "methods": [ - "list_profiles" - ] - }, - "SearchProfiles": { - "methods": [ - "search_profiles" - ] - }, - "UpdateProfile": { - "methods": [ - "update_profile" - ] - } - } - }, - "grpc-async": { - "libraryClient": "ProfileServiceAsyncClient", - "rpcs": { - "CreateProfile": { - "methods": [ - "create_profile" - ] - }, - "DeleteProfile": { - "methods": [ - "delete_profile" - ] - }, - "GetProfile": { - "methods": [ - "get_profile" - ] - }, - "ListProfiles": { - "methods": [ - "list_profiles" - ] - }, - "SearchProfiles": { - "methods": [ - "search_profiles" - ] - }, - "UpdateProfile": { - "methods": [ - "update_profile" - ] - } - } - } - } - }, "TenantService": { "clients": { "grpc": { diff --git a/google/cloud/talent_v4beta1/services/application_service/__init__.py b/google/cloud/talent_v4beta1/services/application_service/__init__.py deleted file mode 100644 index 782d0859..00000000 --- a/google/cloud/talent_v4beta1/services/application_service/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .async_client import ApplicationServiceAsyncClient -from .client import ApplicationServiceClient - -__all__ = ( - "ApplicationServiceClient", - "ApplicationServiceAsyncClient", -) diff --git a/google/cloud/talent_v4beta1/services/application_service/async_client.py b/google/cloud/talent_v4beta1/services/application_service/async_client.py deleted file mode 100644 index bdeec858..00000000 --- a/google/cloud/talent_v4beta1/services/application_service/async_client.py +++ /dev/null @@ -1,787 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import functools -import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union - -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core.client_options import ClientOptions -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore -import pkg_resources - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore -from google.type import date_pb2 # type: ignore - -from google.cloud.talent_v4beta1.services.application_service import pagers -from google.cloud.talent_v4beta1.types import application -from google.cloud.talent_v4beta1.types import application as gct_application -from google.cloud.talent_v4beta1.types import application_service, common - -from .client import ApplicationServiceClient -from .transports.base import DEFAULT_CLIENT_INFO, ApplicationServiceTransport -from .transports.grpc_asyncio import ApplicationServiceGrpcAsyncIOTransport - - -class ApplicationServiceAsyncClient: - """A service that handles application management, including CRUD - and enumeration. - """ - - _client: ApplicationServiceClient - - DEFAULT_ENDPOINT = ApplicationServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = ApplicationServiceClient.DEFAULT_MTLS_ENDPOINT - - application_path = staticmethod(ApplicationServiceClient.application_path) - parse_application_path = staticmethod( - ApplicationServiceClient.parse_application_path - ) - company_path = staticmethod(ApplicationServiceClient.company_path) - parse_company_path = staticmethod(ApplicationServiceClient.parse_company_path) - job_path = staticmethod(ApplicationServiceClient.job_path) - parse_job_path = staticmethod(ApplicationServiceClient.parse_job_path) - profile_path = staticmethod(ApplicationServiceClient.profile_path) - parse_profile_path = staticmethod(ApplicationServiceClient.parse_profile_path) - common_billing_account_path = staticmethod( - ApplicationServiceClient.common_billing_account_path - ) - parse_common_billing_account_path = staticmethod( - ApplicationServiceClient.parse_common_billing_account_path - ) - common_folder_path = staticmethod(ApplicationServiceClient.common_folder_path) - parse_common_folder_path = staticmethod( - ApplicationServiceClient.parse_common_folder_path - ) - common_organization_path = staticmethod( - ApplicationServiceClient.common_organization_path - ) - parse_common_organization_path = staticmethod( - ApplicationServiceClient.parse_common_organization_path - ) - common_project_path = staticmethod(ApplicationServiceClient.common_project_path) - parse_common_project_path = staticmethod( - ApplicationServiceClient.parse_common_project_path - ) - common_location_path = staticmethod(ApplicationServiceClient.common_location_path) - parse_common_location_path = staticmethod( - ApplicationServiceClient.parse_common_location_path - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ApplicationServiceAsyncClient: The constructed client. - """ - return ApplicationServiceClient.from_service_account_info.__func__(ApplicationServiceAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ApplicationServiceAsyncClient: The constructed client. - """ - return ApplicationServiceClient.from_service_account_file.__func__(ApplicationServiceAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @classmethod - def get_mtls_endpoint_and_cert_source( - cls, client_options: Optional[ClientOptions] = None - ): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variabel is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - return ApplicationServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> ApplicationServiceTransport: - """Returns the transport used by the client instance. - - Returns: - ApplicationServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial( - type(ApplicationServiceClient).get_transport_class, - type(ApplicationServiceClient), - ) - - def __init__( - self, - *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, ApplicationServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the application service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.ApplicationServiceTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = ApplicationServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - ) - - async def create_application( - self, - request: Union[application_service.CreateApplicationRequest, dict] = None, - *, - parent: str = None, - application: gct_application.Application = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_application.Application: - r"""Creates a new application entity. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_create_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - application = talent_v4beta1.Application() - application.external_id = "external_id_value" - application.job = "job_value" - application.stage = "STARTED" - - request = talent_v4beta1.CreateApplicationRequest( - parent="parent_value", - application=application, - ) - - # Make the request - response = await client.create_application(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateApplicationRequest, dict]): - The request object. The Request of the CreateApplication - method. - parent (:class:`str`): - Required. Resource name of the profile under which the - application is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - application (:class:`google.cloud.talent_v4beta1.types.Application`): - Required. The application to be - created. - - This corresponds to the ``application`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Application: - Resource that represents a job - application record of a candidate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, application]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = application_service.CreateApplicationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if application is not None: - request.application = application - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_application, - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_application( - self, - request: Union[application_service.GetApplicationRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> application.Application: - r"""Retrieves specified application. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_get_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetApplicationRequest( - name="name_value", - ) - - # Make the request - response = await client.get_application(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetApplicationRequest, dict]): - The request object. Request for getting a application by - name. - name (:class:`str`): - Required. The resource name of the application to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". - For example, - "projects/foo/tenants/bar/profiles/baz/applications/qux". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Application: - Resource that represents a job - application record of a candidate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = application_service.GetApplicationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_application, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_application( - self, - request: Union[application_service.UpdateApplicationRequest, dict] = None, - *, - application: gct_application.Application = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_application.Application: - r"""Updates specified application. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_update_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - application = talent_v4beta1.Application() - application.external_id = "external_id_value" - application.job = "job_value" - application.stage = "STARTED" - - request = talent_v4beta1.UpdateApplicationRequest( - application=application, - ) - - # Make the request - response = await client.update_application(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateApplicationRequest, dict]): - The request object. Request for updating a specified - application. - application (:class:`google.cloud.talent_v4beta1.types.Application`): - Required. The application resource to - replace the current resource in the - system. - - This corresponds to the ``application`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Application: - Resource that represents a job - application record of a candidate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([application]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = application_service.UpdateApplicationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if application is not None: - request.application = application - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_application, - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("application.name", request.application.name),) - ), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_application( - self, - request: Union[application_service.DeleteApplicationRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified application. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_delete_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteApplicationRequest( - name="name_value", - ) - - # Make the request - await client.delete_application(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteApplicationRequest, dict]): - The request object. Request to delete a application. - name (:class:`str`): - Required. The resource name of the application to be - deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". - For example, - "projects/foo/tenants/bar/profiles/baz/applications/qux". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = application_service.DeleteApplicationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.delete_application, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def list_applications( - self, - request: Union[application_service.ListApplicationsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListApplicationsAsyncPager: - r"""Lists all applications associated with the profile. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_list_applications(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListApplicationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_applications(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListApplicationsRequest, dict]): - The request object. List applications for which the - client has ACL visibility. - parent (:class:`str`): - Required. Resource name of the profile under which the - application is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}", - for example, "projects/foo/tenants/bar/profiles/baz". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.services.application_service.pagers.ListApplicationsAsyncPager: - The List applications response - object. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = application_service.ListApplicationsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_applications, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListApplicationsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def __aenter__(self): - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("ApplicationServiceAsyncClient",) diff --git a/google/cloud/talent_v4beta1/services/application_service/client.py b/google/cloud/talent_v4beta1/services/application_service/client.py deleted file mode 100644 index 3e6b992d..00000000 --- a/google/cloud/talent_v4beta1/services/application_service/client.py +++ /dev/null @@ -1,1047 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import os -import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union - -from google.api_core import client_options as client_options_lib -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.oauth2 import service_account # type: ignore -import pkg_resources - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore -from google.type import date_pb2 # type: ignore - -from google.cloud.talent_v4beta1.services.application_service import pagers -from google.cloud.talent_v4beta1.types import application -from google.cloud.talent_v4beta1.types import application as gct_application -from google.cloud.talent_v4beta1.types import application_service, common - -from .transports.base import DEFAULT_CLIENT_INFO, ApplicationServiceTransport -from .transports.grpc import ApplicationServiceGrpcTransport -from .transports.grpc_asyncio import ApplicationServiceGrpcAsyncIOTransport - - -class ApplicationServiceClientMeta(type): - """Metaclass for the ApplicationService client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - - _transport_registry = ( - OrderedDict() - ) # type: Dict[str, Type[ApplicationServiceTransport]] - _transport_registry["grpc"] = ApplicationServiceGrpcTransport - _transport_registry["grpc_asyncio"] = ApplicationServiceGrpcAsyncIOTransport - - def get_transport_class( - cls, - label: str = None, - ) -> Type[ApplicationServiceTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class ApplicationServiceClient(metaclass=ApplicationServiceClientMeta): - """A service that handles application management, including CRUD - and enumeration. - """ - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - DEFAULT_ENDPOINT = "jobs.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ApplicationServiceClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ApplicationServiceClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file(filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> ApplicationServiceTransport: - """Returns the transport used by the client instance. - - Returns: - ApplicationServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def application_path( - project: str, - tenant: str, - profile: str, - application: str, - ) -> str: - """Returns a fully-qualified application string.""" - return "projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}".format( - project=project, - tenant=tenant, - profile=profile, - application=application, - ) - - @staticmethod - def parse_application_path(path: str) -> Dict[str, str]: - """Parses a application path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/tenants/(?P.+?)/profiles/(?P.+?)/applications/(?P.+?)$", - path, - ) - return m.groupdict() if m else {} - - @staticmethod - def company_path( - project: str, - tenant: str, - company: str, - ) -> str: - """Returns a fully-qualified company string.""" - return "projects/{project}/tenants/{tenant}/companies/{company}".format( - project=project, - tenant=tenant, - company=company, - ) - - @staticmethod - def parse_company_path(path: str) -> Dict[str, str]: - """Parses a company path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/tenants/(?P.+?)/companies/(?P.+?)$", - path, - ) - return m.groupdict() if m else {} - - @staticmethod - def job_path( - project: str, - tenant: str, - job: str, - ) -> str: - """Returns a fully-qualified job string.""" - return "projects/{project}/tenants/{tenant}/jobs/{job}".format( - project=project, - tenant=tenant, - job=job, - ) - - @staticmethod - def parse_job_path(path: str) -> Dict[str, str]: - """Parses a job path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/tenants/(?P.+?)/jobs/(?P.+?)$", - path, - ) - return m.groupdict() if m else {} - - @staticmethod - def profile_path( - project: str, - tenant: str, - profile: str, - ) -> str: - """Returns a fully-qualified profile string.""" - return "projects/{project}/tenants/{tenant}/profiles/{profile}".format( - project=project, - tenant=tenant, - profile=profile, - ) - - @staticmethod - def parse_profile_path(path: str) -> Dict[str, str]: - """Parses a profile path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/tenants/(?P.+?)/profiles/(?P.+?)$", - path, - ) - return m.groupdict() if m else {} - - @staticmethod - def common_billing_account_path( - billing_account: str, - ) -> str: - """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format( - billing_account=billing_account, - ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str, str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path( - folder: str, - ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format( - folder=folder, - ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str, str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path( - organization: str, - ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format( - organization=organization, - ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str, str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path( - project: str, - ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format( - project=project, - ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str, str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_location_path( - project: str, - location: str, - ) -> str: - """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format( - project=project, - location=location, - ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str, str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @classmethod - def get_mtls_endpoint_and_cert_source( - cls, client_options: Optional[client_options_lib.ClientOptions] = None - ): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variabel is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - if client_options is None: - client_options = client_options_lib.ClientOptions() - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_client_cert not in ("true", "false"): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError( - "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - ) - - # Figure out the client cert source to use. - client_cert_source = None - if use_client_cert == "true": - if client_options.client_cert_source: - client_cert_source = client_options.client_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - elif use_mtls_endpoint == "always" or ( - use_mtls_endpoint == "auto" and client_cert_source - ): - api_endpoint = cls.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = cls.DEFAULT_ENDPOINT - - return api_endpoint, client_cert_source - - def __init__( - self, - *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, ApplicationServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the application service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ApplicationServiceTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - - api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( - client_options - ) - - api_key_value = getattr(client_options, "api_key", None) - if api_key_value and credentials: - raise ValueError( - "client_options.api_key and credentials are mutually exclusive" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, ApplicationServiceTransport): - # transport is a ApplicationServiceTransport instance. - if credentials or client_options.credentials_file or api_key_value: - raise ValueError( - "When providing a transport instance, " - "provide its credentials directly." - ) - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - import google.auth._default # type: ignore - - if api_key_value and hasattr( - google.auth._default, "get_api_key_credentials" - ): - credentials = google.auth._default.get_api_key_credentials( - api_key_value - ) - - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - def create_application( - self, - request: Union[application_service.CreateApplicationRequest, dict] = None, - *, - parent: str = None, - application: gct_application.Application = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_application.Application: - r"""Creates a new application entity. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_create_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - application = talent_v4beta1.Application() - application.external_id = "external_id_value" - application.job = "job_value" - application.stage = "STARTED" - - request = talent_v4beta1.CreateApplicationRequest( - parent="parent_value", - application=application, - ) - - # Make the request - response = client.create_application(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateApplicationRequest, dict]): - The request object. The Request of the CreateApplication - method. - parent (str): - Required. Resource name of the profile under which the - application is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - application (google.cloud.talent_v4beta1.types.Application): - Required. The application to be - created. - - This corresponds to the ``application`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Application: - Resource that represents a job - application record of a candidate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, application]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a application_service.CreateApplicationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, application_service.CreateApplicationRequest): - request = application_service.CreateApplicationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if application is not None: - request.application = application - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_application] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_application( - self, - request: Union[application_service.GetApplicationRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> application.Application: - r"""Retrieves specified application. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_get_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetApplicationRequest( - name="name_value", - ) - - # Make the request - response = client.get_application(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetApplicationRequest, dict]): - The request object. Request for getting a application by - name. - name (str): - Required. The resource name of the application to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". - For example, - "projects/foo/tenants/bar/profiles/baz/applications/qux". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Application: - Resource that represents a job - application record of a candidate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a application_service.GetApplicationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, application_service.GetApplicationRequest): - request = application_service.GetApplicationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_application] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_application( - self, - request: Union[application_service.UpdateApplicationRequest, dict] = None, - *, - application: gct_application.Application = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_application.Application: - r"""Updates specified application. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_update_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - application = talent_v4beta1.Application() - application.external_id = "external_id_value" - application.job = "job_value" - application.stage = "STARTED" - - request = talent_v4beta1.UpdateApplicationRequest( - application=application, - ) - - # Make the request - response = client.update_application(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateApplicationRequest, dict]): - The request object. Request for updating a specified - application. - application (google.cloud.talent_v4beta1.types.Application): - Required. The application resource to - replace the current resource in the - system. - - This corresponds to the ``application`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Application: - Resource that represents a job - application record of a candidate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([application]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a application_service.UpdateApplicationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, application_service.UpdateApplicationRequest): - request = application_service.UpdateApplicationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if application is not None: - request.application = application - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_application] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("application.name", request.application.name),) - ), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_application( - self, - request: Union[application_service.DeleteApplicationRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified application. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_delete_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteApplicationRequest( - name="name_value", - ) - - # Make the request - client.delete_application(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteApplicationRequest, dict]): - The request object. Request to delete a application. - name (str): - Required. The resource name of the application to be - deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". - For example, - "projects/foo/tenants/bar/profiles/baz/applications/qux". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a application_service.DeleteApplicationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, application_service.DeleteApplicationRequest): - request = application_service.DeleteApplicationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_application] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def list_applications( - self, - request: Union[application_service.ListApplicationsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListApplicationsPager: - r"""Lists all applications associated with the profile. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_list_applications(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListApplicationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_applications(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListApplicationsRequest, dict]): - The request object. List applications for which the - client has ACL visibility. - parent (str): - Required. Resource name of the profile under which the - application is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}", - for example, "projects/foo/tenants/bar/profiles/baz". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.services.application_service.pagers.ListApplicationsPager: - The List applications response - object. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a application_service.ListApplicationsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, application_service.ListApplicationsRequest): - request = application_service.ListApplicationsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_applications] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListApplicationsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def __enter__(self): - return self - - def __exit__(self, type, value, traceback): - """Releases underlying transport's resources. - - .. warning:: - ONLY use as a context manager if the transport is NOT shared - with other clients! Exiting the with block will CLOSE the transport - and may cause errors in other clients! - """ - self.transport.close() - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("ApplicationServiceClient",) diff --git a/google/cloud/talent_v4beta1/services/application_service/pagers.py b/google/cloud/talent_v4beta1/services/application_service/pagers.py deleted file mode 100644 index 31c8be33..00000000 --- a/google/cloud/talent_v4beta1/services/application_service/pagers.py +++ /dev/null @@ -1,157 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import ( - Any, - AsyncIterator, - Awaitable, - Callable, - Iterator, - Optional, - Sequence, - Tuple, -) - -from google.cloud.talent_v4beta1.types import application, application_service - - -class ListApplicationsPager: - """A pager for iterating through ``list_applications`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListApplicationsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``applications`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListApplications`` requests and continue to iterate - through the ``applications`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListApplicationsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - - def __init__( - self, - method: Callable[..., application_service.ListApplicationsResponse], - request: application_service.ListApplicationsRequest, - response: application_service.ListApplicationsResponse, - *, - metadata: Sequence[Tuple[str, str]] = () - ): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.talent_v4beta1.types.ListApplicationsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListApplicationsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = application_service.ListApplicationsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[application_service.ListApplicationsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[application.Application]: - for page in self.pages: - yield from page.applications - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) - - -class ListApplicationsAsyncPager: - """A pager for iterating through ``list_applications`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListApplicationsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``applications`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListApplications`` requests and continue to iterate - through the ``applications`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListApplicationsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - - def __init__( - self, - method: Callable[..., Awaitable[application_service.ListApplicationsResponse]], - request: application_service.ListApplicationsRequest, - response: application_service.ListApplicationsResponse, - *, - metadata: Sequence[Tuple[str, str]] = () - ): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.talent_v4beta1.types.ListApplicationsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListApplicationsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = application_service.ListApplicationsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages( - self, - ) -> AsyncIterator[application_service.ListApplicationsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[application.Application]: - async def async_generator(): - async for page in self.pages: - for response in page.applications: - yield response - - return async_generator() - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/cloud/talent_v4beta1/services/application_service/transports/__init__.py b/google/cloud/talent_v4beta1/services/application_service/transports/__init__.py deleted file mode 100644 index 97897959..00000000 --- a/google/cloud/talent_v4beta1/services/application_service/transports/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from typing import Dict, Type - -from .base import ApplicationServiceTransport -from .grpc import ApplicationServiceGrpcTransport -from .grpc_asyncio import ApplicationServiceGrpcAsyncIOTransport - -# Compile a registry of transports. -_transport_registry = ( - OrderedDict() -) # type: Dict[str, Type[ApplicationServiceTransport]] -_transport_registry["grpc"] = ApplicationServiceGrpcTransport -_transport_registry["grpc_asyncio"] = ApplicationServiceGrpcAsyncIOTransport - -__all__ = ( - "ApplicationServiceTransport", - "ApplicationServiceGrpcTransport", - "ApplicationServiceGrpcAsyncIOTransport", -) diff --git a/google/cloud/talent_v4beta1/services/application_service/transports/base.py b/google/cloud/talent_v4beta1/services/application_service/transports/base.py deleted file mode 100644 index f8ca497a..00000000 --- a/google/cloud/talent_v4beta1/services/application_service/transports/base.py +++ /dev/null @@ -1,249 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union - -import google.api_core -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore -from google.protobuf import empty_pb2 # type: ignore -import pkg_resources - -from google.cloud.talent_v4beta1.types import application -from google.cloud.talent_v4beta1.types import application as gct_application -from google.cloud.talent_v4beta1.types import application_service - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -class ApplicationServiceTransport(abc.ABC): - """Abstract transport class for ApplicationService.""" - - AUTH_SCOPES = ( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ) - - DEFAULT_HOST: str = "jobs.googleapis.com" - - def __init__( - self, - *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - """ - - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs( - "'credentials_file' and 'credentials' are mutually exclusive" - ) - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, **scopes_kwargs, quota_project_id=quota_project_id - ) - elif credentials is None: - credentials, _ = google.auth.default( - **scopes_kwargs, quota_project_id=quota_project_id - ) - - # If the credentials are service account credentials, then always try to use self signed JWT. - if ( - always_use_jwt_access - and isinstance(credentials, service_account.Credentials) - and hasattr(service_account.Credentials, "with_always_use_jwt_access") - ): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.create_application: gapic_v1.method.wrap_method( - self.create_application, - default_timeout=30.0, - client_info=client_info, - ), - self.get_application: gapic_v1.method.wrap_method( - self.get_application, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.update_application: gapic_v1.method.wrap_method( - self.update_application, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_application: gapic_v1.method.wrap_method( - self.delete_application, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.list_applications: gapic_v1.method.wrap_method( - self.list_applications, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - } - - def close(self): - """Closes resources associated with the transport. - - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! - """ - raise NotImplementedError() - - @property - def create_application( - self, - ) -> Callable[ - [application_service.CreateApplicationRequest], - Union[gct_application.Application, Awaitable[gct_application.Application]], - ]: - raise NotImplementedError() - - @property - def get_application( - self, - ) -> Callable[ - [application_service.GetApplicationRequest], - Union[application.Application, Awaitable[application.Application]], - ]: - raise NotImplementedError() - - @property - def update_application( - self, - ) -> Callable[ - [application_service.UpdateApplicationRequest], - Union[gct_application.Application, Awaitable[gct_application.Application]], - ]: - raise NotImplementedError() - - @property - def delete_application( - self, - ) -> Callable[ - [application_service.DeleteApplicationRequest], - Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], - ]: - raise NotImplementedError() - - @property - def list_applications( - self, - ) -> Callable[ - [application_service.ListApplicationsRequest], - Union[ - application_service.ListApplicationsResponse, - Awaitable[application_service.ListApplicationsResponse], - ], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ("ApplicationServiceTransport",) diff --git a/google/cloud/talent_v4beta1/services/application_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/application_service/transports/grpc.py deleted file mode 100644 index 30f6d433..00000000 --- a/google/cloud/talent_v4beta1/services/application_service/transports/grpc.py +++ /dev/null @@ -1,378 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable, Dict, Optional, Sequence, Tuple, Union -import warnings - -from google.api_core import gapic_v1, grpc_helpers -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.protobuf import empty_pb2 # type: ignore -import grpc # type: ignore - -from google.cloud.talent_v4beta1.types import application -from google.cloud.talent_v4beta1.types import application as gct_application -from google.cloud.talent_v4beta1.types import application_service - -from .base import DEFAULT_CLIENT_INFO, ApplicationServiceTransport - - -class ApplicationServiceGrpcTransport(ApplicationServiceTransport): - """gRPC backend transport for ApplicationService. - - A service that handles application management, including CRUD - and enumeration. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _stubs: Dict[str, Callable] - - def __init__( - self, - *, - host: str = "jobs.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel( - cls, - host: str = "jobs.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service.""" - return self._grpc_channel - - @property - def create_application( - self, - ) -> Callable[ - [application_service.CreateApplicationRequest], gct_application.Application - ]: - r"""Return a callable for the create application method over gRPC. - - Creates a new application entity. - - Returns: - Callable[[~.CreateApplicationRequest], - ~.Application]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/CreateApplication", - request_serializer=application_service.CreateApplicationRequest.serialize, - response_deserializer=gct_application.Application.deserialize, - ) - return self._stubs["create_application"] - - @property - def get_application( - self, - ) -> Callable[[application_service.GetApplicationRequest], application.Application]: - r"""Return a callable for the get application method over gRPC. - - Retrieves specified application. - - Returns: - Callable[[~.GetApplicationRequest], - ~.Application]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/GetApplication", - request_serializer=application_service.GetApplicationRequest.serialize, - response_deserializer=application.Application.deserialize, - ) - return self._stubs["get_application"] - - @property - def update_application( - self, - ) -> Callable[ - [application_service.UpdateApplicationRequest], gct_application.Application - ]: - r"""Return a callable for the update application method over gRPC. - - Updates specified application. - - Returns: - Callable[[~.UpdateApplicationRequest], - ~.Application]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/UpdateApplication", - request_serializer=application_service.UpdateApplicationRequest.serialize, - response_deserializer=gct_application.Application.deserialize, - ) - return self._stubs["update_application"] - - @property - def delete_application( - self, - ) -> Callable[[application_service.DeleteApplicationRequest], empty_pb2.Empty]: - r"""Return a callable for the delete application method over gRPC. - - Deletes specified application. - - Returns: - Callable[[~.DeleteApplicationRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/DeleteApplication", - request_serializer=application_service.DeleteApplicationRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs["delete_application"] - - @property - def list_applications( - self, - ) -> Callable[ - [application_service.ListApplicationsRequest], - application_service.ListApplicationsResponse, - ]: - r"""Return a callable for the list applications method over gRPC. - - Lists all applications associated with the profile. - - Returns: - Callable[[~.ListApplicationsRequest], - ~.ListApplicationsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/ListApplications", - request_serializer=application_service.ListApplicationsRequest.serialize, - response_deserializer=application_service.ListApplicationsResponse.deserialize, - ) - return self._stubs["list_applications"] - - def close(self): - self.grpc_channel.close() - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ("ApplicationServiceGrpcTransport",) diff --git a/google/cloud/talent_v4beta1/services/application_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/application_service/transports/grpc_asyncio.py deleted file mode 100644 index 1e936ae2..00000000 --- a/google/cloud/talent_v4beta1/services/application_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,383 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -import warnings - -from google.api_core import gapic_v1, grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.protobuf import empty_pb2 # type: ignore -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4beta1.types import application -from google.cloud.talent_v4beta1.types import application as gct_application -from google.cloud.talent_v4beta1.types import application_service - -from .base import DEFAULT_CLIENT_INFO, ApplicationServiceTransport -from .grpc import ApplicationServiceGrpcTransport - - -class ApplicationServiceGrpcAsyncIOTransport(ApplicationServiceTransport): - """gRPC AsyncIO backend transport for ApplicationService. - - A service that handles application management, including CRUD - and enumeration. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel( - cls, - host: str = "jobs.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - def __init__( - self, - *, - host: str = "jobs.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def create_application( - self, - ) -> Callable[ - [application_service.CreateApplicationRequest], - Awaitable[gct_application.Application], - ]: - r"""Return a callable for the create application method over gRPC. - - Creates a new application entity. - - Returns: - Callable[[~.CreateApplicationRequest], - Awaitable[~.Application]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/CreateApplication", - request_serializer=application_service.CreateApplicationRequest.serialize, - response_deserializer=gct_application.Application.deserialize, - ) - return self._stubs["create_application"] - - @property - def get_application( - self, - ) -> Callable[ - [application_service.GetApplicationRequest], Awaitable[application.Application] - ]: - r"""Return a callable for the get application method over gRPC. - - Retrieves specified application. - - Returns: - Callable[[~.GetApplicationRequest], - Awaitable[~.Application]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/GetApplication", - request_serializer=application_service.GetApplicationRequest.serialize, - response_deserializer=application.Application.deserialize, - ) - return self._stubs["get_application"] - - @property - def update_application( - self, - ) -> Callable[ - [application_service.UpdateApplicationRequest], - Awaitable[gct_application.Application], - ]: - r"""Return a callable for the update application method over gRPC. - - Updates specified application. - - Returns: - Callable[[~.UpdateApplicationRequest], - Awaitable[~.Application]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/UpdateApplication", - request_serializer=application_service.UpdateApplicationRequest.serialize, - response_deserializer=gct_application.Application.deserialize, - ) - return self._stubs["update_application"] - - @property - def delete_application( - self, - ) -> Callable[ - [application_service.DeleteApplicationRequest], Awaitable[empty_pb2.Empty] - ]: - r"""Return a callable for the delete application method over gRPC. - - Deletes specified application. - - Returns: - Callable[[~.DeleteApplicationRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/DeleteApplication", - request_serializer=application_service.DeleteApplicationRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs["delete_application"] - - @property - def list_applications( - self, - ) -> Callable[ - [application_service.ListApplicationsRequest], - Awaitable[application_service.ListApplicationsResponse], - ]: - r"""Return a callable for the list applications method over gRPC. - - Lists all applications associated with the profile. - - Returns: - Callable[[~.ListApplicationsRequest], - Awaitable[~.ListApplicationsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ApplicationService/ListApplications", - request_serializer=application_service.ListApplicationsRequest.serialize, - response_deserializer=application_service.ListApplicationsResponse.deserialize, - ) - return self._stubs["list_applications"] - - def close(self): - return self.grpc_channel.close() - - -__all__ = ("ApplicationServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/talent_v4beta1/services/company_service/async_client.py b/google/cloud/talent_v4beta1/services/company_service/async_client.py index 7cb6620e..e82f7dc3 100644 --- a/google/cloud/talent_v4beta1/services/company_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/company_service/async_client.py @@ -31,6 +31,8 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 + from google.cloud.talent_v4beta1.services.company_service import pagers from google.cloud.talent_v4beta1.types import common from google.cloud.talent_v4beta1.types import company @@ -774,6 +776,60 @@ async def sample_list_companies(): # Done; return the response. return response + async def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/talent_v4beta1/services/company_service/client.py b/google/cloud/talent_v4beta1/services/company_service/client.py index 2228d2ec..d085647e 100644 --- a/google/cloud/talent_v4beta1/services/company_service/client.py +++ b/google/cloud/talent_v4beta1/services/company_service/client.py @@ -34,6 +34,8 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 + from google.cloud.talent_v4beta1.services.company_service import pagers from google.cloud.talent_v4beta1.types import common from google.cloud.talent_v4beta1.types import company @@ -430,6 +432,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def create_company( @@ -981,6 +984,60 @@ def __exit__(self, type, value, traceback): """ self.transport.close() + def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/talent_v4beta1/services/company_service/transports/base.py b/google/cloud/talent_v4beta1/services/company_service/transports/base.py index 8498b74b..fe855fd3 100644 --- a/google/cloud/talent_v4beta1/services/company_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/company_service/transports/base.py @@ -22,6 +22,7 @@ from google.api_core import retry as retries import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.longrunning import operations_pb2 from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore import pkg_resources @@ -60,6 +61,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -87,11 +89,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -112,6 +109,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -124,6 +126,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -241,6 +248,15 @@ def list_companies( ]: raise NotImplementedError() + @property + def get_operation( + self, + ) -> Callable[ + [operations_pb2.GetOperationRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py index 796d40b7..eec2e8ad 100644 --- a/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py @@ -20,6 +20,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.longrunning import operations_pb2 from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -61,6 +62,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -156,6 +158,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -367,6 +370,23 @@ def list_companies( def close(self): self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + @property def kind(self) -> str: return "grpc" diff --git a/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py index 040d81d0..dba56956 100644 --- a/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py @@ -19,6 +19,7 @@ from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.longrunning import operations_pb2 from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -106,6 +107,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -201,6 +203,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -375,5 +378,22 @@ def list_companies( def close(self): return self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + __all__ = ("CompanyServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/talent_v4beta1/services/completion/async_client.py b/google/cloud/talent_v4beta1/services/completion/async_client.py index 0eacec76..c8c6c1c5 100644 --- a/google/cloud/talent_v4beta1/services/completion/async_client.py +++ b/google/cloud/talent_v4beta1/services/completion/async_client.py @@ -31,6 +31,8 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 + from google.cloud.talent_v4beta1.types import common, completion_service from .client import CompletionClient @@ -280,6 +282,60 @@ async def sample_complete_query(): # Done; return the response. return response + async def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/talent_v4beta1/services/completion/client.py b/google/cloud/talent_v4beta1/services/completion/client.py index 94742550..190bda85 100644 --- a/google/cloud/talent_v4beta1/services/completion/client.py +++ b/google/cloud/talent_v4beta1/services/completion/client.py @@ -34,6 +34,8 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 + from google.cloud.talent_v4beta1.types import common, completion_service from .transports.base import DEFAULT_CLIENT_INFO, CompletionTransport @@ -422,6 +424,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def complete_query( @@ -512,6 +515,60 @@ def __exit__(self, type, value, traceback): """ self.transport.close() + def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/talent_v4beta1/services/completion/transports/base.py b/google/cloud/talent_v4beta1/services/completion/transports/base.py index f988e063..618bfa06 100644 --- a/google/cloud/talent_v4beta1/services/completion/transports/base.py +++ b/google/cloud/talent_v4beta1/services/completion/transports/base.py @@ -22,6 +22,7 @@ from google.api_core import retry as retries import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.longrunning import operations_pb2 from google.oauth2 import service_account # type: ignore import pkg_resources @@ -57,6 +58,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -84,11 +86,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -109,6 +106,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -121,6 +123,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -162,6 +169,15 @@ def complete_query( ]: raise NotImplementedError() + @property + def get_operation( + self, + ) -> Callable[ + [operations_pb2.GetOperationRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/google/cloud/talent_v4beta1/services/completion/transports/grpc.py b/google/cloud/talent_v4beta1/services/completion/transports/grpc.py index 0b0e3c19..281b74e5 100644 --- a/google/cloud/talent_v4beta1/services/completion/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/completion/transports/grpc.py @@ -20,6 +20,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.longrunning import operations_pb2 import grpc # type: ignore from google.cloud.talent_v4beta1.types import completion_service @@ -57,6 +58,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -152,6 +154,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -260,6 +263,23 @@ def complete_query( def close(self): self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + @property def kind(self) -> str: return "grpc" diff --git a/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py index b3fae966..a8172a81 100644 --- a/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py @@ -19,6 +19,7 @@ from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.longrunning import operations_pb2 import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -102,6 +103,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -197,6 +199,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -263,5 +266,22 @@ def complete_query( def close(self): return self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + __all__ = ("CompletionGrpcAsyncIOTransport",) diff --git a/google/cloud/talent_v4beta1/services/event_service/async_client.py b/google/cloud/talent_v4beta1/services/event_service/async_client.py index 12c16f8a..1dd41df2 100644 --- a/google/cloud/talent_v4beta1/services/event_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/event_service/async_client.py @@ -31,6 +31,7 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.talent_v4beta1.types import event, event_service @@ -331,6 +332,60 @@ async def sample_create_client_event(): # Done; return the response. return response + async def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/talent_v4beta1/services/event_service/client.py b/google/cloud/talent_v4beta1/services/event_service/client.py index 914eb6fe..a9f42e74 100644 --- a/google/cloud/talent_v4beta1/services/event_service/client.py +++ b/google/cloud/talent_v4beta1/services/event_service/client.py @@ -34,6 +34,7 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.talent_v4beta1.types import event, event_service @@ -424,6 +425,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def create_client_event( @@ -570,6 +572,60 @@ def __exit__(self, type, value, traceback): """ self.transport.close() + def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/talent_v4beta1/services/event_service/transports/base.py b/google/cloud/talent_v4beta1/services/event_service/transports/base.py index 3bb46a7b..d50606b5 100644 --- a/google/cloud/talent_v4beta1/services/event_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/event_service/transports/base.py @@ -22,6 +22,7 @@ from google.api_core import retry as retries import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.longrunning import operations_pb2 from google.oauth2 import service_account # type: ignore import pkg_resources @@ -57,6 +58,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -84,11 +86,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -109,6 +106,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -121,6 +123,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -149,6 +156,15 @@ def create_client_event( ]: raise NotImplementedError() + @property + def get_operation( + self, + ) -> Callable[ + [operations_pb2.GetOperationRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py index 4dfbdd08..da2ce3fa 100644 --- a/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py @@ -20,6 +20,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.longrunning import operations_pb2 import grpc # type: ignore from google.cloud.talent_v4beta1.types import event, event_service @@ -57,6 +58,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -152,6 +154,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -261,6 +264,23 @@ def create_client_event( def close(self): self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + @property def kind(self) -> str: return "grpc" diff --git a/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py index 78fc17bd..dadb04f0 100644 --- a/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py @@ -19,6 +19,7 @@ from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.longrunning import operations_pb2 import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -102,6 +103,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -197,6 +199,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -266,5 +269,22 @@ def create_client_event( def close(self): return self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + __all__ = ("EventServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/talent_v4beta1/services/job_service/async_client.py b/google/cloud/talent_v4beta1/services/job_service/async_client.py index 4c2af6c7..48a59d43 100644 --- a/google/cloud/talent_v4beta1/services/job_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/job_service/async_client.py @@ -33,6 +33,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore +from google.longrunning import operations_pb2 from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.talent_v4beta1.services.job_service import pagers @@ -1074,11 +1075,14 @@ async def sample_list_jobs(): The fields eligible for filtering are: - - ``companyName`` (Required) + - ``companyName`` - ``requisitionId`` - ``status`` Available values: OPEN, EXPIRED, ALL. Defaults to OPEN if no value is specified. + At least one of ``companyName`` and ``requisitionId`` + must present or an INVALID_ARGUMENT error is thrown. + Sample Query: - companyName = @@ -1089,6 +1093,8 @@ async def sample_list_jobs(): - companyName = "projects/foo/tenants/bar/companies/baz" AND status = "EXPIRED" + - requisitionId = "req-1" + - requisitionId = "req-1" AND status = "EXPIRED" This corresponds to the ``filter`` field on the ``request`` instance; if ``request`` is provided, this @@ -1358,6 +1364,60 @@ async def sample_search_jobs_for_alert(): # Done; return the response. return response + async def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/talent_v4beta1/services/job_service/client.py b/google/cloud/talent_v4beta1/services/job_service/client.py index f63a2cd2..cb861532 100644 --- a/google/cloud/talent_v4beta1/services/job_service/client.py +++ b/google/cloud/talent_v4beta1/services/job_service/client.py @@ -36,6 +36,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore +from google.longrunning import operations_pb2 from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.talent_v4beta1.services.job_service import pagers @@ -454,6 +455,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def create_job( @@ -1302,11 +1304,14 @@ def sample_list_jobs(): The fields eligible for filtering are: - - ``companyName`` (Required) + - ``companyName`` - ``requisitionId`` - ``status`` Available values: OPEN, EXPIRED, ALL. Defaults to OPEN if no value is specified. + At least one of ``companyName`` and ``requisitionId`` + must present or an INVALID_ARGUMENT error is thrown. + Sample Query: - companyName = @@ -1317,6 +1322,8 @@ def sample_list_jobs(): - companyName = "projects/foo/tenants/bar/companies/baz" AND status = "EXPIRED" + - requisitionId = "req-1" + - requisitionId = "req-1" AND status = "EXPIRED" This corresponds to the ``filter`` field on the ``request`` instance; if ``request`` is provided, this @@ -1591,6 +1598,60 @@ def __exit__(self, type, value, traceback): """ self.transport.close() + def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/talent_v4beta1/services/job_service/transports/base.py b/google/cloud/talent_v4beta1/services/job_service/transports/base.py index 8847c535..6fe2df8b 100644 --- a/google/cloud/talent_v4beta1/services/job_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/job_service/transports/base.py @@ -61,6 +61,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -88,11 +89,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -113,6 +109,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -125,6 +126,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -313,6 +319,15 @@ def search_jobs_for_alert( ]: raise NotImplementedError() + @property + def get_operation( + self, + ) -> Callable[ + [operations_pb2.GetOperationRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py index 48296d44..2a4baf5a 100644 --- a/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py @@ -62,6 +62,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -158,6 +159,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -528,6 +530,23 @@ def search_jobs_for_alert( def close(self): self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + @property def kind(self) -> str: return "grpc" diff --git a/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py index 708460a5..acd49fc4 100644 --- a/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py @@ -107,6 +107,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -203,6 +204,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -549,5 +551,22 @@ def search_jobs_for_alert( def close(self): return self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + __all__ = ("JobServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/talent_v4beta1/services/profile_service/__init__.py b/google/cloud/talent_v4beta1/services/profile_service/__init__.py deleted file mode 100644 index 79f99f9b..00000000 --- a/google/cloud/talent_v4beta1/services/profile_service/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .async_client import ProfileServiceAsyncClient -from .client import ProfileServiceClient - -__all__ = ( - "ProfileServiceClient", - "ProfileServiceAsyncClient", -) diff --git a/google/cloud/talent_v4beta1/services/profile_service/async_client.py b/google/cloud/talent_v4beta1/services/profile_service/async_client.py deleted file mode 100644 index 7d28c354..00000000 --- a/google/cloud/talent_v4beta1/services/profile_service/async_client.py +++ /dev/null @@ -1,856 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import functools -import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union - -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core.client_options import ClientOptions -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore -import pkg_resources - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore - -from google.cloud.talent_v4beta1.services.profile_service import pagers -from google.cloud.talent_v4beta1.types import common, histogram -from google.cloud.talent_v4beta1.types import profile -from google.cloud.talent_v4beta1.types import profile as gct_profile -from google.cloud.talent_v4beta1.types import profile_service - -from .client import ProfileServiceClient -from .transports.base import DEFAULT_CLIENT_INFO, ProfileServiceTransport -from .transports.grpc_asyncio import ProfileServiceGrpcAsyncIOTransport - - -class ProfileServiceAsyncClient: - """A service that handles profile management, including profile - CRUD, enumeration and search. - """ - - _client: ProfileServiceClient - - DEFAULT_ENDPOINT = ProfileServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = ProfileServiceClient.DEFAULT_MTLS_ENDPOINT - - profile_path = staticmethod(ProfileServiceClient.profile_path) - parse_profile_path = staticmethod(ProfileServiceClient.parse_profile_path) - tenant_path = staticmethod(ProfileServiceClient.tenant_path) - parse_tenant_path = staticmethod(ProfileServiceClient.parse_tenant_path) - common_billing_account_path = staticmethod( - ProfileServiceClient.common_billing_account_path - ) - parse_common_billing_account_path = staticmethod( - ProfileServiceClient.parse_common_billing_account_path - ) - common_folder_path = staticmethod(ProfileServiceClient.common_folder_path) - parse_common_folder_path = staticmethod( - ProfileServiceClient.parse_common_folder_path - ) - common_organization_path = staticmethod( - ProfileServiceClient.common_organization_path - ) - parse_common_organization_path = staticmethod( - ProfileServiceClient.parse_common_organization_path - ) - common_project_path = staticmethod(ProfileServiceClient.common_project_path) - parse_common_project_path = staticmethod( - ProfileServiceClient.parse_common_project_path - ) - common_location_path = staticmethod(ProfileServiceClient.common_location_path) - parse_common_location_path = staticmethod( - ProfileServiceClient.parse_common_location_path - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ProfileServiceAsyncClient: The constructed client. - """ - return ProfileServiceClient.from_service_account_info.__func__(ProfileServiceAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ProfileServiceAsyncClient: The constructed client. - """ - return ProfileServiceClient.from_service_account_file.__func__(ProfileServiceAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @classmethod - def get_mtls_endpoint_and_cert_source( - cls, client_options: Optional[ClientOptions] = None - ): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variabel is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - return ProfileServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> ProfileServiceTransport: - """Returns the transport used by the client instance. - - Returns: - ProfileServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial( - type(ProfileServiceClient).get_transport_class, type(ProfileServiceClient) - ) - - def __init__( - self, - *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, ProfileServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the profile service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.ProfileServiceTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = ProfileServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - ) - - async def list_profiles( - self, - request: Union[profile_service.ListProfilesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListProfilesAsyncPager: - r"""Lists profiles by filter. The order is unspecified. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_list_profiles(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListProfilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_profiles(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListProfilesRequest, dict]): - The request object. List profiles request. - parent (:class:`str`): - Required. The resource name of the tenant under which - the profile is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenants/bar". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.services.profile_service.pagers.ListProfilesAsyncPager: - The List profiles response object. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = profile_service.ListProfilesRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_profiles, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListProfilesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_profile( - self, - request: Union[profile_service.CreateProfileRequest, dict] = None, - *, - parent: str = None, - profile: gct_profile.Profile = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_profile.Profile: - r"""Creates and returns a new profile. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_create_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.CreateProfileRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_profile(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateProfileRequest, dict]): - The request object. Create profile request. - parent (:class:`str`): - Required. The name of the tenant this profile belongs - to. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenants/bar". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - profile (:class:`google.cloud.talent_v4beta1.types.Profile`): - Required. The profile to be created. - This corresponds to the ``profile`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Profile: - A resource that represents the - profile for a job candidate (also - referred to as a "single-source - profile"). - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, profile]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = profile_service.CreateProfileRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if profile is not None: - request.profile = profile - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_profile, - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_profile( - self, - request: Union[profile_service.GetProfileRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> profile.Profile: - r"""Gets the specified profile. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_get_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetProfileRequest( - name="name_value", - ) - - # Make the request - response = await client.get_profile(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetProfileRequest, dict]): - The request object. Get profile request. - name (:class:`str`): - Required. Resource name of the profile to get. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Profile: - A resource that represents the - profile for a job candidate (also - referred to as a "single-source - profile"). - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = profile_service.GetProfileRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_profile, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_profile( - self, - request: Union[profile_service.UpdateProfileRequest, dict] = None, - *, - profile: gct_profile.Profile = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_profile.Profile: - r"""Updates the specified profile and returns the updated - result. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_update_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.UpdateProfileRequest( - ) - - # Make the request - response = await client.update_profile(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateProfileRequest, dict]): - The request object. Update profile request - profile (:class:`google.cloud.talent_v4beta1.types.Profile`): - Required. Profile to be updated. - This corresponds to the ``profile`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Profile: - A resource that represents the - profile for a job candidate (also - referred to as a "single-source - profile"). - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([profile]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = profile_service.UpdateProfileRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if profile is not None: - request.profile = profile - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_profile, - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("profile.name", request.profile.name),) - ), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_profile( - self, - request: Union[profile_service.DeleteProfileRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes the specified profile. - Prerequisite: The profile has no associated applications - or assignments associated. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_delete_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteProfileRequest( - name="name_value", - ) - - # Make the request - await client.delete_profile(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteProfileRequest, dict]): - The request object. Delete profile request. - name (:class:`str`): - Required. Resource name of the profile to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = profile_service.DeleteProfileRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.delete_profile, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def search_profiles( - self, - request: Union[profile_service.SearchProfilesRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.SearchProfilesAsyncPager: - r"""Searches for profiles within a tenant. - - For example, search by raw queries "software engineer in - Mountain View" or search by structured filters (location filter, - education filter, etc.). - - See - [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest] - for more information. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - async def sample_search_profiles(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchProfilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_profiles(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.SearchProfilesRequest, dict]): - The request object. The request body of the - `SearchProfiles` call. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.services.profile_service.pagers.SearchProfilesAsyncPager: - Response of SearchProfiles method. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = profile_service.SearchProfilesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.search_profiles, - default_timeout=30.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.SearchProfilesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def __aenter__(self): - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("ProfileServiceAsyncClient",) diff --git a/google/cloud/talent_v4beta1/services/profile_service/client.py b/google/cloud/talent_v4beta1/services/profile_service/client.py deleted file mode 100644 index 820ac697..00000000 --- a/google/cloud/talent_v4beta1/services/profile_service/client.py +++ /dev/null @@ -1,1073 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import os -import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union - -from google.api_core import client_options as client_options_lib -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.oauth2 import service_account # type: ignore -import pkg_resources - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore - -from google.cloud.talent_v4beta1.services.profile_service import pagers -from google.cloud.talent_v4beta1.types import common, histogram -from google.cloud.talent_v4beta1.types import profile -from google.cloud.talent_v4beta1.types import profile as gct_profile -from google.cloud.talent_v4beta1.types import profile_service - -from .transports.base import DEFAULT_CLIENT_INFO, ProfileServiceTransport -from .transports.grpc import ProfileServiceGrpcTransport -from .transports.grpc_asyncio import ProfileServiceGrpcAsyncIOTransport - - -class ProfileServiceClientMeta(type): - """Metaclass for the ProfileService client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - - _transport_registry = ( - OrderedDict() - ) # type: Dict[str, Type[ProfileServiceTransport]] - _transport_registry["grpc"] = ProfileServiceGrpcTransport - _transport_registry["grpc_asyncio"] = ProfileServiceGrpcAsyncIOTransport - - def get_transport_class( - cls, - label: str = None, - ) -> Type[ProfileServiceTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class ProfileServiceClient(metaclass=ProfileServiceClientMeta): - """A service that handles profile management, including profile - CRUD, enumeration and search. - """ - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - DEFAULT_ENDPOINT = "jobs.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ProfileServiceClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ProfileServiceClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file(filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> ProfileServiceTransport: - """Returns the transport used by the client instance. - - Returns: - ProfileServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def profile_path( - project: str, - tenant: str, - profile: str, - ) -> str: - """Returns a fully-qualified profile string.""" - return "projects/{project}/tenants/{tenant}/profiles/{profile}".format( - project=project, - tenant=tenant, - profile=profile, - ) - - @staticmethod - def parse_profile_path(path: str) -> Dict[str, str]: - """Parses a profile path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/tenants/(?P.+?)/profiles/(?P.+?)$", - path, - ) - return m.groupdict() if m else {} - - @staticmethod - def tenant_path( - project: str, - tenant: str, - ) -> str: - """Returns a fully-qualified tenant string.""" - return "projects/{project}/tenants/{tenant}".format( - project=project, - tenant=tenant, - ) - - @staticmethod - def parse_tenant_path(path: str) -> Dict[str, str]: - """Parses a tenant path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/tenants/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_billing_account_path( - billing_account: str, - ) -> str: - """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format( - billing_account=billing_account, - ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str, str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path( - folder: str, - ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format( - folder=folder, - ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str, str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path( - organization: str, - ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format( - organization=organization, - ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str, str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path( - project: str, - ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format( - project=project, - ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str, str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_location_path( - project: str, - location: str, - ) -> str: - """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format( - project=project, - location=location, - ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str, str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @classmethod - def get_mtls_endpoint_and_cert_source( - cls, client_options: Optional[client_options_lib.ClientOptions] = None - ): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variabel is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - if client_options is None: - client_options = client_options_lib.ClientOptions() - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_client_cert not in ("true", "false"): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError( - "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - ) - - # Figure out the client cert source to use. - client_cert_source = None - if use_client_cert == "true": - if client_options.client_cert_source: - client_cert_source = client_options.client_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - elif use_mtls_endpoint == "always" or ( - use_mtls_endpoint == "auto" and client_cert_source - ): - api_endpoint = cls.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = cls.DEFAULT_ENDPOINT - - return api_endpoint, client_cert_source - - def __init__( - self, - *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, ProfileServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the profile service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ProfileServiceTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - - api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( - client_options - ) - - api_key_value = getattr(client_options, "api_key", None) - if api_key_value and credentials: - raise ValueError( - "client_options.api_key and credentials are mutually exclusive" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, ProfileServiceTransport): - # transport is a ProfileServiceTransport instance. - if credentials or client_options.credentials_file or api_key_value: - raise ValueError( - "When providing a transport instance, " - "provide its credentials directly." - ) - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - import google.auth._default # type: ignore - - if api_key_value and hasattr( - google.auth._default, "get_api_key_credentials" - ): - credentials = google.auth._default.get_api_key_credentials( - api_key_value - ) - - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - def list_profiles( - self, - request: Union[profile_service.ListProfilesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListProfilesPager: - r"""Lists profiles by filter. The order is unspecified. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_list_profiles(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListProfilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_profiles(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListProfilesRequest, dict]): - The request object. List profiles request. - parent (str): - Required. The resource name of the tenant under which - the profile is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenants/bar". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.services.profile_service.pagers.ListProfilesPager: - The List profiles response object. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a profile_service.ListProfilesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, profile_service.ListProfilesRequest): - request = profile_service.ListProfilesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_profiles] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListProfilesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_profile( - self, - request: Union[profile_service.CreateProfileRequest, dict] = None, - *, - parent: str = None, - profile: gct_profile.Profile = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_profile.Profile: - r"""Creates and returns a new profile. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_create_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.CreateProfileRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_profile(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateProfileRequest, dict]): - The request object. Create profile request. - parent (str): - Required. The name of the tenant this profile belongs - to. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenants/bar". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - profile (google.cloud.talent_v4beta1.types.Profile): - Required. The profile to be created. - This corresponds to the ``profile`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Profile: - A resource that represents the - profile for a job candidate (also - referred to as a "single-source - profile"). - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, profile]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a profile_service.CreateProfileRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, profile_service.CreateProfileRequest): - request = profile_service.CreateProfileRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if profile is not None: - request.profile = profile - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_profile] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_profile( - self, - request: Union[profile_service.GetProfileRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> profile.Profile: - r"""Gets the specified profile. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_get_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetProfileRequest( - name="name_value", - ) - - # Make the request - response = client.get_profile(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetProfileRequest, dict]): - The request object. Get profile request. - name (str): - Required. Resource name of the profile to get. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Profile: - A resource that represents the - profile for a job candidate (also - referred to as a "single-source - profile"). - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a profile_service.GetProfileRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, profile_service.GetProfileRequest): - request = profile_service.GetProfileRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_profile] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_profile( - self, - request: Union[profile_service.UpdateProfileRequest, dict] = None, - *, - profile: gct_profile.Profile = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_profile.Profile: - r"""Updates the specified profile and returns the updated - result. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_update_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.UpdateProfileRequest( - ) - - # Make the request - response = client.update_profile(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateProfileRequest, dict]): - The request object. Update profile request - profile (google.cloud.talent_v4beta1.types.Profile): - Required. Profile to be updated. - This corresponds to the ``profile`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.types.Profile: - A resource that represents the - profile for a job candidate (also - referred to as a "single-source - profile"). - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([profile]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a profile_service.UpdateProfileRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, profile_service.UpdateProfileRequest): - request = profile_service.UpdateProfileRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if profile is not None: - request.profile = profile - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_profile] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("profile.name", request.profile.name),) - ), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_profile( - self, - request: Union[profile_service.DeleteProfileRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes the specified profile. - Prerequisite: The profile has no associated applications - or assignments associated. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_delete_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteProfileRequest( - name="name_value", - ) - - # Make the request - client.delete_profile(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteProfileRequest, dict]): - The request object. Delete profile request. - name (str): - Required. Resource name of the profile to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a profile_service.DeleteProfileRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, profile_service.DeleteProfileRequest): - request = profile_service.DeleteProfileRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_profile] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def search_profiles( - self, - request: Union[profile_service.SearchProfilesRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.SearchProfilesPager: - r"""Searches for profiles within a tenant. - - For example, search by raw queries "software engineer in - Mountain View" or search by structured filters (location filter, - education filter, etc.). - - See - [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest] - for more information. - - .. code-block:: python - - from google.cloud import talent_v4beta1 - - def sample_search_profiles(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchProfilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_profiles(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.SearchProfilesRequest, dict]): - The request object. The request body of the - `SearchProfiles` call. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.talent_v4beta1.services.profile_service.pagers.SearchProfilesPager: - Response of SearchProfiles method. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a profile_service.SearchProfilesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, profile_service.SearchProfilesRequest): - request = profile_service.SearchProfilesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.search_profiles] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.SearchProfilesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def __enter__(self): - return self - - def __exit__(self, type, value, traceback): - """Releases underlying transport's resources. - - .. warning:: - ONLY use as a context manager if the transport is NOT shared - with other clients! Exiting the with block will CLOSE the transport - and may cause errors in other clients! - """ - self.transport.close() - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ("ProfileServiceClient",) diff --git a/google/cloud/talent_v4beta1/services/profile_service/pagers.py b/google/cloud/talent_v4beta1/services/profile_service/pagers.py deleted file mode 100644 index a979d99c..00000000 --- a/google/cloud/talent_v4beta1/services/profile_service/pagers.py +++ /dev/null @@ -1,283 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import ( - Any, - AsyncIterator, - Awaitable, - Callable, - Iterator, - Optional, - Sequence, - Tuple, -) - -from google.cloud.talent_v4beta1.types import histogram, profile, profile_service - - -class ListProfilesPager: - """A pager for iterating through ``list_profiles`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListProfilesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``profiles`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListProfiles`` requests and continue to iterate - through the ``profiles`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListProfilesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - - def __init__( - self, - method: Callable[..., profile_service.ListProfilesResponse], - request: profile_service.ListProfilesRequest, - response: profile_service.ListProfilesResponse, - *, - metadata: Sequence[Tuple[str, str]] = () - ): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.talent_v4beta1.types.ListProfilesRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListProfilesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = profile_service.ListProfilesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[profile_service.ListProfilesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[profile.Profile]: - for page in self.pages: - yield from page.profiles - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) - - -class ListProfilesAsyncPager: - """A pager for iterating through ``list_profiles`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListProfilesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``profiles`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListProfiles`` requests and continue to iterate - through the ``profiles`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListProfilesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - - def __init__( - self, - method: Callable[..., Awaitable[profile_service.ListProfilesResponse]], - request: profile_service.ListProfilesRequest, - response: profile_service.ListProfilesResponse, - *, - metadata: Sequence[Tuple[str, str]] = () - ): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.talent_v4beta1.types.ListProfilesRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListProfilesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = profile_service.ListProfilesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[profile_service.ListProfilesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[profile.Profile]: - async def async_generator(): - async for page in self.pages: - for response in page.profiles: - yield response - - return async_generator() - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) - - -class SearchProfilesPager: - """A pager for iterating through ``search_profiles`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.SearchProfilesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``histogram_query_results`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``SearchProfiles`` requests and continue to iterate - through the ``histogram_query_results`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.SearchProfilesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - - def __init__( - self, - method: Callable[..., profile_service.SearchProfilesResponse], - request: profile_service.SearchProfilesRequest, - response: profile_service.SearchProfilesResponse, - *, - metadata: Sequence[Tuple[str, str]] = () - ): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.talent_v4beta1.types.SearchProfilesRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.SearchProfilesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = profile_service.SearchProfilesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[profile_service.SearchProfilesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[histogram.HistogramQueryResult]: - for page in self.pages: - yield from page.histogram_query_results - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) - - -class SearchProfilesAsyncPager: - """A pager for iterating through ``search_profiles`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.SearchProfilesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``histogram_query_results`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``SearchProfiles`` requests and continue to iterate - through the ``histogram_query_results`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.SearchProfilesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - - def __init__( - self, - method: Callable[..., Awaitable[profile_service.SearchProfilesResponse]], - request: profile_service.SearchProfilesRequest, - response: profile_service.SearchProfilesResponse, - *, - metadata: Sequence[Tuple[str, str]] = () - ): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.talent_v4beta1.types.SearchProfilesRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.SearchProfilesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = profile_service.SearchProfilesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[profile_service.SearchProfilesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[histogram.HistogramQueryResult]: - async def async_generator(): - async for page in self.pages: - for response in page.histogram_query_results: - yield response - - return async_generator() - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/cloud/talent_v4beta1/services/profile_service/transports/__init__.py b/google/cloud/talent_v4beta1/services/profile_service/transports/__init__.py deleted file mode 100644 index f46de9fa..00000000 --- a/google/cloud/talent_v4beta1/services/profile_service/transports/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from typing import Dict, Type - -from .base import ProfileServiceTransport -from .grpc import ProfileServiceGrpcTransport -from .grpc_asyncio import ProfileServiceGrpcAsyncIOTransport - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[ProfileServiceTransport]] -_transport_registry["grpc"] = ProfileServiceGrpcTransport -_transport_registry["grpc_asyncio"] = ProfileServiceGrpcAsyncIOTransport - -__all__ = ( - "ProfileServiceTransport", - "ProfileServiceGrpcTransport", - "ProfileServiceGrpcAsyncIOTransport", -) diff --git a/google/cloud/talent_v4beta1/services/profile_service/transports/base.py b/google/cloud/talent_v4beta1/services/profile_service/transports/base.py deleted file mode 100644 index b6f77bb6..00000000 --- a/google/cloud/talent_v4beta1/services/profile_service/transports/base.py +++ /dev/null @@ -1,266 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union - -import google.api_core -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore -from google.protobuf import empty_pb2 # type: ignore -import pkg_resources - -from google.cloud.talent_v4beta1.types import profile -from google.cloud.talent_v4beta1.types import profile as gct_profile -from google.cloud.talent_v4beta1.types import profile_service - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -class ProfileServiceTransport(abc.ABC): - """Abstract transport class for ProfileService.""" - - AUTH_SCOPES = ( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ) - - DEFAULT_HOST: str = "jobs.googleapis.com" - - def __init__( - self, - *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - """ - - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs( - "'credentials_file' and 'credentials' are mutually exclusive" - ) - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, **scopes_kwargs, quota_project_id=quota_project_id - ) - elif credentials is None: - credentials, _ = google.auth.default( - **scopes_kwargs, quota_project_id=quota_project_id - ) - - # If the credentials are service account credentials, then always try to use self signed JWT. - if ( - always_use_jwt_access - and isinstance(credentials, service_account.Credentials) - and hasattr(service_account.Credentials, "with_always_use_jwt_access") - ): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.list_profiles: gapic_v1.method.wrap_method( - self.list_profiles, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.create_profile: gapic_v1.method.wrap_method( - self.create_profile, - default_timeout=30.0, - client_info=client_info, - ), - self.get_profile: gapic_v1.method.wrap_method( - self.get_profile, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.update_profile: gapic_v1.method.wrap_method( - self.update_profile, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_profile: gapic_v1.method.wrap_method( - self.delete_profile, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.search_profiles: gapic_v1.method.wrap_method( - self.search_profiles, - default_timeout=30.0, - client_info=client_info, - ), - } - - def close(self): - """Closes resources associated with the transport. - - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! - """ - raise NotImplementedError() - - @property - def list_profiles( - self, - ) -> Callable[ - [profile_service.ListProfilesRequest], - Union[ - profile_service.ListProfilesResponse, - Awaitable[profile_service.ListProfilesResponse], - ], - ]: - raise NotImplementedError() - - @property - def create_profile( - self, - ) -> Callable[ - [profile_service.CreateProfileRequest], - Union[gct_profile.Profile, Awaitable[gct_profile.Profile]], - ]: - raise NotImplementedError() - - @property - def get_profile( - self, - ) -> Callable[ - [profile_service.GetProfileRequest], - Union[profile.Profile, Awaitable[profile.Profile]], - ]: - raise NotImplementedError() - - @property - def update_profile( - self, - ) -> Callable[ - [profile_service.UpdateProfileRequest], - Union[gct_profile.Profile, Awaitable[gct_profile.Profile]], - ]: - raise NotImplementedError() - - @property - def delete_profile( - self, - ) -> Callable[ - [profile_service.DeleteProfileRequest], - Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], - ]: - raise NotImplementedError() - - @property - def search_profiles( - self, - ) -> Callable[ - [profile_service.SearchProfilesRequest], - Union[ - profile_service.SearchProfilesResponse, - Awaitable[profile_service.SearchProfilesResponse], - ], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ("ProfileServiceTransport",) diff --git a/google/cloud/talent_v4beta1/services/profile_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/profile_service/transports/grpc.py deleted file mode 100644 index b29bbe6f..00000000 --- a/google/cloud/talent_v4beta1/services/profile_service/transports/grpc.py +++ /dev/null @@ -1,412 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable, Dict, Optional, Sequence, Tuple, Union -import warnings - -from google.api_core import gapic_v1, grpc_helpers -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.protobuf import empty_pb2 # type: ignore -import grpc # type: ignore - -from google.cloud.talent_v4beta1.types import profile -from google.cloud.talent_v4beta1.types import profile as gct_profile -from google.cloud.talent_v4beta1.types import profile_service - -from .base import DEFAULT_CLIENT_INFO, ProfileServiceTransport - - -class ProfileServiceGrpcTransport(ProfileServiceTransport): - """gRPC backend transport for ProfileService. - - A service that handles profile management, including profile - CRUD, enumeration and search. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _stubs: Dict[str, Callable] - - def __init__( - self, - *, - host: str = "jobs.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel( - cls, - host: str = "jobs.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service.""" - return self._grpc_channel - - @property - def list_profiles( - self, - ) -> Callable[ - [profile_service.ListProfilesRequest], profile_service.ListProfilesResponse - ]: - r"""Return a callable for the list profiles method over gRPC. - - Lists profiles by filter. The order is unspecified. - - Returns: - Callable[[~.ListProfilesRequest], - ~.ListProfilesResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "list_profiles" not in self._stubs: - self._stubs["list_profiles"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/ListProfiles", - request_serializer=profile_service.ListProfilesRequest.serialize, - response_deserializer=profile_service.ListProfilesResponse.deserialize, - ) - return self._stubs["list_profiles"] - - @property - def create_profile( - self, - ) -> Callable[[profile_service.CreateProfileRequest], gct_profile.Profile]: - r"""Return a callable for the create profile method over gRPC. - - Creates and returns a new profile. - - Returns: - Callable[[~.CreateProfileRequest], - ~.Profile]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_profile" not in self._stubs: - self._stubs["create_profile"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/CreateProfile", - request_serializer=profile_service.CreateProfileRequest.serialize, - response_deserializer=gct_profile.Profile.deserialize, - ) - return self._stubs["create_profile"] - - @property - def get_profile( - self, - ) -> Callable[[profile_service.GetProfileRequest], profile.Profile]: - r"""Return a callable for the get profile method over gRPC. - - Gets the specified profile. - - Returns: - Callable[[~.GetProfileRequest], - ~.Profile]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "get_profile" not in self._stubs: - self._stubs["get_profile"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/GetProfile", - request_serializer=profile_service.GetProfileRequest.serialize, - response_deserializer=profile.Profile.deserialize, - ) - return self._stubs["get_profile"] - - @property - def update_profile( - self, - ) -> Callable[[profile_service.UpdateProfileRequest], gct_profile.Profile]: - r"""Return a callable for the update profile method over gRPC. - - Updates the specified profile and returns the updated - result. - - Returns: - Callable[[~.UpdateProfileRequest], - ~.Profile]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_profile" not in self._stubs: - self._stubs["update_profile"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/UpdateProfile", - request_serializer=profile_service.UpdateProfileRequest.serialize, - response_deserializer=gct_profile.Profile.deserialize, - ) - return self._stubs["update_profile"] - - @property - def delete_profile( - self, - ) -> Callable[[profile_service.DeleteProfileRequest], empty_pb2.Empty]: - r"""Return a callable for the delete profile method over gRPC. - - Deletes the specified profile. - Prerequisite: The profile has no associated applications - or assignments associated. - - Returns: - Callable[[~.DeleteProfileRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_profile" not in self._stubs: - self._stubs["delete_profile"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/DeleteProfile", - request_serializer=profile_service.DeleteProfileRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs["delete_profile"] - - @property - def search_profiles( - self, - ) -> Callable[ - [profile_service.SearchProfilesRequest], profile_service.SearchProfilesResponse - ]: - r"""Return a callable for the search profiles method over gRPC. - - Searches for profiles within a tenant. - - For example, search by raw queries "software engineer in - Mountain View" or search by structured filters (location filter, - education filter, etc.). - - See - [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest] - for more information. - - Returns: - Callable[[~.SearchProfilesRequest], - ~.SearchProfilesResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "search_profiles" not in self._stubs: - self._stubs["search_profiles"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/SearchProfiles", - request_serializer=profile_service.SearchProfilesRequest.serialize, - response_deserializer=profile_service.SearchProfilesResponse.deserialize, - ) - return self._stubs["search_profiles"] - - def close(self): - self.grpc_channel.close() - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ("ProfileServiceGrpcTransport",) diff --git a/google/cloud/talent_v4beta1/services/profile_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/profile_service/transports/grpc_asyncio.py deleted file mode 100644 index f5af98e0..00000000 --- a/google/cloud/talent_v4beta1/services/profile_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,417 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -import warnings - -from google.api_core import gapic_v1, grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.protobuf import empty_pb2 # type: ignore -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4beta1.types import profile -from google.cloud.talent_v4beta1.types import profile as gct_profile -from google.cloud.talent_v4beta1.types import profile_service - -from .base import DEFAULT_CLIENT_INFO, ProfileServiceTransport -from .grpc import ProfileServiceGrpcTransport - - -class ProfileServiceGrpcAsyncIOTransport(ProfileServiceTransport): - """gRPC AsyncIO backend transport for ProfileService. - - A service that handles profile management, including profile - CRUD, enumeration and search. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel( - cls, - host: str = "jobs.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs, - ) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs, - ) - - def __init__( - self, - *, - host: str = "jobs.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def list_profiles( - self, - ) -> Callable[ - [profile_service.ListProfilesRequest], - Awaitable[profile_service.ListProfilesResponse], - ]: - r"""Return a callable for the list profiles method over gRPC. - - Lists profiles by filter. The order is unspecified. - - Returns: - Callable[[~.ListProfilesRequest], - Awaitable[~.ListProfilesResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "list_profiles" not in self._stubs: - self._stubs["list_profiles"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/ListProfiles", - request_serializer=profile_service.ListProfilesRequest.serialize, - response_deserializer=profile_service.ListProfilesResponse.deserialize, - ) - return self._stubs["list_profiles"] - - @property - def create_profile( - self, - ) -> Callable[ - [profile_service.CreateProfileRequest], Awaitable[gct_profile.Profile] - ]: - r"""Return a callable for the create profile method over gRPC. - - Creates and returns a new profile. - - Returns: - Callable[[~.CreateProfileRequest], - Awaitable[~.Profile]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_profile" not in self._stubs: - self._stubs["create_profile"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/CreateProfile", - request_serializer=profile_service.CreateProfileRequest.serialize, - response_deserializer=gct_profile.Profile.deserialize, - ) - return self._stubs["create_profile"] - - @property - def get_profile( - self, - ) -> Callable[[profile_service.GetProfileRequest], Awaitable[profile.Profile]]: - r"""Return a callable for the get profile method over gRPC. - - Gets the specified profile. - - Returns: - Callable[[~.GetProfileRequest], - Awaitable[~.Profile]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "get_profile" not in self._stubs: - self._stubs["get_profile"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/GetProfile", - request_serializer=profile_service.GetProfileRequest.serialize, - response_deserializer=profile.Profile.deserialize, - ) - return self._stubs["get_profile"] - - @property - def update_profile( - self, - ) -> Callable[ - [profile_service.UpdateProfileRequest], Awaitable[gct_profile.Profile] - ]: - r"""Return a callable for the update profile method over gRPC. - - Updates the specified profile and returns the updated - result. - - Returns: - Callable[[~.UpdateProfileRequest], - Awaitable[~.Profile]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "update_profile" not in self._stubs: - self._stubs["update_profile"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/UpdateProfile", - request_serializer=profile_service.UpdateProfileRequest.serialize, - response_deserializer=gct_profile.Profile.deserialize, - ) - return self._stubs["update_profile"] - - @property - def delete_profile( - self, - ) -> Callable[[profile_service.DeleteProfileRequest], Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete profile method over gRPC. - - Deletes the specified profile. - Prerequisite: The profile has no associated applications - or assignments associated. - - Returns: - Callable[[~.DeleteProfileRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "delete_profile" not in self._stubs: - self._stubs["delete_profile"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/DeleteProfile", - request_serializer=profile_service.DeleteProfileRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs["delete_profile"] - - @property - def search_profiles( - self, - ) -> Callable[ - [profile_service.SearchProfilesRequest], - Awaitable[profile_service.SearchProfilesResponse], - ]: - r"""Return a callable for the search profiles method over gRPC. - - Searches for profiles within a tenant. - - For example, search by raw queries "software engineer in - Mountain View" or search by structured filters (location filter, - education filter, etc.). - - See - [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest] - for more information. - - Returns: - Callable[[~.SearchProfilesRequest], - Awaitable[~.SearchProfilesResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "search_profiles" not in self._stubs: - self._stubs["search_profiles"] = self.grpc_channel.unary_unary( - "/google.cloud.talent.v4beta1.ProfileService/SearchProfiles", - request_serializer=profile_service.SearchProfilesRequest.serialize, - response_deserializer=profile_service.SearchProfilesResponse.deserialize, - ) - return self._stubs["search_profiles"] - - def close(self): - return self.grpc_channel.close() - - -__all__ = ("ProfileServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/talent_v4beta1/services/tenant_service/async_client.py b/google/cloud/talent_v4beta1/services/tenant_service/async_client.py index 6c433492..2aa180ba 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/async_client.py @@ -31,6 +31,8 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 + from google.cloud.talent_v4beta1.services.tenant_service import pagers from google.cloud.talent_v4beta1.types import tenant from google.cloud.talent_v4beta1.types import tenant as gct_tenant @@ -757,6 +759,60 @@ async def sample_list_tenants(): # Done; return the response. return response + async def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/talent_v4beta1/services/tenant_service/client.py b/google/cloud/talent_v4beta1/services/tenant_service/client.py index e63985a0..5880415c 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/client.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/client.py @@ -34,6 +34,8 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 + from google.cloud.talent_v4beta1.services.tenant_service import pagers from google.cloud.talent_v4beta1.types import tenant from google.cloud.talent_v4beta1.types import tenant as gct_tenant @@ -422,6 +424,7 @@ def __init__( quota_project_id=client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, + api_audience=client_options.api_audience, ) def create_tenant( @@ -957,6 +960,60 @@ def __exit__(self, type, value, traceback): """ self.transport.close() + def get_operation( + self, + request: operations_pb2.GetOperationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py b/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py index 0a01a0ed..526a8e3e 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py @@ -22,6 +22,7 @@ from google.api_core import retry as retries import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.longrunning import operations_pb2 from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore import pkg_resources @@ -60,6 +61,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport. @@ -87,11 +89,6 @@ def __init__( be used for service account credentials. """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ":" not in host: - host += ":443" - self._host = host - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. @@ -112,6 +109,11 @@ def __init__( credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) # If the credentials are service account credentials, then always try to use self signed JWT. if ( @@ -124,6 +126,11 @@ def __init__( # Save the credentials. self._credentials = credentials + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -241,6 +248,15 @@ def list_tenants( ]: raise NotImplementedError() + @property + def get_operation( + self, + ) -> Callable[ + [operations_pb2.GetOperationRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py index ae25b0c5..1cb83c7d 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py @@ -20,6 +20,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.longrunning import operations_pb2 from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -61,6 +62,7 @@ def __init__( quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -156,6 +158,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -363,6 +366,23 @@ def list_tenants( def close(self): self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + @property def kind(self) -> str: return "grpc" diff --git a/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py index 1a755f22..41207597 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py @@ -19,6 +19,7 @@ from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.longrunning import operations_pb2 from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -106,6 +107,7 @@ def __init__( quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, ) -> None: """Instantiate the transport. @@ -201,6 +203,7 @@ def __init__( quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, ) if not self._grpc_channel: @@ -369,5 +372,22 @@ def list_tenants( def close(self): return self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + __all__ = ("TenantServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/talent_v4beta1/types/__init__.py b/google/cloud/talent_v4beta1/types/__init__.py index 30fad4ce..49271553 100644 --- a/google/cloud/talent_v4beta1/types/__init__.py +++ b/google/cloud/talent_v4beta1/types/__init__.py @@ -13,40 +13,23 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .application import Application -from .application_service import ( - CreateApplicationRequest, - DeleteApplicationRequest, - GetApplicationRequest, - ListApplicationsRequest, - ListApplicationsResponse, - UpdateApplicationRequest, -) from .common import ( - AvailabilitySignalType, BatchOperationMetadata, - Certification, CommuteMethod, CompanySize, CompensationInfo, - ContactInfoUsage, CustomAttribute, DegreeType, DeviceInfo, EmploymentType, HtmlSanitization, - Interview, JobBenefit, JobCategory, JobLevel, Location, - Outcome, PostingRegion, - Rating, RequestMetadata, ResponseMetadata, - Skill, - SkillProficiencyLevel, SpellingCorrection, TimestampRange, Visibility, @@ -61,27 +44,9 @@ UpdateCompanyRequest, ) from .completion_service import CompleteQueryRequest, CompleteQueryResponse -from .event import ClientEvent, JobEvent, ProfileEvent +from .event import ClientEvent, JobEvent from .event_service import CreateClientEventRequest -from .filters import ( - ApplicationDateFilter, - ApplicationJobFilter, - ApplicationOutcomeNotesFilter, - AvailabilityFilter, - CandidateAvailabilityFilter, - CommuteFilter, - CompensationFilter, - EducationFilter, - EmployerFilter, - JobQuery, - JobTitleFilter, - LocationFilter, - PersonNameFilter, - ProfileQuery, - SkillFilter, - TimeFilter, - WorkExperienceFilter, -) +from .filters import CommuteFilter, CompensationFilter, JobQuery, LocationFilter from .histogram import HistogramQuery, HistogramQueryResult from .job import Job from .job_service import ( @@ -99,34 +64,6 @@ SearchJobsResponse, UpdateJobRequest, ) -from .profile import ( - Activity, - AdditionalContactInfo, - Address, - AvailabilitySignal, - Degree, - EducationRecord, - Email, - EmploymentRecord, - Patent, - PersonalUri, - PersonName, - Phone, - Profile, - Publication, - Resume, -) -from .profile_service import ( - CreateProfileRequest, - DeleteProfileRequest, - GetProfileRequest, - ListProfilesRequest, - ListProfilesResponse, - SearchProfilesRequest, - SearchProfilesResponse, - SummarizedProfile, - UpdateProfileRequest, -) from .tenant import Tenant from .tenant_service import ( CreateTenantRequest, @@ -138,39 +75,24 @@ ) __all__ = ( - "Application", - "CreateApplicationRequest", - "DeleteApplicationRequest", - "GetApplicationRequest", - "ListApplicationsRequest", - "ListApplicationsResponse", - "UpdateApplicationRequest", "BatchOperationMetadata", - "Certification", "CompensationInfo", "CustomAttribute", "DeviceInfo", - "Interview", "Location", - "Rating", "RequestMetadata", "ResponseMetadata", - "Skill", "SpellingCorrection", "TimestampRange", - "AvailabilitySignalType", "CommuteMethod", "CompanySize", - "ContactInfoUsage", "DegreeType", "EmploymentType", "HtmlSanitization", "JobBenefit", "JobCategory", "JobLevel", - "Outcome", "PostingRegion", - "SkillProficiencyLevel", "Visibility", "Company", "CreateCompanyRequest", @@ -183,25 +105,11 @@ "CompleteQueryResponse", "ClientEvent", "JobEvent", - "ProfileEvent", "CreateClientEventRequest", - "ApplicationDateFilter", - "ApplicationJobFilter", - "ApplicationOutcomeNotesFilter", - "AvailabilityFilter", - "CandidateAvailabilityFilter", "CommuteFilter", "CompensationFilter", - "EducationFilter", - "EmployerFilter", "JobQuery", - "JobTitleFilter", "LocationFilter", - "PersonNameFilter", - "ProfileQuery", - "SkillFilter", - "TimeFilter", - "WorkExperienceFilter", "HistogramQuery", "HistogramQueryResult", "Job", @@ -218,30 +126,6 @@ "SearchJobsResponse", "UpdateJobRequest", "JobView", - "Activity", - "AdditionalContactInfo", - "Address", - "AvailabilitySignal", - "Degree", - "EducationRecord", - "Email", - "EmploymentRecord", - "Patent", - "PersonalUri", - "PersonName", - "Phone", - "Profile", - "Publication", - "Resume", - "CreateProfileRequest", - "DeleteProfileRequest", - "GetProfileRequest", - "ListProfilesRequest", - "ListProfilesResponse", - "SearchProfilesRequest", - "SearchProfilesResponse", - "SummarizedProfile", - "UpdateProfileRequest", "Tenant", "CreateTenantRequest", "DeleteTenantRequest", diff --git a/google/cloud/talent_v4beta1/types/application.py b/google/cloud/talent_v4beta1/types/application.py deleted file mode 100644 index de0328c3..00000000 --- a/google/cloud/talent_v4beta1/types/application.py +++ /dev/null @@ -1,211 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore -from google.type import date_pb2 # type: ignore -import proto # type: ignore - -from google.cloud.talent_v4beta1.types import common - -__protobuf__ = proto.module( - package="google.cloud.talent.v4beta1", - manifest={ - "Application", - }, -) - - -class Application(proto.Message): - r"""Resource that represents a job application record of a - candidate. - - Attributes: - name (str): - Required during application update. - - Resource name assigned to an application by the API. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". - For example, - "projects/foo/tenants/bar/profiles/baz/applications/qux". - external_id (str): - Required. Client side application identifier, - used to uniquely identify the application. - - The maximum number of allowed characters is 255. - profile (str): - Output only. Resource name of the candidate of this - application. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - job (str): - Required. Resource name of the job which the candidate - applied for. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - company (str): - Resource name of the company which the candidate applied - for. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". - For example, "projects/foo/tenants/bar/companies/baz". - application_date (google.type.date_pb2.Date): - The application date. - stage (google.cloud.talent_v4beta1.types.Application.ApplicationStage): - Required. What is the most recent stage of - the application (that is, new, screen, send cv, - hired, finished work)? This field is - intentionally not comprehensive of every - possible status, but instead, represents - statuses that would be used to indicate to the - ML models good / bad matches. - state (google.cloud.talent_v4beta1.types.Application.ApplicationState): - The application state. - interviews (Sequence[google.cloud.talent_v4beta1.types.Interview]): - All interviews (screen, onsite, and so on) - conducted as part of this application (includes - details such as user conducting the interview, - timestamp, feedback, and so on). - referral (google.protobuf.wrappers_pb2.BoolValue): - If the candidate is referred by a employee. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Required. Reflects the time that the - application was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The last update timestamp. - outcome_notes (str): - Free text reason behind the recruitement - outcome (for example, reason for withdraw / - reject, reason for an unsuccessful finish, and - so on). - Number of characters allowed is 100. - outcome (google.cloud.talent_v4beta1.types.Outcome): - Outcome positiveness shows how positive the - outcome is. - is_match (google.protobuf.wrappers_pb2.BoolValue): - Output only. Indicates whether this job - application is a match to application related - filters. This value is only applicable in - profile search response. - job_title_snippet (str): - Output only. Job title snippet shows how the - job title is related to a search query. It's - empty if the job title isn't related to the - search query. - """ - - class ApplicationState(proto.Enum): - r"""Enum that represents the application status.""" - APPLICATION_STATE_UNSPECIFIED = 0 - IN_PROGRESS = 1 - CANDIDATE_WITHDREW = 2 - EMPLOYER_WITHDREW = 3 - COMPLETED = 4 - CLOSED = 5 - - class ApplicationStage(proto.Enum): - r"""The stage of the application.""" - APPLICATION_STAGE_UNSPECIFIED = 0 - NEW = 1 - SCREEN = 2 - HIRING_MANAGER_REVIEW = 3 - INTERVIEW = 4 - OFFER_EXTENDED = 5 - OFFER_ACCEPTED = 6 - STARTED = 7 - - name = proto.Field( - proto.STRING, - number=1, - ) - external_id = proto.Field( - proto.STRING, - number=31, - ) - profile = proto.Field( - proto.STRING, - number=2, - ) - job = proto.Field( - proto.STRING, - number=4, - ) - company = proto.Field( - proto.STRING, - number=5, - ) - application_date = proto.Field( - proto.MESSAGE, - number=7, - message=date_pb2.Date, - ) - stage = proto.Field( - proto.ENUM, - number=11, - enum=ApplicationStage, - ) - state = proto.Field( - proto.ENUM, - number=13, - enum=ApplicationState, - ) - interviews = proto.RepeatedField( - proto.MESSAGE, - number=16, - message=common.Interview, - ) - referral = proto.Field( - proto.MESSAGE, - number=18, - message=wrappers_pb2.BoolValue, - ) - create_time = proto.Field( - proto.MESSAGE, - number=19, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=20, - message=timestamp_pb2.Timestamp, - ) - outcome_notes = proto.Field( - proto.STRING, - number=21, - ) - outcome = proto.Field( - proto.ENUM, - number=22, - enum=common.Outcome, - ) - is_match = proto.Field( - proto.MESSAGE, - number=28, - message=wrappers_pb2.BoolValue, - ) - job_title_snippet = proto.Field( - proto.STRING, - number=29, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/talent_v4beta1/types/application_service.py b/google/cloud/talent_v4beta1/types/application_service.py deleted file mode 100644 index 0ba66923..00000000 --- a/google/cloud/talent_v4beta1/types/application_service.py +++ /dev/null @@ -1,202 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from google.protobuf import field_mask_pb2 # type: ignore -import proto # type: ignore - -from google.cloud.talent_v4beta1.types import application as gct_application -from google.cloud.talent_v4beta1.types import common - -__protobuf__ = proto.module( - package="google.cloud.talent.v4beta1", - manifest={ - "CreateApplicationRequest", - "GetApplicationRequest", - "UpdateApplicationRequest", - "DeleteApplicationRequest", - "ListApplicationsRequest", - "ListApplicationsResponse", - }, -) - - -class CreateApplicationRequest(proto.Message): - r"""The Request of the CreateApplication method. - - Attributes: - parent (str): - Required. Resource name of the profile under which the - application is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - application (google.cloud.talent_v4beta1.types.Application): - Required. The application to be created. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - application = proto.Field( - proto.MESSAGE, - number=2, - message=gct_application.Application, - ) - - -class GetApplicationRequest(proto.Message): - r"""Request for getting a application by name. - - Attributes: - name (str): - Required. The resource name of the application to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". - For example, - "projects/foo/tenants/bar/profiles/baz/applications/qux". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateApplicationRequest(proto.Message): - r"""Request for updating a specified application. - - Attributes: - application (google.cloud.talent_v4beta1.types.Application): - Required. The application resource to replace - the current resource in the system. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Strongly recommended for the best service experience. - - If - [update_mask][google.cloud.talent.v4beta1.UpdateApplicationRequest.update_mask] - is provided, only the specified fields in - [application][google.cloud.talent.v4beta1.UpdateApplicationRequest.application] - are updated. Otherwise all the fields are updated. - - A field mask to specify the application fields to be - updated. Only top level fields of - [Application][google.cloud.talent.v4beta1.Application] are - supported. - """ - - application = proto.Field( - proto.MESSAGE, - number=1, - message=gct_application.Application, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteApplicationRequest(proto.Message): - r"""Request to delete a application. - - Attributes: - name (str): - Required. The resource name of the application to be - deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". - For example, - "projects/foo/tenants/bar/profiles/baz/applications/qux". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListApplicationsRequest(proto.Message): - r"""List applications for which the client has ACL visibility. - - Attributes: - parent (str): - Required. Resource name of the profile under which the - application is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}", - for example, "projects/foo/tenants/bar/profiles/baz". - page_token (str): - The starting indicator from which to return - results. - page_size (int): - The maximum number of applications to be - returned, at most 100. Default is 100 if a - non-positive number is provided. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_token = proto.Field( - proto.STRING, - number=2, - ) - page_size = proto.Field( - proto.INT32, - number=3, - ) - - -class ListApplicationsResponse(proto.Message): - r"""The List applications response object. - - Attributes: - applications (Sequence[google.cloud.talent_v4beta1.types.Application]): - Applications for the current client. - next_page_token (str): - A token to retrieve the next page of results. - metadata (google.cloud.talent_v4beta1.types.ResponseMetadata): - Additional information for the API - invocation, such as the request tracking id. - """ - - @property - def raw_page(self): - return self - - applications = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gct_application.Application, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - metadata = proto.Field( - proto.MESSAGE, - number=3, - message=common.ResponseMetadata, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/talent_v4beta1/types/common.py b/google/cloud/talent_v4beta1/types/common.py index 5298e857..ffa9ed70 100644 --- a/google/cloud/talent_v4beta1/types/common.py +++ b/google/cloud/talent_v4beta1/types/common.py @@ -15,7 +15,6 @@ # from google.protobuf import timestamp_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore -from google.type import date_pb2 # type: ignore from google.type import latlng_pb2 # type: ignore from google.type import money_pb2 # type: ignore from google.type import postal_address_pb2 # type: ignore @@ -32,12 +31,8 @@ "JobCategory", "PostingRegion", "Visibility", - "ContactInfoUsage", "HtmlSanitization", "CommuteMethod", - "SkillProficiencyLevel", - "Outcome", - "AvailabilitySignalType", "TimestampRange", "Location", "RequestMetadata", @@ -46,10 +41,6 @@ "CustomAttribute", "SpellingCorrection", "CompensationInfo", - "Certification", - "Skill", - "Interview", - "Rating", "BatchOperationMetadata", }, ) @@ -189,14 +180,6 @@ class Visibility(proto.Enum): SHARED_WITH_PUBLIC = 3 -class ContactInfoUsage(proto.Enum): - r"""Enum that represents the usage of the contact information.""" - CONTACT_INFO_USAGE_UNSPECIFIED = 0 - PERSONAL = 1 - WORK = 2 - SCHOOL = 3 - - class HtmlSanitization(proto.Enum): r"""Option for HTML content sanitization on user input fields, for example, job description. By setting this option, user can @@ -217,35 +200,6 @@ class CommuteMethod(proto.Enum): CYCLING = 4 -class SkillProficiencyLevel(proto.Enum): - r"""Enum that represents the skill proficiency level.""" - SKILL_PROFICIENCY_LEVEL_UNSPECIFIED = 0 - UNSKILLED = 6 - FUNDAMENTAL_AWARENESS = 1 - NOVICE = 2 - INTERMEDIATE = 3 - ADVANCED = 4 - EXPERT = 5 - - -class Outcome(proto.Enum): - r"""The overall outcome /decision / result indicator.""" - OUTCOME_UNSPECIFIED = 0 - POSITIVE = 1 - NEUTRAL = 2 - NEGATIVE = 3 - OUTCOME_NOT_AVAILABLE = 4 - - -class AvailabilitySignalType(proto.Enum): - r"""The type of candidate availability signal.""" - AVAILABILITY_SIGNAL_TYPE_UNSPECIFIED = 0 - JOB_APPLICATION = 1 - RESUME_UPDATE = 2 - CANDIDATE_UPDATE = 3 - CLIENT_SUBMISSION = 4 - - class TimestampRange(proto.Message): r"""Message representing a period of time between two timestamps. @@ -521,8 +475,17 @@ class CustomAttribute(proto.Message): [long_values][google.cloud.talent.v4beta1.CustomAttribute.long_values] is supported. filterable (bool): - If the ``filterable`` flag is true, custom field values are - searchable. If false, values are not searchable. + If the ``filterable`` flag is true, the custom field values + may be used for custom attribute filters + [JobQuery.custom_attribute_filter][google.cloud.talent.v4beta1.JobQuery.custom_attribute_filter]. + If false, these values may not be used for custom attribute + filters. + + Default is false. + keyword_searchable (bool): + If the ``keyword_searchable`` flag is true, the keywords in + custom fields are searchable by keyword match. If false, the + values are not searchable by keyword match. Default is false. """ @@ -539,6 +502,10 @@ class CustomAttribute(proto.Message): proto.BOOL, number=3, ) + keyword_searchable = proto.Field( + proto.BOOL, + number=4, + ) class SpellingCorrection(proto.Message): @@ -799,157 +766,6 @@ class CompensationRange(proto.Message): ) -class Certification(proto.Message): - r"""Resource that represents a license or certification. - - Attributes: - display_name (str): - Name of license or certification. - Number of characters allowed is 100. - acquire_date (google.type.date_pb2.Date): - Acquisition date or effective date of license - or certification. - expire_date (google.type.date_pb2.Date): - Expiration date of license of certification. - authority (str): - Authority of license, such as government. - Number of characters allowed is 100. - description (str): - Description of license or certification. - Number of characters allowed is 100,000. - """ - - display_name = proto.Field( - proto.STRING, - number=1, - ) - acquire_date = proto.Field( - proto.MESSAGE, - number=2, - message=date_pb2.Date, - ) - expire_date = proto.Field( - proto.MESSAGE, - number=3, - message=date_pb2.Date, - ) - authority = proto.Field( - proto.STRING, - number=4, - ) - description = proto.Field( - proto.STRING, - number=5, - ) - - -class Skill(proto.Message): - r"""Resource that represents a skill of a candidate. - - Attributes: - display_name (str): - Skill display name. - For example, "Java", "Python". - - Number of characters allowed is 100. - last_used_date (google.type.date_pb2.Date): - The last time this skill was used. - level (google.cloud.talent_v4beta1.types.SkillProficiencyLevel): - Skill proficiency level which indicates how - proficient the candidate is at this skill. - context (str): - A paragraph describes context of this skill. - Number of characters allowed is 100,000. - skill_name_snippet (str): - Output only. Skill name snippet shows how the - [display_name][google.cloud.talent.v4beta1.Skill.display_name] - is related to a search query. It's empty if the - [display_name][google.cloud.talent.v4beta1.Skill.display_name] - isn't related to the search query. - """ - - display_name = proto.Field( - proto.STRING, - number=1, - ) - last_used_date = proto.Field( - proto.MESSAGE, - number=2, - message=date_pb2.Date, - ) - level = proto.Field( - proto.ENUM, - number=3, - enum="SkillProficiencyLevel", - ) - context = proto.Field( - proto.STRING, - number=4, - ) - skill_name_snippet = proto.Field( - proto.STRING, - number=5, - ) - - -class Interview(proto.Message): - r"""Details of an interview. - - Attributes: - rating (google.cloud.talent_v4beta1.types.Rating): - The rating on this interview. - outcome (google.cloud.talent_v4beta1.types.Outcome): - Required. The overall decision resulting from - this interview (positive, negative, nuetral). - """ - - rating = proto.Field( - proto.MESSAGE, - number=6, - message="Rating", - ) - outcome = proto.Field( - proto.ENUM, - number=7, - enum="Outcome", - ) - - -class Rating(proto.Message): - r"""The details of the score received for an assessment or - interview. - - Attributes: - overall (float): - Overall score. - min_ (float): - The minimum value for the score. - max_ (float): - The maximum value for the score. - interval (float): - The steps within the score (for example, - interval = 1 max = 5 min = 1 indicates that the - score can be 1, 2, 3, 4, or 5) - """ - - overall = proto.Field( - proto.DOUBLE, - number=1, - ) - min_ = proto.Field( - proto.DOUBLE, - number=2, - ) - max_ = proto.Field( - proto.DOUBLE, - number=3, - ) - interval = proto.Field( - proto.DOUBLE, - number=4, - ) - - class BatchOperationMetadata(proto.Message): r"""Metadata used for long running operations returned by CTS batch APIs. It's used to replace diff --git a/google/cloud/talent_v4beta1/types/event.py b/google/cloud/talent_v4beta1/types/event.py index 49609f7e..648e3248 100644 --- a/google/cloud/talent_v4beta1/types/event.py +++ b/google/cloud/talent_v4beta1/types/event.py @@ -21,7 +21,6 @@ manifest={ "ClientEvent", "JobEvent", - "ProfileEvent", }, ) @@ -34,10 +33,6 @@ class ClientEvent(proto.Message): of events sent must be consistent with other calls, such as job searches, issued to the service by the client. - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields @@ -58,12 +53,6 @@ class ClientEvent(proto.Message): with the application that implements Cloud Talent Solution. - This field is a member of `oneof`_ ``event``. - profile_event (google.cloud.talent_v4beta1.types.ProfileEvent): - An event issued when a profile searcher - interacts with the application that implements - Cloud Talent Solution. - This field is a member of `oneof`_ ``event``. event_notes (str): Notes about the event provided by recruiters @@ -90,12 +79,6 @@ class ClientEvent(proto.Message): oneof="event", message="JobEvent", ) - profile_event = proto.Field( - proto.MESSAGE, - number=6, - oneof="event", - message="ProfileEvent", - ) event_notes = proto.Field( proto.STRING, number=9, @@ -168,53 +151,4 @@ class JobEventType(proto.Enum): ) -class ProfileEvent(proto.Message): - r"""An event issued when a profile searcher interacts with the - application that implements Cloud Talent Solution. - - Attributes: - type_ (google.cloud.talent_v4beta1.types.ProfileEvent.ProfileEventType): - Required. Type of event. - profiles (Sequence[str]): - Required. The [profile - name(s)][google.cloud.talent.v4beta1.Profile.name] - associated with this client event. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}", - for example, "projects/foo/tenants/bar/profiles/baz". - jobs (Sequence[str]): - The [job name(s)][google.cloud.talent.v4beta1.Job.name] - associated with this client event. Leave it empty if the - event isn't associated with a job. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}", - for example, "projects/foo/tenants/bar/jobs/baz". - """ - - class ProfileEventType(proto.Enum): - r"""The enum represents types of client events for a candidate - profile. - """ - PROFILE_EVENT_TYPE_UNSPECIFIED = 0 - IMPRESSION = 1 - VIEW = 2 - BOOKMARK = 3 - - type_ = proto.Field( - proto.ENUM, - number=1, - enum=ProfileEventType, - ) - profiles = proto.RepeatedField( - proto.STRING, - number=2, - ) - jobs = proto.RepeatedField( - proto.STRING, - number=6, - ) - - __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/talent_v4beta1/types/filters.py b/google/cloud/talent_v4beta1/types/filters.py index 26605ed9..fa3bd4df 100644 --- a/google/cloud/talent_v4beta1/types/filters.py +++ b/google/cloud/talent_v4beta1/types/filters.py @@ -14,9 +14,6 @@ # limitations under the License. # from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore -from google.type import date_pb2 # type: ignore from google.type import latlng_pb2 # type: ignore from google.type import timeofday_pb2 # type: ignore import proto # type: ignore @@ -27,22 +24,9 @@ package="google.cloud.talent.v4beta1", manifest={ "JobQuery", - "ProfileQuery", "LocationFilter", "CompensationFilter", "CommuteFilter", - "JobTitleFilter", - "SkillFilter", - "EmployerFilter", - "EducationFilter", - "WorkExperienceFilter", - "ApplicationDateFilter", - "ApplicationOutcomeNotesFilter", - "ApplicationJobFilter", - "TimeFilter", - "CandidateAvailabilityFilter", - "AvailabilityFilter", - "PersonNameFilter", }, ) @@ -127,9 +111,25 @@ class JobQuery(proto.Message): Currently we don't support sorting by commute time. company_display_names (Sequence[str]): - This filter specifies the exact company + This filter specifies the company [Company.display_name][google.cloud.talent.v4beta1.Company.display_name] - of the jobs to search against. + of the jobs to search against. The company name must match + the value exactly. + + Alternatively, the value being searched for can be wrapped + in different match operators. ``SUBSTRING_MATCH([value])`` + The company name must contain a case insensitive substring + match of the value. Using this function may increase + latency. + + Sample Value: ``SUBSTRING_MATCH(google)`` + + ``MULTI_WORD_TOKEN_MATCH([value])`` The value will be + treated as a multi word token and the company name must + contain a case insensitive match of the value. Using this + function may increase latency. + + Sample Value: ``MULTI_WORD_TOKEN_MATCH(google)`` If a value isn't specified, jobs within the search results are associated with any company. @@ -167,7 +167,7 @@ class JobQuery(proto.Message): Boolean expressions (AND/OR/NOT) are supported up to 3 levels of nesting (for example, "((A AND B AND C) OR NOT D) AND E"), a maximum of 100 comparisons or functions are - allowed in the expression. The expression must be < 6000 + allowed in the expression. The expression must be < 10000 bytes in length. Sample Query: @@ -274,394 +274,6 @@ class JobQuery(proto.Message): ) -class ProfileQuery(proto.Message): - r"""Filters to apply when performing the search query. - - Attributes: - query (str): - Keywords to match any text fields of - profiles. - For example, "software engineer in Palo Alto". - location_filters (Sequence[google.cloud.talent_v4beta1.types.LocationFilter]): - The location filter specifies geo-regions containing the - profiles to search against. - - One of - [LocationFilter.address][google.cloud.talent.v4beta1.LocationFilter.address] - or - [LocationFilter.lat_lng][google.cloud.talent.v4beta1.LocationFilter.lat_lng] - must be provided or an error is thrown. If both - [LocationFilter.address][google.cloud.talent.v4beta1.LocationFilter.address] - and - [LocationFilter.lat_lng][google.cloud.talent.v4beta1.LocationFilter.lat_lng] - are provided, an error is thrown. - - The following logic is used to determine which locations in - the profile to filter against: - - 1. All of the profile's geocoded - [Profile.addresses][google.cloud.talent.v4beta1.Profile.addresses] - where - [Address.usage][google.cloud.talent.v4beta1.Address.usage] - is PERSONAL and - [Address.current][google.cloud.talent.v4beta1.Address.current] - is true. - - 2. If the above set of locations is empty, all of the - profile's geocoded - [Profile.addresses][google.cloud.talent.v4beta1.Profile.addresses] - where - [Address.usage][google.cloud.talent.v4beta1.Address.usage] - is CONTACT_INFO_USAGE_UNSPECIFIED and - [Address.current][google.cloud.talent.v4beta1.Address.current] - is true. - - 3. If the above set of locations is empty, all of the - profile's geocoded - [Profile.addresses][google.cloud.talent.v4beta1.Profile.addresses] - where - [Address.usage][google.cloud.talent.v4beta1.Address.usage] - is PERSONAL or CONTACT_INFO_USAGE_UNSPECIFIED and - [Address.current][google.cloud.talent.v4beta1.Address.current] - is not set. - - This means that any profiles without any - [Profile.addresses][google.cloud.talent.v4beta1.Profile.addresses] - that match any of the above criteria will not be included in - a search with location filter. Furthermore, any - [Profile.addresses][google.cloud.talent.v4beta1.Profile.addresses] - where - [Address.usage][google.cloud.talent.v4beta1.Address.usage] - is WORK or SCHOOL or where - [Address.current][google.cloud.talent.v4beta1.Address.current] - is false are not considered for location filter. - - If a location filter isn't specified, profiles fitting the - other search criteria are retrieved regardless of where - they're located. - - If - [LocationFilter.negated][google.cloud.talent.v4beta1.LocationFilter.negated] - is specified, the result doesn't contain profiles from that - location. - - If - [LocationFilter.address][google.cloud.talent.v4beta1.LocationFilter.address] - is provided, the - [LocationType][google.cloud.talent.v4beta1.Location.LocationType], - center point (latitude and longitude), and radius are - automatically detected by the Google Maps Geocoding API and - included as well. If - [LocationFilter.address][google.cloud.talent.v4beta1.LocationFilter.address] - cannot be geocoded, the filter falls back to keyword search. - - If the detected - [LocationType][google.cloud.talent.v4beta1.Location.LocationType] - is - [LocationType.SUB_ADMINISTRATIVE_AREA][google.cloud.talent.v4beta1.Location.LocationType.SUB_ADMINISTRATIVE_AREA], - [LocationType.ADMINISTRATIVE_AREA][google.cloud.talent.v4beta1.Location.LocationType.ADMINISTRATIVE_AREA], - or - [LocationType.COUNTRY][google.cloud.talent.v4beta1.Location.LocationType.COUNTRY], - the filter is performed against the detected location name - (using exact text matching). Otherwise, the filter is - performed against the detected center point and a radius of - detected location radius + - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles]. - - If - [LocationFilter.address][google.cloud.talent.v4beta1.LocationFilter.address] - is provided, - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - is the additional radius on top of the radius of the - location geocoded from - [LocationFilter.address][google.cloud.talent.v4beta1.LocationFilter.address]. - If - [LocationFilter.lat_lng][google.cloud.talent.v4beta1.LocationFilter.lat_lng] - is provided, - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - is the only radius that is used. - - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - is 10 by default. Note that the value of - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - is 0 if it is unset, so the server does not differentiate - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - that is explicitly set to 0 and - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - that is not set. Which means that if - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - is explicitly set to 0, the server will use the default - value of - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - which is 10. To work around this and effectively set - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - to 0, we recommend setting - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - to a very small decimal number (such as 0.00001). - - If - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - is negative, an error is thrown. - job_title_filters (Sequence[google.cloud.talent_v4beta1.types.JobTitleFilter]): - Job title filter specifies job titles of profiles to match - on. - - If a job title isn't specified, profiles with any titles are - retrieved. - - If multiple values are specified, profiles are retrieved - with any of the specified job titles. - - If - [JobTitleFilter.negated][google.cloud.talent.v4beta1.JobTitleFilter.negated] - is specified, the result won't contain profiles with the job - titles. - - For example, search for profiles with a job title "Product - Manager". - employer_filters (Sequence[google.cloud.talent_v4beta1.types.EmployerFilter]): - Employer filter specifies employers of profiles to match on. - - If an employer filter isn't specified, profiles with any - employers are retrieved. - - If multiple employer filters are specified, profiles with - any matching employers are retrieved. - - If - [EmployerFilter.negated][google.cloud.talent.v4beta1.EmployerFilter.negated] - is specified, the result won't contain profiles that match - the employers. - - For example, search for profiles that have working - experience at "Google LLC". - education_filters (Sequence[google.cloud.talent_v4beta1.types.EducationFilter]): - Education filter specifies education of profiles to match - on. - - If an education filter isn't specified, profiles with any - education are retrieved. - - If multiple education filters are specified, profiles that - match any education filters are retrieved. - - If - [EducationFilter.negated][google.cloud.talent.v4beta1.EducationFilter.negated] - is specified, the result won't contain profiles that match - the educations. - - For example, search for profiles with a master degree. - skill_filters (Sequence[google.cloud.talent_v4beta1.types.SkillFilter]): - Skill filter specifies skill of profiles to match on. - - If a skill filter isn't specified, profiles with any skills - are retrieved. - - If multiple skill filters are specified, profiles that match - any skill filters are retrieved. - - If - [SkillFilter.negated][google.cloud.talent.v4beta1.SkillFilter.negated] - is specified, the result won't contain profiles that match - the skills. - - For example, search for profiles that have "Java" and - "Python" in skill list. - work_experience_filter (Sequence[google.cloud.talent_v4beta1.types.WorkExperienceFilter]): - Work experience filter specifies the total - working experience of profiles to match on. - - If a work experience filter isn't specified, - profiles with any professional experience are - retrieved. - - If multiple work experience filters are - specified, profiles that match any work - experience filters are retrieved. - - For example, search for profiles with 10 years - of work experience. - time_filters (Sequence[google.cloud.talent_v4beta1.types.TimeFilter]): - Time filter specifies the create/update - timestamp of the profiles to match on. - - For example, search for profiles created since - "2018-1-1". - hirable_filter (google.protobuf.wrappers_pb2.BoolValue): - The hirable filter specifies the profile's - hirable status to match on. - application_date_filters (Sequence[google.cloud.talent_v4beta1.types.ApplicationDateFilter]): - The application date filters specify - application date ranges to match on. - application_outcome_notes_filters (Sequence[google.cloud.talent_v4beta1.types.ApplicationOutcomeNotesFilter]): - The application outcome notes filters specify - the notes for the outcome of the job - application. - application_job_filters (Sequence[google.cloud.talent_v4beta1.types.ApplicationJobFilter]): - The application job filters specify the job - applied for in the application. - custom_attribute_filter (str): - This filter specifies a structured syntax to match against - the - [Profile.custom_attributes][google.cloud.talent.v4beta1.Profile.custom_attributes] - that are marked as ``filterable``. - - The syntax for this expression is a subset of Google SQL - syntax. - - String custom attributes: supported operators are =, != - where the left of the operator is a custom field key and the - right of the operator is a string (surrounded by quotes) - value. - - Numeric custom attributes: Supported operators are '>', '<' - or '=' operators where the left of the operator is a custom - field key and the right of the operator is a numeric value. - - Supported functions are LOWER() to perform case - insensitive match and EMPTY() to filter on the - existence of a key. - - Boolean expressions (AND/OR/NOT) are supported up to 3 - levels of nesting (for example "((A AND B AND C) OR NOT D) - AND E"), and there can be a maximum of 50 - comparisons/functions in the expression. The expression must - be < 2000 characters in length. - - Sample Query: (key1 = "TEST" OR LOWER(key1)="test" OR NOT - EMPTY(key1)) - candidate_availability_filter (google.cloud.talent_v4beta1.types.CandidateAvailabilityFilter): - Deprecated. Use availability_filters instead. - - The candidate availability filter which filters based on - availability signals. - - Signal 1: Number of days since most recent job application. - See - [Availability.JobApplicationAvailabilitySignal][google.cloud.talent.v4beta1.Availability.JobApplicationAvailabilitySignal] - for the details of this signal. - - Signal 2: Number of days since last profile update. See - [Availability.ProfileUpdateAvailabilitySignal][google.cloud.talent.v4beta1.Availability.ProfileUpdateAvailabilitySignal] - for the details of this signal. - - The candidate availability filter helps a recruiter - understand if a specific candidate is likely to be actively - seeking new job opportunities based on an aggregated set of - signals. Specifically, the intent is NOT to indicate the - candidate's potential qualification / interest / close - ability for a specific job. - availability_filters (Sequence[google.cloud.talent_v4beta1.types.AvailabilityFilter]): - The availability filter which filters based on - [Profile.availability_signals][google.cloud.talent.v4beta1.Profile.availability_signals]. - - The availability filter helps a recruiter understand if a - specific candidate is likely to be actively seeking new job - opportunities based on an aggregated set of signals. - Specifically, the intent is NOT to indicate the candidate's - potential qualification / interest / close ability for a - specific job. - - There can be at most one - [AvailabilityFilter][google.cloud.talent.v4beta1.AvailabilityFilter] - per - [signal_type][google.cloud.talent.v4beta1.AvailabilityFilter.signal_type]. - If there are multiple - [AvailabilityFilter][google.cloud.talent.v4beta1.AvailabilityFilter] - for a - [signal_type][google.cloud.talent.v4beta1.AvailabilityFilter.signal_type], - an error is thrown. - person_name_filters (Sequence[google.cloud.talent_v4beta1.types.PersonNameFilter]): - Person name filter specifies person name of - profiles to match on. - If multiple person name filters are specified, - profiles that match any person name filters are - retrieved. - - For example, search for profiles of candidates - with name "John Smith". - """ - - query = proto.Field( - proto.STRING, - number=1, - ) - location_filters = proto.RepeatedField( - proto.MESSAGE, - number=2, - message="LocationFilter", - ) - job_title_filters = proto.RepeatedField( - proto.MESSAGE, - number=3, - message="JobTitleFilter", - ) - employer_filters = proto.RepeatedField( - proto.MESSAGE, - number=4, - message="EmployerFilter", - ) - education_filters = proto.RepeatedField( - proto.MESSAGE, - number=5, - message="EducationFilter", - ) - skill_filters = proto.RepeatedField( - proto.MESSAGE, - number=6, - message="SkillFilter", - ) - work_experience_filter = proto.RepeatedField( - proto.MESSAGE, - number=7, - message="WorkExperienceFilter", - ) - time_filters = proto.RepeatedField( - proto.MESSAGE, - number=8, - message="TimeFilter", - ) - hirable_filter = proto.Field( - proto.MESSAGE, - number=9, - message=wrappers_pb2.BoolValue, - ) - application_date_filters = proto.RepeatedField( - proto.MESSAGE, - number=10, - message="ApplicationDateFilter", - ) - application_outcome_notes_filters = proto.RepeatedField( - proto.MESSAGE, - number=11, - message="ApplicationOutcomeNotesFilter", - ) - application_job_filters = proto.RepeatedField( - proto.MESSAGE, - number=13, - message="ApplicationJobFilter", - ) - custom_attribute_filter = proto.Field( - proto.STRING, - number=15, - ) - candidate_availability_filter = proto.Field( - proto.MESSAGE, - number=16, - message="CandidateAvailabilityFilter", - ) - availability_filters = proto.RepeatedField( - proto.MESSAGE, - number=18, - message="AvailabilityFilter", - ) - person_name_filters = proto.RepeatedField( - proto.MESSAGE, - number=17, - message="PersonNameFilter", - ) - - class LocationFilter(proto.Message): r"""Geographic region of the search. @@ -670,19 +282,25 @@ class LocationFilter(proto.Message): The address name, such as "Mountain View" or "Bay Area". region_code (str): - CLDR region code of the country/region of the address. This - is used to address ambiguity of the user-input location, for - example, "Liverpool" against "Liverpool, NY, US" or - "Liverpool, UK". - - Set this field to bias location resolution toward a specific - country or territory. If this field is not set, application - behavior is biased toward the United States by default. + CLDR region code of the country/region. This field may be + used in two ways: + + 1) If telecommute preference is not set, this field is used + address ambiguity of the user-input address. For example, + "Liverpool" may refer to "Liverpool, NY, US" or + "Liverpool, UK". This region code biases the address + resolution toward a specific country or territory. If + this field is not set, address resolution is biased + toward the United States by default. + + 2) If telecommute preference is set to TELECOMMUTE_ALLOWED, + the telecommute location filter will be limited to the + region specified in this field. If this field is not set, + the telecommute job locations will not be See - https://www.unicode.org/cldr/charts/30/supplemental/territory_information.html - for details. Example: "CH" for Switzerland. Note that this - filter is not applicable for Profile Search related queries. + https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html + for details. Example: "CH" for Switzerland. lat_lng (google.type.latlng_pb2.LatLng): The latitude and longitude of the geographic center to search from. This field is ignored if ``address`` is @@ -695,7 +313,7 @@ class LocationFilter(proto.Message): telecommute_preference (google.cloud.talent_v4beta1.types.LocationFilter.TelecommutePreference): Allows the client to return jobs without a set location, specifically, telecommuting jobs (telecommuting is - considered by the service as a special location. + considered by the service as a special location). [Job.posting_region][google.cloud.talent.v4beta1.Job.posting_region] indicates if a job permits telecommuting. If this field is set to @@ -706,7 +324,14 @@ class LocationFilter(proto.Message): [lat_lng][google.cloud.talent.v4beta1.LocationFilter.lat_lng] are ignored. If not set or set to [TelecommutePreference.TELECOMMUTE_EXCLUDED][google.cloud.talent.v4beta1.LocationFilter.TelecommutePreference.TELECOMMUTE_EXCLUDED], - telecommute job are not searched. + the telecommute status of the jobs is ignored. Jobs that + have + [PostingRegion.TELECOMMUTE][google.cloud.talent.v4beta1.PostingRegion.TELECOMMUTE] + and have additional + [Job.addresses][google.cloud.talent.v4beta1.Job.addresses] + may still be matched based on other location filters using + [address][google.cloud.talent.v4beta1.LocationFilter.address] + or [latlng][]. This filter can be used by itself to search exclusively for telecommuting jobs, or it can be combined with another @@ -720,8 +345,6 @@ class LocationFilter(proto.Message): negated (bool): Whether to apply negation to the filter so profiles matching the filter are excluded. - - Currently only supported in profile search. """ class TelecommutePreference(proto.Enum): @@ -729,6 +352,7 @@ class TelecommutePreference(proto.Enum): TELECOMMUTE_PREFERENCE_UNSPECIFIED = 0 TELECOMMUTE_EXCLUDED = 1 TELECOMMUTE_ALLOWED = 2 + TELECOMMUTE_JOBS_EXCLUDED = 3 address = proto.Field( proto.STRING, @@ -886,375 +510,4 @@ class RoadTraffic(proto.Enum): ) -class JobTitleFilter(proto.Message): - r"""Job title of the search. - - Attributes: - job_title (str): - Required. The job title. For example, - "Software engineer", or "Product manager". - negated (bool): - Whether to apply negation to the filter so - profiles matching the filter are excluded. - """ - - job_title = proto.Field( - proto.STRING, - number=1, - ) - negated = proto.Field( - proto.BOOL, - number=2, - ) - - -class SkillFilter(proto.Message): - r"""Skill filter of the search. - - Attributes: - skill (str): - Required. The skill name. For example, - "java", "j2ee", and so on. - negated (bool): - Whether to apply negation to the filter so - profiles matching the filter are excluded. - """ - - skill = proto.Field( - proto.STRING, - number=1, - ) - negated = proto.Field( - proto.BOOL, - number=2, - ) - - -class EmployerFilter(proto.Message): - r"""Employer filter of the search. - - Attributes: - employer (str): - Required. The name of the employer, for - example "Google", "Alphabet". - mode (google.cloud.talent_v4beta1.types.EmployerFilter.EmployerFilterMode): - Define set of - [EmploymentRecord][google.cloud.talent.v4beta1.EmploymentRecord]s - to search against. - - Defaults to - [EmployerFilterMode.ALL_EMPLOYMENT_RECORDS][google.cloud.talent.v4beta1.EmployerFilter.EmployerFilterMode.ALL_EMPLOYMENT_RECORDS]. - negated (bool): - Whether to apply negation to the filter so - profiles matching the filter is excluded. - """ - - class EmployerFilterMode(proto.Enum): - r"""Enum indicating which set of - [Profile.employment_records][google.cloud.talent.v4beta1.Profile.employment_records] - to search against. - """ - EMPLOYER_FILTER_MODE_UNSPECIFIED = 0 - ALL_EMPLOYMENT_RECORDS = 1 - CURRENT_EMPLOYMENT_RECORDS_ONLY = 2 - PAST_EMPLOYMENT_RECORDS_ONLY = 3 - - employer = proto.Field( - proto.STRING, - number=1, - ) - mode = proto.Field( - proto.ENUM, - number=2, - enum=EmployerFilterMode, - ) - negated = proto.Field( - proto.BOOL, - number=3, - ) - - -class EducationFilter(proto.Message): - r"""Education filter of the search. - - Attributes: - school (str): - The school name. For example "MIT", - "University of California, Berkeley". - field_of_study (str): - The field of study. This is to search against value provided - in - [Degree.fields_of_study][google.cloud.talent.v4beta1.Degree.fields_of_study]. - For example "Computer Science", "Mathematics". - degree_type (google.cloud.talent_v4beta1.types.DegreeType): - Education degree in ISCED code. Each value in - degree covers a specific level of education, - without any expansion to upper nor lower levels - of education degree. - negated (bool): - Whether to apply negation to the filter so - profiles matching the filter is excluded. - """ - - school = proto.Field( - proto.STRING, - number=1, - ) - field_of_study = proto.Field( - proto.STRING, - number=2, - ) - degree_type = proto.Field( - proto.ENUM, - number=3, - enum=common.DegreeType, - ) - negated = proto.Field( - proto.BOOL, - number=6, - ) - - -class WorkExperienceFilter(proto.Message): - r"""Work experience filter. - - This filter is used to search for profiles with working experience - length between - [min_experience][google.cloud.talent.v4beta1.WorkExperienceFilter.min_experience] - and - [max_experience][google.cloud.talent.v4beta1.WorkExperienceFilter.max_experience]. - - Attributes: - min_experience (google.protobuf.duration_pb2.Duration): - The minimum duration of the work experience - (inclusive). - max_experience (google.protobuf.duration_pb2.Duration): - The maximum duration of the work experience - (exclusive). - """ - - min_experience = proto.Field( - proto.MESSAGE, - number=1, - message=duration_pb2.Duration, - ) - max_experience = proto.Field( - proto.MESSAGE, - number=2, - message=duration_pb2.Duration, - ) - - -class ApplicationDateFilter(proto.Message): - r"""Application Date Range Filter. - - The API matches profiles with - [Application.application_date][google.cloud.talent.v4beta1.Application.application_date] - between start date and end date (both boundaries are inclusive). The - filter is ignored if both - [start_date][google.cloud.talent.v4beta1.ApplicationDateFilter.start_date] - and - [end_date][google.cloud.talent.v4beta1.ApplicationDateFilter.end_date] - are missing. - - Attributes: - start_date (google.type.date_pb2.Date): - Start date. If it's missing, The API matches - profiles with application date not after the end - date. - end_date (google.type.date_pb2.Date): - End date. If it's missing, The API matches - profiles with application date not before the - start date. - """ - - start_date = proto.Field( - proto.MESSAGE, - number=1, - message=date_pb2.Date, - ) - end_date = proto.Field( - proto.MESSAGE, - number=2, - message=date_pb2.Date, - ) - - -class ApplicationOutcomeNotesFilter(proto.Message): - r"""Outcome Notes Filter. - - Attributes: - outcome_notes (str): - Required. User entered or selected outcome reason. The API - does an exact match on the - [Application.outcome_notes][google.cloud.talent.v4beta1.Application.outcome_notes] - in profiles. - negated (bool): - If true, The API excludes all candidates with any - [Application.outcome_notes][google.cloud.talent.v4beta1.Application.outcome_notes] - matching the outcome reason specified in the filter. - """ - - outcome_notes = proto.Field( - proto.STRING, - number=1, - ) - negated = proto.Field( - proto.BOOL, - number=2, - ) - - -class ApplicationJobFilter(proto.Message): - r"""Filter on the job information of Application. - - Attributes: - job_requisition_id (str): - The job requisition id in the application. The API does an - exact match on the - [Job.requisition_id][google.cloud.talent.v4beta1.Job.requisition_id] - of - [Application.job][google.cloud.talent.v4beta1.Application.job] - in profiles. - job_title (str): - The job title in the application. The API does an exact - match on the - [Job.title][google.cloud.talent.v4beta1.Job.title] of - [Application.job][google.cloud.talent.v4beta1.Application.job] - in profiles. - negated (bool): - If true, the API excludes all profiles with any - [Application.job][google.cloud.talent.v4beta1.Application.job] - matching the filters. - """ - - job_requisition_id = proto.Field( - proto.STRING, - number=2, - ) - job_title = proto.Field( - proto.STRING, - number=3, - ) - negated = proto.Field( - proto.BOOL, - number=4, - ) - - -class TimeFilter(proto.Message): - r"""Filter on create timestamp or update timestamp of profiles. - - Attributes: - start_time (google.protobuf.timestamp_pb2.Timestamp): - Start timestamp, matching profiles with the - start time. If this field missing, The API - matches profiles with create / update timestamp - before the end timestamp. - end_time (google.protobuf.timestamp_pb2.Timestamp): - End timestamp, matching profiles with the end - time. If this field missing, The API matches - profiles with create / update timestamp after - the start timestamp. - time_field (google.cloud.talent_v4beta1.types.TimeFilter.TimeField): - Specifies which time field to filter profiles. - - Defaults to - [TimeField.CREATE_TIME][google.cloud.talent.v4beta1.TimeFilter.TimeField.CREATE_TIME]. - """ - - class TimeField(proto.Enum): - r"""Time fields can be used in TimeFilter.""" - TIME_FIELD_UNSPECIFIED = 0 - CREATE_TIME = 1 - UPDATE_TIME = 2 - - start_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - time_field = proto.Field( - proto.ENUM, - number=3, - enum=TimeField, - ) - - -class CandidateAvailabilityFilter(proto.Message): - r"""Deprecated. Use AvailabilityFilter instead. - Filter on availability signals. - - Attributes: - negated (bool): - It is false by default. If true, API excludes - all the potential available profiles. - """ - - negated = proto.Field( - proto.BOOL, - number=1, - ) - - -class AvailabilityFilter(proto.Message): - r"""Filter on availability signals. - - Attributes: - signal_type (google.cloud.talent_v4beta1.types.AvailabilitySignalType): - Required. Type of signal to apply filter on. - range_ (google.cloud.talent_v4beta1.types.TimestampRange): - Required. Range of times to filter candidate - signals by. - required (bool): - If multiple - [AvailabilityFilter][google.cloud.talent.v4beta1.AvailabilityFilter] - are provided, the default behavior is to OR all filters, but - if this field is set to true, this particular - [AvailabilityFilter][google.cloud.talent.v4beta1.AvailabilityFilter] - will be AND'ed against other - [AvailabilityFilter][google.cloud.talent.v4beta1.AvailabilityFilter]. - """ - - signal_type = proto.Field( - proto.ENUM, - number=1, - enum=common.AvailabilitySignalType, - ) - range_ = proto.Field( - proto.MESSAGE, - number=2, - message=common.TimestampRange, - ) - required = proto.Field( - proto.BOOL, - number=3, - ) - - -class PersonNameFilter(proto.Message): - r"""Filter on person name. - - Attributes: - person_name (str): - Required. The person name. For example, "John Smith". - - Can be any combination of - [PersonName.structured_name.given_name][], - [PersonName.structured_name.middle_initial][], - [PersonName.structured_name.family_name][], and - [PersonName.formatted_name][google.cloud.talent.v4beta1.PersonName.formatted_name]. - """ - - person_name = proto.Field( - proto.STRING, - number=1, - ) - - __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/talent_v4beta1/types/job_service.py b/google/cloud/talent_v4beta1/types/job_service.py index 38389157..1e2e3865 100644 --- a/google/cloud/talent_v4beta1/types/job_service.py +++ b/google/cloud/talent_v4beta1/types/job_service.py @@ -213,18 +213,23 @@ class ListJobsRequest(proto.Message): The fields eligible for filtering are: - - ``companyName`` (Required) + - ``companyName`` - ``requisitionId`` - ``status`` Available values: OPEN, EXPIRED, ALL. Defaults to OPEN if no value is specified. + At least one of ``companyName`` and ``requisitionId`` must + present or an INVALID_ARGUMENT error is thrown. + Sample Query: - companyName = "projects/foo/tenants/bar/companies/baz" - companyName = "projects/foo/tenants/bar/companies/baz" AND requisitionId = "req-1" - companyName = "projects/foo/tenants/bar/companies/baz" - AND status = "EXPIRED". + AND status = "EXPIRED" + - requisitionId = "req-1" + - requisitionId = "req-1" AND status = "EXPIRED". page_token (str): The starting point of a query result. page_size (int): @@ -336,16 +341,7 @@ class SearchJobsRequest(proto.Message): Defaults to false. require_precise_result_size (bool): - Controls if the search job request requires the return of a - precise count of the first 300 results. Setting this to - ``true`` ensures consistency in the number of results per - page. Best practice is to set this value to true if a client - allows users to jump directly to a non-sequential search - results page. - - Enabling this flag may adversely impact performance. - - Defaults to false. + This field is deprecated. histogram_queries (Sequence[google.cloud.talent_v4beta1.types.HistogramQuery]): An expression specifies a histogram request against matching jobs. @@ -360,6 +356,8 @@ class SearchJobsRequest(proto.Message): - ``count(numeric_histogram_facet, list of buckets)``: Count the number of matching entities within each bucket. + A maximum of 200 histogram buckets are supported. + Data types: - Histogram facet: facet names with format @@ -394,6 +392,9 @@ class SearchJobsRequest(proto.Message): - company_size: histogram by [CompanySize][google.cloud.talent.v4beta1.CompanySize], for example, "SMALL", "MEDIUM", "BIG". + - publish_time_in_day: histogram by the + [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + in days. Must specify list of numeric buckets in spec. - publish_time_in_month: histogram by the [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] in months. Must specify list of numeric buckets in spec. @@ -458,7 +459,7 @@ class SearchJobsRequest(proto.Message): - ``count(admin1)`` - ``count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000), bucket(100000, MAX)])`` - ``count(string_custom_attribute["some-string-custom-attribute"])`` - - ``count(numeric_custom_attribute["some-numeric-custom-attribute"], [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative"])`` + - ``count(numeric_custom_attribute["some-numeric-custom-attribute"], [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")])`` job_view (google.cloud.talent_v4beta1.types.JobView): The desired job attributes returned for jobs in the search response. Defaults to @@ -568,6 +569,18 @@ class SearchJobsRequest(proto.Message): top of existing relevance score (determined by API algorithm). disable_keyword_match (bool): + This field is deprecated. Please use + [SearchJobsRequest.keyword_match_mode][google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode] + going forward. + + To migrate, disable_keyword_match set to false maps to + [KeywordMatchMode.KEYWORD_MATCH_ALL][google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL], + and disable_keyword_match set to true maps to + [KeywordMatchMode.KEYWORD_MATCH_DISABLED][google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED]. + If + [SearchJobsRequest.keyword_match_mode][google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode] + is set, this field is ignored. + Controls whether to disable exact keyword match on [Job.title][google.cloud.talent.v4beta1.Job.title], [Job.description][google.cloud.talent.v4beta1.Job.description], @@ -593,6 +606,12 @@ class SearchJobsRequest(proto.Message): recall of subsequent search requests. Defaults to false. + keyword_match_mode (google.cloud.talent_v4beta1.types.SearchJobsRequest.KeywordMatchMode): + Controls what keyword match options to use. + + Defaults to + [KeywordMatchMode.KEYWORD_MATCH_ALL][google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL] + if no value is specified. """ class SearchMode(proto.Enum): @@ -616,6 +635,30 @@ class DiversificationLevel(proto.Enum): DISABLED = 1 SIMPLE = 2 + class KeywordMatchMode(proto.Enum): + r"""Controls what keyword matching behavior the search has. When keyword + matching is enabled, a keyword match returns jobs that may not match + given category filters when there are matching keywords. For + example, for the query "program manager" with KeywordMatchMode set + to KEYWORD_MATCH_ALL, a job posting with the title "software + developer," which doesn't fall into "program manager" ontology, and + "program manager" appearing in its description will be surfaced. + + For queries like "cloud" that don't contain title or location + specific ontology, jobs with "cloud" keyword matches are returned + regardless of this enum's value. + + Use + [Company.keyword_searchable_job_custom_attributes][google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes] + if company-specific globally matched custom field/attribute string + values are needed. Enabling keyword match improves recall of + subsequent search requests. + """ + KEYWORD_MATCH_MODE_UNSPECIFIED = 0 + KEYWORD_MATCH_DISABLED = 1 + KEYWORD_MATCH_ALL = 2 + KEYWORD_MATCH_TITLE_ONLY = 3 + class CustomRankingInfo(proto.Message): r"""Custom ranking information for [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. @@ -643,7 +686,7 @@ class CustomRankingInfo(proto.Message): evaluated to a number. Parenthesis are supported to adjust calculation precedence. - The expression must be < 100 characters in length. + The expression must be < 200 characters in length. The expression is considered invalid for a job if the expression references custom attributes that are not @@ -744,6 +787,11 @@ class ImportanceLevel(proto.Enum): proto.BOOL, number=16, ) + keyword_match_mode = proto.Field( + proto.ENUM, + number=18, + enum=KeywordMatchMode, + ) class SearchJobsResponse(proto.Message): @@ -772,13 +820,9 @@ class SearchJobsResponse(proto.Message): This number isn't guaranteed to be accurate. For accurate results, see - [SearchJobsRequest.require_precise_result_size][google.cloud.talent.v4beta1.SearchJobsRequest.require_precise_result_size]. + [SearchJobsResponse.total_size][google.cloud.talent.v4beta1.SearchJobsResponse.total_size]. total_size (int): - The precise result count, which is available only if the - client set - [SearchJobsRequest.require_precise_result_size][google.cloud.talent.v4beta1.SearchJobsRequest.require_precise_result_size] - to ``true``, or if the response is the last page of results. - Otherwise, the value is ``-1``. + The precise result count with limit 100,000. metadata (google.cloud.talent_v4beta1.types.ResponseMetadata): Additional information for the API invocation, such as the request tracking id. diff --git a/google/cloud/talent_v4beta1/types/profile.py b/google/cloud/talent_v4beta1/types/profile.py deleted file mode 100644 index 7b4029b3..00000000 --- a/google/cloud/talent_v4beta1/types/profile.py +++ /dev/null @@ -1,1327 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore -from google.type import date_pb2 # type: ignore -from google.type import postal_address_pb2 # type: ignore -import proto # type: ignore - -from google.cloud.talent_v4beta1.types import common - -__protobuf__ = proto.module( - package="google.cloud.talent.v4beta1", - manifest={ - "Profile", - "AvailabilitySignal", - "Resume", - "PersonName", - "Address", - "Email", - "Phone", - "PersonalUri", - "AdditionalContactInfo", - "EmploymentRecord", - "EducationRecord", - "Degree", - "Activity", - "Publication", - "Patent", - }, -) - - -class Profile(proto.Message): - r"""A resource that represents the profile for a job candidate - (also referred to as a "single-source profile"). - - Attributes: - name (str): - Required during profile update. - - Resource name assigned to a profile by the API. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}", - for example, "projects/foo/tenants/bar/profiles/baz". - external_id (str): - Profile's id in client system, if available. This value is - unique for each profile inside a tenant. An error is thrown - if another profile with the same external_id is created. - - The maximum number of bytes allowed is 100. - source (str): - The source description indicating where the - profile is acquired. - For example, if a candidate profile is acquired - from a resume, the user can input "resume" here - to indicate the source. - - The maximum number of bytes allowed is 100. - uri (str): - The URI set by clients that links to this - profile's client-side copy. - The maximum number of bytes allowed is 4000. - group_id (str): - The cluster id of the profile to associate with other - profile(s) for the same candidate. - - This field should be generated by the customer. If a value - is not provided, a random UUID is assigned to this field of - the profile. - - This is used to link multiple profiles to the same - candidate. For example, a client has a candidate with two - profiles, where one was created recently and the other one - was created 5 years ago. These two profiles may be very - different. The clients can create the first profile and get - a generated - [group_id][google.cloud.talent.v4beta1.Profile.group_id], - and assign it when the second profile is created, indicating - these two profiles are referring to the same candidate. - is_hirable (google.protobuf.wrappers_pb2.BoolValue): - Indicates the hirable status of the - candidate. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The timestamp when the profile was first - created at this source. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The timestamp when the profile was last - updated at this source. - candidate_update_time (google.protobuf.timestamp_pb2.Timestamp): - The timestamp when the profile was last updated as a result - of a direct or indirect action by a candidate. - - These actions include: - - - Direct actions such as the candidate submitting a new - resume as part of a job application to the agency, using - a self-service tool such as a website to update their - profile, and so on. - - Indirect actions by the candidate such as uploading a - resume to a job board that is collected by the agency - through a feed, providing a resume to a recruiter who - then uploads it into the ATS, and so on. - - Updates made to the candidate's profile by the recruiter - as a result of interacting with the candidate (for - example adding a skill or work preference, and so on). - Changes to - [recruiting_notes][google.cloud.talent.v4beta1.Profile.recruiting_notes] - are specifically excluded from this action type. - - Note: - [candidate_update_time][google.cloud.talent.v4beta1.Profile.candidate_update_time] - must be greater than or equal to - [resume_update_time][google.cloud.talent.v4beta1.Profile.resume_update_time] - or an error is thrown. - resume_update_time (google.protobuf.timestamp_pb2.Timestamp): - The timestamp when the candidate's resume was added or - updated on the candidate's profile. Whether that resume was - directly uploaded by a candidate, pulled from a 3rd party - job board feed, added by a recruiter, and so on. - - If this field is updated, it's expected that - [resume][google.cloud.talent.v4beta1.Profile.resume] is - provided in the create or update calls. - resume (google.cloud.talent_v4beta1.types.Resume): - The resume representing this profile. - person_names (Sequence[google.cloud.talent_v4beta1.types.PersonName]): - The names of the candidate this profile - references. - Currently only one person name is supported. - addresses (Sequence[google.cloud.talent_v4beta1.types.Address]): - The candidate's postal addresses. It's highly recommended to - input this information as accurately as possible to help - improve search quality. Here are some recommendations: - - - Provide - [Address.usage][google.cloud.talent.v4beta1.Address.usage] - if possible, especially if the address is PERSONAL. - During a search only personal addresses are considered. - If there is no such address, all addresses with - unspecified usage are assumed to be personal. - - Provide - [Address.current][google.cloud.talent.v4beta1.Address.current] - for the current address if possible. During a search, - only current addresses are considered. If there is no - such address, all addresses are assumed to be current. - - When displaying a candidate's addresses, it is sometimes - desirable to limit the number of addresses shown. In these - cases we recommend that you display the addresses in the - following order of priority: - - 1. [Address.usage][google.cloud.talent.v4beta1.Address.usage] - is PERSONAL and - [Address.current][google.cloud.talent.v4beta1.Address.current] - is true. - 2. [Address.usage][google.cloud.talent.v4beta1.Address.usage] - is PERSONAL and - [Address.current][google.cloud.talent.v4beta1.Address.current] - is false or not set. - 3. [Address.usage][google.cloud.talent.v4beta1.Address.usage] - is CONTACT_INFO_USAGE_UNSPECIFIED and - [Address.current][google.cloud.talent.v4beta1.Address.current] - is true. - 4. [Address.usage][google.cloud.talent.v4beta1.Address.usage] - is CONTACT_INFO_USAGE_UNSPECIFIED and - [Address.current][google.cloud.talent.v4beta1.Address.current] - is false or not set. - email_addresses (Sequence[google.cloud.talent_v4beta1.types.Email]): - The candidate's email addresses. - phone_numbers (Sequence[google.cloud.talent_v4beta1.types.Phone]): - The candidate's phone number(s). - personal_uris (Sequence[google.cloud.talent_v4beta1.types.PersonalUri]): - The candidate's personal URIs. - additional_contact_info (Sequence[google.cloud.talent_v4beta1.types.AdditionalContactInfo]): - Available contact information besides - [addresses][google.cloud.talent.v4beta1.Profile.addresses], - [email_addresses][google.cloud.talent.v4beta1.Profile.email_addresses], - [phone_numbers][google.cloud.talent.v4beta1.Profile.phone_numbers] - and - [personal_uris][google.cloud.talent.v4beta1.Profile.personal_uris]. - For example, Hang-out, Skype. - employment_records (Sequence[google.cloud.talent_v4beta1.types.EmploymentRecord]): - The employment history records of the candidate. It's highly - recommended to input this information as accurately as - possible to help improve search quality. Here are some - recommendations: - - - Specify the start and end dates of the employment - records. - - List different employment types separately, no matter how - minor the change is. For example, only job title is - changed from "software engineer" to "senior software - engineer". - - Provide - [EmploymentRecord.is_current][google.cloud.talent.v4beta1.EmploymentRecord.is_current] - for the current employment if possible. If not, it's - inferred from user inputs. - - The limitation for max number of employment records is 100. - education_records (Sequence[google.cloud.talent_v4beta1.types.EducationRecord]): - The education history record of the candidate. It's highly - recommended to input this information as accurately as - possible to help improve search quality. Here are some - recommendations: - - - Specify the start and end dates of the education records. - - List each education type separately, no matter how minor - the change is. For example, the profile contains the - education experience from the same school but different - degrees. - - Provide - [EducationRecord.is_current][google.cloud.talent.v4beta1.EducationRecord.is_current] - for the current education if possible. If not, it's - inferred from user inputs. - - The limitation for max number of education records is 100. - skills (Sequence[google.cloud.talent_v4beta1.types.Skill]): - The skill set of the candidate. It's highly - recommended to provide as much information as - possible to help improve the search quality. - The limitation for max number of skills is 500. - activities (Sequence[google.cloud.talent_v4beta1.types.Activity]): - The individual or collaborative activities which the - candidate has participated in, for example, open-source - projects, class assignments that aren't listed in - [employment_records][google.cloud.talent.v4beta1.Profile.employment_records]. - - The limitation for max number of activities is 50. - publications (Sequence[google.cloud.talent_v4beta1.types.Publication]): - The publications published by the candidate. - The limitation for max number of publications is - 50. - patents (Sequence[google.cloud.talent_v4beta1.types.Patent]): - The patents acquired by the candidate. - certifications (Sequence[google.cloud.talent_v4beta1.types.Certification]): - The certifications acquired by the candidate. - applications (Sequence[str]): - Output only. The resource names of the - candidate's applications. - assignments (Sequence[str]): - Output only. The resource names of the - candidate's assignments. - custom_attributes (Mapping[str, google.cloud.talent_v4beta1.types.CustomAttribute]): - A map of fields to hold both filterable and non-filterable - custom profile attributes that aren't covered by the - provided structured fields. See - [CustomAttribute][google.cloud.talent.v4beta1.CustomAttribute] - for more details. - - At most 100 filterable and at most 100 unfilterable keys are - supported. If limit is exceeded, an error is thrown. Custom - attributes are ``unfilterable`` by default. These are - filterable when the ``filterable`` flag is set to ``true``. - - Numeric custom attributes: each key can only map to one - numeric value, otherwise an error is thrown. Client can also - filter on numeric custom attributes using '>', '<' or '=' - operators. - - String custom attributes: each key can map up to 50 string - values. For filterable string value, each value has a byte - size of no more than 256B. For unfilterable string values, - the maximum byte size of a single key is 64B. An error is - thrown for any request exceeding the limit. The maximum - total byte size is 10KB. - processed (bool): - Output only. Indicates if a summarized - profile was created as part of the profile - creation API call. This flag does not indicate - whether a profile is searchable or not. - keyword_snippet (str): - Output only. Keyword snippet shows how the search result is - related to a search query. This is only returned in - [SearchProfilesResponse][google.cloud.talent.v4beta1.SearchProfilesResponse]. - availability_signals (Sequence[google.cloud.talent_v4beta1.types.AvailabilitySignal]): - Output only. Candidate's availability - signals. - derived_addresses (Sequence[google.cloud.talent_v4beta1.types.Location]): - Output only. Derived locations of the profile, resolved from - [Profile.addresses][google.cloud.talent.v4beta1.Profile.addresses]. - - [derived_addresses][google.cloud.talent.v4beta1.Profile.derived_addresses] - are exactly matched to - [Profile.addresses][google.cloud.talent.v4beta1.Profile.addresses] - in the same order. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - external_id = proto.Field( - proto.STRING, - number=2, - ) - source = proto.Field( - proto.STRING, - number=3, - ) - uri = proto.Field( - proto.STRING, - number=4, - ) - group_id = proto.Field( - proto.STRING, - number=5, - ) - is_hirable = proto.Field( - proto.MESSAGE, - number=6, - message=wrappers_pb2.BoolValue, - ) - create_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - candidate_update_time = proto.Field( - proto.MESSAGE, - number=67, - message=timestamp_pb2.Timestamp, - ) - resume_update_time = proto.Field( - proto.MESSAGE, - number=68, - message=timestamp_pb2.Timestamp, - ) - resume = proto.Field( - proto.MESSAGE, - number=53, - message="Resume", - ) - person_names = proto.RepeatedField( - proto.MESSAGE, - number=11, - message="PersonName", - ) - addresses = proto.RepeatedField( - proto.MESSAGE, - number=12, - message="Address", - ) - email_addresses = proto.RepeatedField( - proto.MESSAGE, - number=13, - message="Email", - ) - phone_numbers = proto.RepeatedField( - proto.MESSAGE, - number=14, - message="Phone", - ) - personal_uris = proto.RepeatedField( - proto.MESSAGE, - number=15, - message="PersonalUri", - ) - additional_contact_info = proto.RepeatedField( - proto.MESSAGE, - number=16, - message="AdditionalContactInfo", - ) - employment_records = proto.RepeatedField( - proto.MESSAGE, - number=17, - message="EmploymentRecord", - ) - education_records = proto.RepeatedField( - proto.MESSAGE, - number=18, - message="EducationRecord", - ) - skills = proto.RepeatedField( - proto.MESSAGE, - number=19, - message=common.Skill, - ) - activities = proto.RepeatedField( - proto.MESSAGE, - number=20, - message="Activity", - ) - publications = proto.RepeatedField( - proto.MESSAGE, - number=21, - message="Publication", - ) - patents = proto.RepeatedField( - proto.MESSAGE, - number=22, - message="Patent", - ) - certifications = proto.RepeatedField( - proto.MESSAGE, - number=23, - message=common.Certification, - ) - applications = proto.RepeatedField( - proto.STRING, - number=47, - ) - assignments = proto.RepeatedField( - proto.STRING, - number=48, - ) - custom_attributes = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=26, - message=common.CustomAttribute, - ) - processed = proto.Field( - proto.BOOL, - number=27, - ) - keyword_snippet = proto.Field( - proto.STRING, - number=28, - ) - availability_signals = proto.RepeatedField( - proto.MESSAGE, - number=70, - message="AvailabilitySignal", - ) - derived_addresses = proto.RepeatedField( - proto.MESSAGE, - number=64, - message=common.Location, - ) - - -class AvailabilitySignal(proto.Message): - r"""Candidate availability signal. - - Attributes: - type_ (google.cloud.talent_v4beta1.types.AvailabilitySignalType): - Type of signal. - last_update_time (google.protobuf.timestamp_pb2.Timestamp): - Timestamp of when the given availability - activity last happened. - filter_satisfied (google.protobuf.wrappers_pb2.BoolValue): - Indicates if the - [last_update_time][google.cloud.talent.v4beta1.AvailabilitySignal.last_update_time] - is within - [AvailabilityFilter.range][google.cloud.talent.v4beta1.AvailabilityFilter.range]. - - Returned only in a search response when there is an - [AvailabilityFilter][google.cloud.talent.v4beta1.AvailabilityFilter] - in - [ProfileQuery.availability_filters][google.cloud.talent.v4beta1.ProfileQuery.availability_filters] - where - [signal_type][google.cloud.talent.v4beta1.AvailabilityFilter.signal_type] - matches - [type][google.cloud.talent.v4beta1.AvailabilitySignal.type]. - """ - - type_ = proto.Field( - proto.ENUM, - number=1, - enum=common.AvailabilitySignalType, - ) - last_update_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - filter_satisfied = proto.Field( - proto.MESSAGE, - number=3, - message=wrappers_pb2.BoolValue, - ) - - -class Resume(proto.Message): - r"""Resource that represents a resume. - - Attributes: - structured_resume (str): - Users can create a profile with only this field field, if - [resume_type][google.cloud.talent.v4beta1.Resume.resume_type] - is - [HRXML][google.cloud.talent.v4beta1.Resume.ResumeType.HRXML]. - For example, the API parses this field and creates a profile - with all structured fields populated. - [EmploymentRecord][google.cloud.talent.v4beta1.EmploymentRecord], - [EducationRecord][google.cloud.talent.v4beta1.EducationRecord], - and so on. An error is thrown if this field cannot be - parsed. - - Note that the use of the functionality offered by this field - to extract data from resumes is an Alpha feature and as such - is not covered by any SLA. - resume_type (google.cloud.talent_v4beta1.types.Resume.ResumeType): - The format of - [structured_resume][google.cloud.talent.v4beta1.Resume.structured_resume]. - """ - - class ResumeType(proto.Enum): - r"""The format of a structured resume.""" - RESUME_TYPE_UNSPECIFIED = 0 - HRXML = 1 - OTHER_RESUME_TYPE = 2 - - structured_resume = proto.Field( - proto.STRING, - number=1, - ) - resume_type = proto.Field( - proto.ENUM, - number=2, - enum=ResumeType, - ) - - -class PersonName(proto.Message): - r"""Resource that represents the name of a person. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - formatted_name (str): - A string represents a person's full name. For - example, "Dr. John Smith". - Number of characters allowed is 100. - - This field is a member of `oneof`_ ``person_name``. - structured_name (google.cloud.talent_v4beta1.types.PersonName.PersonStructuredName): - A person's name in a structured way (last - name, first name, suffix, and so on.) - - This field is a member of `oneof`_ ``person_name``. - preferred_name (str): - Preferred name for the person. This field is ignored if - [structured_name][google.cloud.talent.v4beta1.PersonName.structured_name] - is provided. - - Number of characters allowed is 100. - """ - - class PersonStructuredName(proto.Message): - r"""Resource that represents a person's structured name. - - Attributes: - given_name (str): - Given/first name. - - It's derived from - [formatted_name][google.cloud.talent.v4beta1.PersonName.formatted_name] - if not provided. - - Number of characters allowed is 100. - preferred_name (str): - Preferred given/first name or nickname. - Number of characters allowed is 100. - middle_initial (str): - Middle initial. - - It's derived from - [formatted_name][google.cloud.talent.v4beta1.PersonName.formatted_name] - if not provided. - - Number of characters allowed is 20. - family_name (str): - Family/last name. - - It's derived from - [formatted_name][google.cloud.talent.v4beta1.PersonName.formatted_name] - if not provided. - - Number of characters allowed is 100. - suffixes (Sequence[str]): - Suffixes. - Number of characters allowed is 20. - prefixes (Sequence[str]): - Prefixes. - Number of characters allowed is 20. - """ - - given_name = proto.Field( - proto.STRING, - number=1, - ) - preferred_name = proto.Field( - proto.STRING, - number=6, - ) - middle_initial = proto.Field( - proto.STRING, - number=2, - ) - family_name = proto.Field( - proto.STRING, - number=3, - ) - suffixes = proto.RepeatedField( - proto.STRING, - number=4, - ) - prefixes = proto.RepeatedField( - proto.STRING, - number=5, - ) - - formatted_name = proto.Field( - proto.STRING, - number=1, - oneof="person_name", - ) - structured_name = proto.Field( - proto.MESSAGE, - number=2, - oneof="person_name", - message=PersonStructuredName, - ) - preferred_name = proto.Field( - proto.STRING, - number=3, - ) - - -class Address(proto.Message): - r"""Resource that represents a address. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - usage (google.cloud.talent_v4beta1.types.ContactInfoUsage): - The usage of the address. For example, - SCHOOL, WORK, PERSONAL. - unstructured_address (str): - Unstructured address. - For example, "1600 Amphitheatre Pkwy, Mountain - View, CA 94043", "Sunnyvale, California". - - Number of characters allowed is 100. - - This field is a member of `oneof`_ ``address``. - structured_address (google.type.postal_address_pb2.PostalAddress): - Structured address that contains street - address, city, state, country, and so on. - - This field is a member of `oneof`_ ``address``. - current (google.protobuf.wrappers_pb2.BoolValue): - Indicates if it's the person's current - address. - """ - - usage = proto.Field( - proto.ENUM, - number=1, - enum=common.ContactInfoUsage, - ) - unstructured_address = proto.Field( - proto.STRING, - number=2, - oneof="address", - ) - structured_address = proto.Field( - proto.MESSAGE, - number=3, - oneof="address", - message=postal_address_pb2.PostalAddress, - ) - current = proto.Field( - proto.MESSAGE, - number=4, - message=wrappers_pb2.BoolValue, - ) - - -class Email(proto.Message): - r"""Resource that represents a person's email address. - - Attributes: - usage (google.cloud.talent_v4beta1.types.ContactInfoUsage): - The usage of the email address. For example, - SCHOOL, WORK, PERSONAL. - email_address (str): - Email address. - Number of characters allowed is 4,000. - """ - - usage = proto.Field( - proto.ENUM, - number=1, - enum=common.ContactInfoUsage, - ) - email_address = proto.Field( - proto.STRING, - number=2, - ) - - -class Phone(proto.Message): - r"""Resource that represents a person's telephone number. - - Attributes: - usage (google.cloud.talent_v4beta1.types.ContactInfoUsage): - The usage of the phone. For example, SCHOOL, - WORK, PERSONAL. - type_ (google.cloud.talent_v4beta1.types.Phone.PhoneType): - The phone type. For example, LANDLINE, - MOBILE, FAX. - number (str): - Phone number. - Any phone formats are supported and only exact - matches are performed on searches. For example, - if a phone number in profile is provided in the - format of "(xxx)xxx-xxxx", in profile searches - the same phone format has to be provided. - - Number of characters allowed is 20. - when_available (str): - When this number is available. Any - descriptive string is expected. - Number of characters allowed is 100. - """ - - class PhoneType(proto.Enum): - r"""Enum that represents the type of the telephone.""" - PHONE_TYPE_UNSPECIFIED = 0 - LANDLINE = 1 - MOBILE = 2 - FAX = 3 - PAGER = 4 - TTY_OR_TDD = 5 - VOICEMAIL = 6 - VIRTUAL = 7 - VOIP = 8 - MOBILE_OR_LANDLINE = 9 - - usage = proto.Field( - proto.ENUM, - number=1, - enum=common.ContactInfoUsage, - ) - type_ = proto.Field( - proto.ENUM, - number=2, - enum=PhoneType, - ) - number = proto.Field( - proto.STRING, - number=3, - ) - when_available = proto.Field( - proto.STRING, - number=4, - ) - - -class PersonalUri(proto.Message): - r"""Resource that represents a valid URI for a personal use. - - Attributes: - uri (str): - The personal URI. - Number of characters allowed is 4,000. - """ - - uri = proto.Field( - proto.STRING, - number=1, - ) - - -class AdditionalContactInfo(proto.Message): - r"""Resource that represents contact information other than - phone, email, URI and addresses. - - Attributes: - usage (google.cloud.talent_v4beta1.types.ContactInfoUsage): - The usage of this contact method. For - example, SCHOOL, WORK, PERSONAL. - name (str): - The name of the contact method. - For example, "hangout", "skype". - - Number of characters allowed is 100. - contact_id (str): - The contact id. - Number of characters allowed is 100. - """ - - usage = proto.Field( - proto.ENUM, - number=1, - enum=common.ContactInfoUsage, - ) - name = proto.Field( - proto.STRING, - number=2, - ) - contact_id = proto.Field( - proto.STRING, - number=3, - ) - - -class EmploymentRecord(proto.Message): - r"""Resource that represents an employment record of a candidate. - - Attributes: - start_date (google.type.date_pb2.Date): - Start date of the employment. - end_date (google.type.date_pb2.Date): - End date of the employment. - employer_name (str): - The name of the employer - company/organization. - For example, "Google", "Alphabet", and so on. - Number of characters allowed is 250. - division_name (str): - The division name of the employment. - For example, division, department, client, and - so on. - Number of characters allowed is 100. - address (google.cloud.talent_v4beta1.types.Address): - The physical address of the employer. - job_title (str): - The job title of the employment. - For example, "Software Engineer", "Data - Scientist", and so on. - Number of characters allowed is 250. - job_description (str): - The description of job content. - Number of characters allowed is 100,000. - is_supervisor (google.protobuf.wrappers_pb2.BoolValue): - If the jobs is a supervisor position. - is_self_employed (google.protobuf.wrappers_pb2.BoolValue): - If this employment is self-employed. - is_current (google.protobuf.wrappers_pb2.BoolValue): - If this employment is current. - job_title_snippet (str): - Output only. The job title snippet shows how the - [job_title][google.cloud.talent.v4beta1.EmploymentRecord.job_title] - is related to a search query. It's empty if the - [job_title][google.cloud.talent.v4beta1.EmploymentRecord.job_title] - isn't related to the search query. - job_description_snippet (str): - Output only. The job description snippet shows how the - [job_description][google.cloud.talent.v4beta1.EmploymentRecord.job_description] - is related to a search query. It's empty if the - [job_description][google.cloud.talent.v4beta1.EmploymentRecord.job_description] - isn't related to the search query. - employer_name_snippet (str): - Output only. The employer name snippet shows how the - [employer_name][google.cloud.talent.v4beta1.EmploymentRecord.employer_name] - is related to a search query. It's empty if the - [employer_name][google.cloud.talent.v4beta1.EmploymentRecord.employer_name] - isn't related to the search query. - """ - - start_date = proto.Field( - proto.MESSAGE, - number=1, - message=date_pb2.Date, - ) - end_date = proto.Field( - proto.MESSAGE, - number=2, - message=date_pb2.Date, - ) - employer_name = proto.Field( - proto.STRING, - number=3, - ) - division_name = proto.Field( - proto.STRING, - number=4, - ) - address = proto.Field( - proto.MESSAGE, - number=5, - message="Address", - ) - job_title = proto.Field( - proto.STRING, - number=6, - ) - job_description = proto.Field( - proto.STRING, - number=7, - ) - is_supervisor = proto.Field( - proto.MESSAGE, - number=8, - message=wrappers_pb2.BoolValue, - ) - is_self_employed = proto.Field( - proto.MESSAGE, - number=9, - message=wrappers_pb2.BoolValue, - ) - is_current = proto.Field( - proto.MESSAGE, - number=10, - message=wrappers_pb2.BoolValue, - ) - job_title_snippet = proto.Field( - proto.STRING, - number=11, - ) - job_description_snippet = proto.Field( - proto.STRING, - number=12, - ) - employer_name_snippet = proto.Field( - proto.STRING, - number=13, - ) - - -class EducationRecord(proto.Message): - r"""Resource that represents an education record of a candidate. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - start_date (google.type.date_pb2.Date): - The start date of the education. - end_date (google.type.date_pb2.Date): - The end date of the education. - expected_graduation_date (google.type.date_pb2.Date): - The expected graduation date if currently - pursuing a degree. - school_name (str): - The name of the school or institution. - For example, "Stanford University", "UC - Berkeley", and so on. - Number of characters allowed is 250. - address (google.cloud.talent_v4beta1.types.Address): - The physical address of the education - institution. - degree_description (str): - The full description of the degree. - For example, "Master of Science in Computer - Science", "B.S in Math". - Number of characters allowed is 100. - - This field is a member of `oneof`_ ``degree``. - structured_degree (google.cloud.talent_v4beta1.types.Degree): - The structured notation of the degree. - - This field is a member of `oneof`_ ``degree``. - description (str): - The description of the education. - Number of characters allowed is 100,000. - is_current (google.protobuf.wrappers_pb2.BoolValue): - If this education is current. - school_name_snippet (str): - Output only. The school name snippet shows how the - [school_name][google.cloud.talent.v4beta1.EducationRecord.school_name] - is related to a search query in search result. It's empty if - the - [school_name][google.cloud.talent.v4beta1.EducationRecord.school_name] - isn't related to the search query. - degree_snippet (str): - Output only. The job description snippet shows how the - [Degree][google.cloud.talent.v4beta1.Degree] is related to a - search query in search result. It's empty if the - [Degree][google.cloud.talent.v4beta1.Degree] isn't related - to the search query. - """ - - start_date = proto.Field( - proto.MESSAGE, - number=1, - message=date_pb2.Date, - ) - end_date = proto.Field( - proto.MESSAGE, - number=2, - message=date_pb2.Date, - ) - expected_graduation_date = proto.Field( - proto.MESSAGE, - number=3, - message=date_pb2.Date, - ) - school_name = proto.Field( - proto.STRING, - number=4, - ) - address = proto.Field( - proto.MESSAGE, - number=5, - message="Address", - ) - degree_description = proto.Field( - proto.STRING, - number=6, - oneof="degree", - ) - structured_degree = proto.Field( - proto.MESSAGE, - number=7, - oneof="degree", - message="Degree", - ) - description = proto.Field( - proto.STRING, - number=8, - ) - is_current = proto.Field( - proto.MESSAGE, - number=9, - message=wrappers_pb2.BoolValue, - ) - school_name_snippet = proto.Field( - proto.STRING, - number=10, - ) - degree_snippet = proto.Field( - proto.STRING, - number=11, - ) - - -class Degree(proto.Message): - r"""Resource that represents a degree pursuing or acquired by a - candidate. - - Attributes: - degree_type (google.cloud.talent_v4beta1.types.DegreeType): - ISCED degree type. - degree_name (str): - Full Degree name. - For example, "B.S.", "Master of Arts", and so - on. - Number of characters allowed is 100. - fields_of_study (Sequence[str]): - Fields of study for the degree. - For example, "Computer science", "engineering". - Number of characters allowed is 100. - """ - - degree_type = proto.Field( - proto.ENUM, - number=1, - enum=common.DegreeType, - ) - degree_name = proto.Field( - proto.STRING, - number=2, - ) - fields_of_study = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class Activity(proto.Message): - r"""Resource that represents an individual or collaborative - activity participated in by a candidate, for example, an - open-source project, a class assignment, and so on. - - Attributes: - display_name (str): - Activity display name. - Number of characters allowed is 100. - description (str): - Activity description. - Number of characters allowed is 100,000. - uri (str): - Activity URI. - Number of characters allowed is 4,000. - create_date (google.type.date_pb2.Date): - The first creation date of the activity. - update_date (google.type.date_pb2.Date): - The last update date of the activity. - team_members (Sequence[str]): - A list of team members involved in this - activity. - Number of characters allowed is 100. - - The limitation for max number of team members is - 50. - skills_used (Sequence[google.cloud.talent_v4beta1.types.Skill]): - A list of skills used in this activity. - The limitation for max number of skills used is - 50. - activity_name_snippet (str): - Output only. Activity name snippet shows how the - [display_name][google.cloud.talent.v4beta1.Activity.display_name] - is related to a search query. It's empty if the - [display_name][google.cloud.talent.v4beta1.Activity.display_name] - isn't related to the search query. - activity_description_snippet (str): - Output only. Activity description snippet shows how the - [description][google.cloud.talent.v4beta1.Activity.description] - is related to a search query. It's empty if the - [description][google.cloud.talent.v4beta1.Activity.description] - isn't related to the search query. - skills_used_snippet (Sequence[str]): - Output only. Skill used snippet shows how the corresponding - [skills_used][google.cloud.talent.v4beta1.Activity.skills_used] - are related to a search query. It's empty if the - corresponding - [skills_used][google.cloud.talent.v4beta1.Activity.skills_used] - are not related to the search query. - """ - - display_name = proto.Field( - proto.STRING, - number=1, - ) - description = proto.Field( - proto.STRING, - number=2, - ) - uri = proto.Field( - proto.STRING, - number=3, - ) - create_date = proto.Field( - proto.MESSAGE, - number=4, - message=date_pb2.Date, - ) - update_date = proto.Field( - proto.MESSAGE, - number=5, - message=date_pb2.Date, - ) - team_members = proto.RepeatedField( - proto.STRING, - number=6, - ) - skills_used = proto.RepeatedField( - proto.MESSAGE, - number=7, - message=common.Skill, - ) - activity_name_snippet = proto.Field( - proto.STRING, - number=8, - ) - activity_description_snippet = proto.Field( - proto.STRING, - number=9, - ) - skills_used_snippet = proto.RepeatedField( - proto.STRING, - number=10, - ) - - -class Publication(proto.Message): - r"""Resource that represents a publication resource of a - candidate. - - Attributes: - authors (Sequence[str]): - A list of author names. - Number of characters allowed is 100. - title (str): - The title of the publication. - Number of characters allowed is 100. - description (str): - The description of the publication. - Number of characters allowed is 100,000. - journal (str): - The journal name of the publication. - Number of characters allowed is 100. - volume (str): - Volume number. - Number of characters allowed is 100. - publisher (str): - The publisher of the journal. - Number of characters allowed is 100. - publication_date (google.type.date_pb2.Date): - The publication date. - publication_type (str): - The publication type. - Number of characters allowed is 100. - isbn (str): - ISBN number. - Number of characters allowed is 100. - """ - - authors = proto.RepeatedField( - proto.STRING, - number=1, - ) - title = proto.Field( - proto.STRING, - number=2, - ) - description = proto.Field( - proto.STRING, - number=3, - ) - journal = proto.Field( - proto.STRING, - number=4, - ) - volume = proto.Field( - proto.STRING, - number=5, - ) - publisher = proto.Field( - proto.STRING, - number=6, - ) - publication_date = proto.Field( - proto.MESSAGE, - number=7, - message=date_pb2.Date, - ) - publication_type = proto.Field( - proto.STRING, - number=8, - ) - isbn = proto.Field( - proto.STRING, - number=9, - ) - - -class Patent(proto.Message): - r"""Resource that represents the patent acquired by a candidate. - - Attributes: - display_name (str): - Name of the patent. - Number of characters allowed is 100. - inventors (Sequence[str]): - A list of inventors' names. - Number of characters allowed for each is 100. - patent_status (str): - The status of the patent. - Number of characters allowed is 100. - patent_status_date (google.type.date_pb2.Date): - The date the last time the status of the - patent was checked. - patent_filing_date (google.type.date_pb2.Date): - The date that the patent was filed. - patent_office (str): - The name of the patent office. - Number of characters allowed is 100. - patent_number (str): - The number of the patent. - Number of characters allowed is 100. - patent_description (str): - The description of the patent. - Number of characters allowed is 100,000. - skills_used (Sequence[google.cloud.talent_v4beta1.types.Skill]): - The skills used in this patent. - """ - - display_name = proto.Field( - proto.STRING, - number=1, - ) - inventors = proto.RepeatedField( - proto.STRING, - number=2, - ) - patent_status = proto.Field( - proto.STRING, - number=3, - ) - patent_status_date = proto.Field( - proto.MESSAGE, - number=4, - message=date_pb2.Date, - ) - patent_filing_date = proto.Field( - proto.MESSAGE, - number=5, - message=date_pb2.Date, - ) - patent_office = proto.Field( - proto.STRING, - number=6, - ) - patent_number = proto.Field( - proto.STRING, - number=7, - ) - patent_description = proto.Field( - proto.STRING, - number=8, - ) - skills_used = proto.RepeatedField( - proto.MESSAGE, - number=9, - message=common.Skill, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/talent_v4beta1/types/profile_service.py b/google/cloud/talent_v4beta1/types/profile_service.py deleted file mode 100644 index 6542459c..00000000 --- a/google/cloud/talent_v4beta1/types/profile_service.py +++ /dev/null @@ -1,617 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from google.protobuf import field_mask_pb2 # type: ignore -import proto # type: ignore - -from google.cloud.talent_v4beta1.types import common, filters, histogram -from google.cloud.talent_v4beta1.types import profile as gct_profile - -__protobuf__ = proto.module( - package="google.cloud.talent.v4beta1", - manifest={ - "ListProfilesRequest", - "ListProfilesResponse", - "CreateProfileRequest", - "GetProfileRequest", - "UpdateProfileRequest", - "DeleteProfileRequest", - "SearchProfilesRequest", - "SearchProfilesResponse", - "SummarizedProfile", - }, -) - - -class ListProfilesRequest(proto.Message): - r"""List profiles request. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - profile is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenants/bar". - filter (str): - The filter string specifies the profiles to be enumerated. - - Supported operator: =, AND - - The field(s) eligible for filtering are: - - - ``externalId`` - - ``groupId`` - - externalId and groupId cannot be specified at the same time. - If both externalId and groupId are provided, the API will - return a bad request error. - - Sample Query: - - - externalId = "externalId-1" - - groupId = "groupId-1". - page_token (str): - The token that specifies the current offset (that is, - starting result). - - Please set the value to - [ListProfilesResponse.next_page_token][google.cloud.talent.v4beta1.ListProfilesResponse.next_page_token] - to continue the list. - page_size (int): - The maximum number of profiles to be - returned, at most 100. - Default is 100 unless a positive number smaller - than 100 is specified. - read_mask (google.protobuf.field_mask_pb2.FieldMask): - A field mask to specify the profile fields to be listed in - response. All fields are listed if it is unset. - - Valid values are: - - - name - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - filter = proto.Field( - proto.STRING, - number=5, - ) - page_token = proto.Field( - proto.STRING, - number=2, - ) - page_size = proto.Field( - proto.INT32, - number=3, - ) - read_mask = proto.Field( - proto.MESSAGE, - number=4, - message=field_mask_pb2.FieldMask, - ) - - -class ListProfilesResponse(proto.Message): - r"""The List profiles response object. - - Attributes: - profiles (Sequence[google.cloud.talent_v4beta1.types.Profile]): - Profiles for the specific tenant. - next_page_token (str): - A token to retrieve the next page of results. - This is empty if there are no more results. - """ - - @property - def raw_page(self): - return self - - profiles = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gct_profile.Profile, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class CreateProfileRequest(proto.Message): - r"""Create profile request. - - Attributes: - parent (str): - Required. The name of the tenant this profile belongs to. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenants/bar". - profile (google.cloud.talent_v4beta1.types.Profile): - Required. The profile to be created. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - profile = proto.Field( - proto.MESSAGE, - number=2, - message=gct_profile.Profile, - ) - - -class GetProfileRequest(proto.Message): - r"""Get profile request. - - Attributes: - name (str): - Required. Resource name of the profile to get. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateProfileRequest(proto.Message): - r"""Update profile request - - Attributes: - profile (google.cloud.talent_v4beta1.types.Profile): - Required. Profile to be updated. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - A field mask to specify the profile fields to - update. - A full update is performed if it is unset. - """ - - profile = proto.Field( - proto.MESSAGE, - number=1, - message=gct_profile.Profile, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteProfileRequest(proto.Message): - r"""Delete profile request. - - Attributes: - name (str): - Required. Resource name of the profile to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". - For example, "projects/foo/tenants/bar/profiles/baz". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class SearchProfilesRequest(proto.Message): - r"""The request body of the ``SearchProfiles`` call. - - Attributes: - parent (str): - Required. The resource name of the tenant to search within. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenants/bar". - request_metadata (google.cloud.talent_v4beta1.types.RequestMetadata): - Required. The meta information collected - about the profile search user. This is used to - improve the search quality of the service. These - values are provided by users, and must be - precise and consistent. - profile_query (google.cloud.talent_v4beta1.types.ProfileQuery): - Search query to execute. See - [ProfileQuery][google.cloud.talent.v4beta1.ProfileQuery] for - more details. - page_size (int): - A limit on the number of profiles returned in - the search results. A value above the default - value 10 can increase search response time. - The maximum value allowed is 100. Otherwise an - error is thrown. - page_token (str): - The pageToken, similar to offset enables users of the API to - paginate through the search results. To retrieve the first - page of results, set the pageToken to empty. The search - response includes a - [nextPageToken][google.cloud.talent.v4beta1.SearchProfilesResponse.next_page_token] - field that can be used to populate the pageToken field for - the next page of results. Using pageToken instead of offset - increases the performance of the API, especially compared to - larger offset values. - offset (int): - An integer that specifies the current offset (that is, - starting result) in search results. This field is only - considered if - [page_token][google.cloud.talent.v4beta1.SearchProfilesRequest.page_token] - is unset. - - The maximum allowed value is 5000. Otherwise an error is - thrown. - - For example, 0 means to search from the first profile, and - 10 means to search from the 11th profile. This can be used - for pagination, for example pageSize = 10 and offset = 10 - means to search from the second page. - disable_spell_check (bool): - This flag controls the spell-check feature. If ``false``, - the service attempts to correct a misspelled query. - - For example, "enginee" is corrected to "engineer". - order_by (str): - The criteria that determines how search results are sorted. - Defaults is "relevance desc" if no value is specified. - - Supported options are: - - - "relevance desc": By descending relevance, as determined - by the API algorithms. - - "update_date desc": Sort by - [Profile.update_time][google.cloud.talent.v4beta1.Profile.update_time] - in descending order (recently updated profiles first). - - "create_date desc": Sort by - [Profile.create_time][google.cloud.talent.v4beta1.Profile.create_time] - in descending order (recently created profiles first). - - "first_name": Sort by - [PersonName.PersonStructuredName.given_name][google.cloud.talent.v4beta1.PersonName.PersonStructuredName.given_name] - in ascending order. - - "first_name desc": Sort by - [PersonName.PersonStructuredName.given_name][google.cloud.talent.v4beta1.PersonName.PersonStructuredName.given_name] - in descending order. - - "last_name": Sort by - [PersonName.PersonStructuredName.family_name][google.cloud.talent.v4beta1.PersonName.PersonStructuredName.family_name] - in ascending order. - - "last_name desc": Sort by - [PersonName.PersonStructuredName.family_name][google.cloud.talent.v4beta1.PersonName.PersonStructuredName.family_name] - in ascending order. - case_sensitive_sort (bool): - When sort by field is based on alphabetical - order, sort values case sensitively (based on - ASCII) when the value is set to true. Default - value is case in-sensitive sort (false). - histogram_queries (Sequence[google.cloud.talent_v4beta1.types.HistogramQuery]): - A list of expressions specifies histogram requests against - matching profiles for - [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest]. - - The expression syntax looks like a function definition with - parameters. - - Function syntax: function_name(histogram_facet[, list of - buckets]) - - Data types: - - - Histogram facet: facet names with format - ``[a-zA-Z][a-zA-Z0-9_]+``. - - String: string like "any string with backslash escape for - quote(")." - - Number: whole number and floating point number like 10, - -1 and -0.01. - - List: list of elements with comma(,) separator surrounded - by square brackets. For example, [1, 2, 3] and ["one", - "two", "three"]. - - Built-in constants: - - - MIN (minimum number similar to java Double.MIN_VALUE) - - MAX (maximum number similar to java Double.MAX_VALUE) - - Built-in functions: - - - bucket(start, end[, label]) Bucket build-in function - creates a bucket with range of [start, end). Note that - the end is exclusive. For example, bucket(1, MAX, - "positive number") or bucket(1, 10). - - Histogram Facets: - - - admin1: Admin1 is a global placeholder for referring to - state, province, or the particular term a country uses to - define the geographic structure below the country level. - Examples include states codes such as "CA", "IL", "NY", - and provinces, such as "BC". - - locality: Locality is a global placeholder for referring - to city, town, or the particular term a country uses to - define the geographic structure below the admin1 level. - Examples include city names such as "Mountain View" and - "New York". - - extended_locality: Extended locality is concatenated - version of admin1 and locality with comma separator. For - example, "Mountain View, CA" and "New York, NY". - - postal_code: Postal code of profile which follows locale - code. - - country: Country code (ISO-3166-1 alpha-2 code) of - profile, such as US, JP, GB. - - job_title: Normalized job titles specified in - EmploymentHistory. - - company_name: Normalized company name of profiles to - match on. - - institution: The school name. For example, "MIT", - "University of California, Berkeley" - - degree: Highest education degree in ISCED code. Each - value in degree covers a specific level of education, - without any expansion to upper nor lower levels of - education degree. - - experience_in_months: experience in months. 0 means 0 - month to 1 month (exclusive). - - application_date: The application date specifies - application start dates. See - [ApplicationDateFilter][google.cloud.talent.v4beta1.ApplicationDateFilter] - for more details. - - application_outcome_notes: The application outcome reason - specifies the reasons behind the outcome of the job - application. See - [ApplicationOutcomeNotesFilter][google.cloud.talent.v4beta1.ApplicationOutcomeNotesFilter] - for more details. - - application_job_title: The application job title - specifies the job applied for in the application. See - [ApplicationJobFilter][google.cloud.talent.v4beta1.ApplicationJobFilter] - for more details. - - hirable_status: Hirable status specifies the profile's - hirable status. - - string_custom_attribute: String custom attributes. Values - can be accessed via square bracket notation like - string_custom_attribute["key1"]. - - numeric_custom_attribute: Numeric custom attributes. - Values can be accessed via square bracket notation like - numeric_custom_attribute["key1"]. - - Example expressions: - - - count(admin1) - - count(experience_in_months, [bucket(0, 12, "1 year"), - bucket(12, 36, "1-3 years"), bucket(36, MAX, "3+ - years")]) - - count(string_custom_attribute["assigned_recruiter"]) - - count(numeric_custom_attribute["favorite_number"], - [bucket(MIN, 0, "negative"), bucket(0, MAX, - "non-negative")]) - result_set_id (str): - An id that uniquely identifies the result set of a - [SearchProfiles][google.cloud.talent.v4beta1.ProfileService.SearchProfiles] - call. The id should be retrieved from the - [SearchProfilesResponse][google.cloud.talent.v4beta1.SearchProfilesResponse] - message returned from a previous invocation of - [SearchProfiles][google.cloud.talent.v4beta1.ProfileService.SearchProfiles]. - - A result set is an ordered list of search results. - - If this field is not set, a new result set is computed based - on the - [profile_query][google.cloud.talent.v4beta1.SearchProfilesRequest.profile_query]. - A new - [result_set_id][google.cloud.talent.v4beta1.SearchProfilesRequest.result_set_id] - is returned as a handle to access this result set. - - If this field is set, the service will ignore the resource - and - [profile_query][google.cloud.talent.v4beta1.SearchProfilesRequest.profile_query] - values, and simply retrieve a page of results from the - corresponding result set. In this case, one and only one of - [page_token][google.cloud.talent.v4beta1.SearchProfilesRequest.page_token] - or - [offset][google.cloud.talent.v4beta1.SearchProfilesRequest.offset] - must be set. - - A typical use case is to invoke - [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest] - without this field, then use the resulting - [result_set_id][google.cloud.talent.v4beta1.SearchProfilesRequest.result_set_id] - in - [SearchProfilesResponse][google.cloud.talent.v4beta1.SearchProfilesResponse] - to page through the results. - strict_keywords_search (bool): - This flag is used to indicate whether the - service will attempt to understand synonyms and - terms related to the search query or treat the - query "as is" when it generates a set of - results. By default this flag is set to false, - thus allowing expanded results to also be - returned. For example a search for "software - engineer" might also return candidates who have - experience in jobs similar to software engineer - positions. By setting this flag to true, the - service will only attempt to deliver candidates - has software engineer in his/her global fields - by treating "software engineer" as a keyword. - - It is recommended to provide a feature in the UI - (such as a checkbox) to allow recruiters to set - this flag to true if they intend to search for - longer boolean strings. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - request_metadata = proto.Field( - proto.MESSAGE, - number=2, - message=common.RequestMetadata, - ) - profile_query = proto.Field( - proto.MESSAGE, - number=3, - message=filters.ProfileQuery, - ) - page_size = proto.Field( - proto.INT32, - number=4, - ) - page_token = proto.Field( - proto.STRING, - number=5, - ) - offset = proto.Field( - proto.INT32, - number=6, - ) - disable_spell_check = proto.Field( - proto.BOOL, - number=7, - ) - order_by = proto.Field( - proto.STRING, - number=8, - ) - case_sensitive_sort = proto.Field( - proto.BOOL, - number=9, - ) - histogram_queries = proto.RepeatedField( - proto.MESSAGE, - number=10, - message=histogram.HistogramQuery, - ) - result_set_id = proto.Field( - proto.STRING, - number=12, - ) - strict_keywords_search = proto.Field( - proto.BOOL, - number=13, - ) - - -class SearchProfilesResponse(proto.Message): - r"""Response of SearchProfiles method. - - Attributes: - estimated_total_size (int): - An estimation of the number of profiles that - match the specified query. - This number isn't guaranteed to be accurate. - spell_correction (google.cloud.talent_v4beta1.types.SpellingCorrection): - The spell checking result, and correction. - metadata (google.cloud.talent_v4beta1.types.ResponseMetadata): - Additional information for the API - invocation, such as the request tracking id. - next_page_token (str): - A token to retrieve the next page of results. - This is empty if there are no more results. - histogram_query_results (Sequence[google.cloud.talent_v4beta1.types.HistogramQueryResult]): - The histogram results that match with specified - [SearchProfilesRequest.histogram_queries][google.cloud.talent.v4beta1.SearchProfilesRequest.histogram_queries]. - summarized_profiles (Sequence[google.cloud.talent_v4beta1.types.SummarizedProfile]): - The profile entities that match the specified - [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest]. - result_set_id (str): - An id that uniquely identifies the result set of a - [SearchProfiles][google.cloud.talent.v4beta1.ProfileService.SearchProfiles] - call for consistent results. - """ - - @property - def raw_page(self): - return self - - estimated_total_size = proto.Field( - proto.INT64, - number=1, - ) - spell_correction = proto.Field( - proto.MESSAGE, - number=2, - message=common.SpellingCorrection, - ) - metadata = proto.Field( - proto.MESSAGE, - number=3, - message=common.ResponseMetadata, - ) - next_page_token = proto.Field( - proto.STRING, - number=4, - ) - histogram_query_results = proto.RepeatedField( - proto.MESSAGE, - number=5, - message=histogram.HistogramQueryResult, - ) - summarized_profiles = proto.RepeatedField( - proto.MESSAGE, - number=6, - message="SummarizedProfile", - ) - result_set_id = proto.Field( - proto.STRING, - number=7, - ) - - -class SummarizedProfile(proto.Message): - r"""Profile entry with metadata inside - [SearchProfilesResponse][google.cloud.talent.v4beta1.SearchProfilesResponse]. - - Attributes: - profiles (Sequence[google.cloud.talent_v4beta1.types.Profile]): - A list of profiles that are linked by - [Profile.group_id][google.cloud.talent.v4beta1.Profile.group_id]. - summary (google.cloud.talent_v4beta1.types.Profile): - A profile summary shows the profile summary and how the - profile matches the search query. - - In profile summary, the profiles with the same - [Profile.group_id][google.cloud.talent.v4beta1.Profile.group_id] - are merged together. Among profiles, same - education/employment records may be slightly different but - they are merged into one with best efforts. - - For example, in one profile the school name is "UC Berkeley" - and the field study is "Computer Science" and in another one - the school name is "University of California at Berkeley" - and the field study is "CS". The API merges these two inputs - into one and selects one value for each field. For example, - the school name in summary is set to "University of - California at Berkeley" and the field of study is set to - "Computer Science". - """ - - profiles = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gct_profile.Profile, - ) - summary = proto.Field( - proto.MESSAGE, - number=2, - message=gct_profile.Profile, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 94b2f9c2..94504ea6 100644 --- a/noxfile.py +++ b/noxfile.py @@ -266,7 +266,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") + session.run("coverage", "report", "--show-missing", "--fail-under=99") session.run("coverage", "erase") diff --git a/owlbot.py b/owlbot.py new file mode 100644 index 00000000..ad6496e6 --- /dev/null +++ b/owlbot.py @@ -0,0 +1,50 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from pathlib import Path + +import synthtool as s +import synthtool.gcp as gcp +from synthtool.languages import python + +# ---------------------------------------------------------------------------- +# Copy the generated client from the owl-bot staging directory +# ---------------------------------------------------------------------------- + +default_version = "v1" + +for library in s.get_staging_dirs(default_version): + s.move(library, excludes=["setup.py"]) +s.remove_staging_dirs() + +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- + +templated_files = gcp.CommonTemplates().py_library( + microgenerator=True, + versions=gcp.common.detect_versions(path="./google", default_first=True), + cov_level=99, +) +s.move(templated_files, excludes=[".coveragerc"]) # the microgenerator has a good coveragerc file + +python.configure_previous_major_version_branches() + +python.py_samples(skip_readmes=True) + + +# run format session for all directories which have a noxfile +for noxfile in Path(".").glob("**/noxfile.py"): + s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False) + diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_create_application_async.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_create_application_async.py deleted file mode 100644 index 054d1e7e..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_create_application_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateApplication -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_CreateApplication_async] -from google.cloud import talent_v4beta1 - - -async def sample_create_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - application = talent_v4beta1.Application() - application.external_id = "external_id_value" - application.job = "job_value" - application.stage = "STARTED" - - request = talent_v4beta1.CreateApplicationRequest( - parent="parent_value", - application=application, - ) - - # Make the request - response = await client.create_application(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ApplicationService_CreateApplication_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_create_application_sync.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_create_application_sync.py deleted file mode 100644 index 2be41b46..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_create_application_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateApplication -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_CreateApplication_sync] -from google.cloud import talent_v4beta1 - - -def sample_create_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - application = talent_v4beta1.Application() - application.external_id = "external_id_value" - application.job = "job_value" - application.stage = "STARTED" - - request = talent_v4beta1.CreateApplicationRequest( - parent="parent_value", - application=application, - ) - - # Make the request - response = client.create_application(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ApplicationService_CreateApplication_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_delete_application_async.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_delete_application_async.py deleted file mode 100644 index 9c1360d0..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_delete_application_async.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteApplication -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_DeleteApplication_async] -from google.cloud import talent_v4beta1 - - -async def sample_delete_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteApplicationRequest( - name="name_value", - ) - - # Make the request - await client.delete_application(request=request) - - -# [END jobs_v4beta1_generated_ApplicationService_DeleteApplication_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_delete_application_sync.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_delete_application_sync.py deleted file mode 100644 index b83f46db..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_delete_application_sync.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteApplication -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_DeleteApplication_sync] -from google.cloud import talent_v4beta1 - - -def sample_delete_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteApplicationRequest( - name="name_value", - ) - - # Make the request - client.delete_application(request=request) - - -# [END jobs_v4beta1_generated_ApplicationService_DeleteApplication_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_get_application_async.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_get_application_async.py deleted file mode 100644 index 67d0dbdd..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_get_application_async.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetApplication -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_GetApplication_async] -from google.cloud import talent_v4beta1 - - -async def sample_get_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetApplicationRequest( - name="name_value", - ) - - # Make the request - response = await client.get_application(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ApplicationService_GetApplication_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_get_application_sync.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_get_application_sync.py deleted file mode 100644 index ba4a44e8..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_get_application_sync.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetApplication -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_GetApplication_sync] -from google.cloud import talent_v4beta1 - - -def sample_get_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetApplicationRequest( - name="name_value", - ) - - # Make the request - response = client.get_application(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ApplicationService_GetApplication_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_list_applications_async.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_list_applications_async.py deleted file mode 100644 index 870f086f..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_list_applications_async.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListApplications -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_ListApplications_async] -from google.cloud import talent_v4beta1 - - -async def sample_list_applications(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListApplicationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_applications(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_ApplicationService_ListApplications_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_list_applications_sync.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_list_applications_sync.py deleted file mode 100644 index 9a3dfaf0..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_list_applications_sync.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListApplications -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_ListApplications_sync] -from google.cloud import talent_v4beta1 - - -def sample_list_applications(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListApplicationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_applications(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_ApplicationService_ListApplications_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_update_application_async.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_update_application_async.py deleted file mode 100644 index 587e0171..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_update_application_async.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateApplication -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_UpdateApplication_async] -from google.cloud import talent_v4beta1 - - -async def sample_update_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceAsyncClient() - - # Initialize request argument(s) - application = talent_v4beta1.Application() - application.external_id = "external_id_value" - application.job = "job_value" - application.stage = "STARTED" - - request = talent_v4beta1.UpdateApplicationRequest( - application=application, - ) - - # Make the request - response = await client.update_application(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ApplicationService_UpdateApplication_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_application_service_update_application_sync.py b/samples/generated_samples/jobs_v4beta1_generated_application_service_update_application_sync.py deleted file mode 100644 index e003739d..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_application_service_update_application_sync.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateApplication -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ApplicationService_UpdateApplication_sync] -from google.cloud import talent_v4beta1 - - -def sample_update_application(): - # Create a client - client = talent_v4beta1.ApplicationServiceClient() - - # Initialize request argument(s) - application = talent_v4beta1.Application() - application.external_id = "external_id_value" - application.job = "job_value" - application.stage = "STARTED" - - request = talent_v4beta1.UpdateApplicationRequest( - application=application, - ) - - # Make the request - response = client.update_application(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ApplicationService_UpdateApplication_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_create_profile_async.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_create_profile_async.py deleted file mode 100644 index 181aff59..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_create_profile_async.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateProfile -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_CreateProfile_async] -from google.cloud import talent_v4beta1 - - -async def sample_create_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.CreateProfileRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_profile(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ProfileService_CreateProfile_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_create_profile_sync.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_create_profile_sync.py deleted file mode 100644 index 2419c554..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_create_profile_sync.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateProfile -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_CreateProfile_sync] -from google.cloud import talent_v4beta1 - - -def sample_create_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.CreateProfileRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_profile(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ProfileService_CreateProfile_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_delete_profile_async.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_delete_profile_async.py deleted file mode 100644 index cc2be661..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_delete_profile_async.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteProfile -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_DeleteProfile_async] -from google.cloud import talent_v4beta1 - - -async def sample_delete_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteProfileRequest( - name="name_value", - ) - - # Make the request - await client.delete_profile(request=request) - - -# [END jobs_v4beta1_generated_ProfileService_DeleteProfile_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_delete_profile_sync.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_delete_profile_sync.py deleted file mode 100644 index 61fe38e8..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_delete_profile_sync.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteProfile -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_DeleteProfile_sync] -from google.cloud import talent_v4beta1 - - -def sample_delete_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteProfileRequest( - name="name_value", - ) - - # Make the request - client.delete_profile(request=request) - - -# [END jobs_v4beta1_generated_ProfileService_DeleteProfile_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_get_profile_async.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_get_profile_async.py deleted file mode 100644 index d604a922..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_get_profile_async.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetProfile -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_GetProfile_async] -from google.cloud import talent_v4beta1 - - -async def sample_get_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetProfileRequest( - name="name_value", - ) - - # Make the request - response = await client.get_profile(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ProfileService_GetProfile_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_get_profile_sync.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_get_profile_sync.py deleted file mode 100644 index d1f0ab27..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_get_profile_sync.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetProfile -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_GetProfile_sync] -from google.cloud import talent_v4beta1 - - -def sample_get_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetProfileRequest( - name="name_value", - ) - - # Make the request - response = client.get_profile(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ProfileService_GetProfile_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_list_profiles_async.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_list_profiles_async.py deleted file mode 100644 index 39091994..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_list_profiles_async.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListProfiles -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_ListProfiles_async] -from google.cloud import talent_v4beta1 - - -async def sample_list_profiles(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListProfilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_profiles(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_ProfileService_ListProfiles_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_list_profiles_sync.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_list_profiles_sync.py deleted file mode 100644 index de0171cf..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_list_profiles_sync.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListProfiles -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_ListProfiles_sync] -from google.cloud import talent_v4beta1 - - -def sample_list_profiles(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListProfilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_profiles(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_ProfileService_ListProfiles_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_search_profiles_async.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_search_profiles_async.py deleted file mode 100644 index e92fe5ee..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_search_profiles_async.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for SearchProfiles -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_SearchProfiles_async] -from google.cloud import talent_v4beta1 - - -async def sample_search_profiles(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchProfilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_profiles(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_ProfileService_SearchProfiles_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_search_profiles_sync.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_search_profiles_sync.py deleted file mode 100644 index 8345a1db..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_search_profiles_sync.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for SearchProfiles -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_SearchProfiles_sync] -from google.cloud import talent_v4beta1 - - -def sample_search_profiles(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchProfilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_profiles(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_ProfileService_SearchProfiles_sync] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_update_profile_async.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_update_profile_async.py deleted file mode 100644 index c94e7b9c..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_update_profile_async.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateProfile -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_UpdateProfile_async] -from google.cloud import talent_v4beta1 - - -async def sample_update_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.UpdateProfileRequest( - ) - - # Make the request - response = await client.update_profile(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ProfileService_UpdateProfile_async] diff --git a/samples/generated_samples/jobs_v4beta1_generated_profile_service_update_profile_sync.py b/samples/generated_samples/jobs_v4beta1_generated_profile_service_update_profile_sync.py deleted file mode 100644 index ec145a43..00000000 --- a/samples/generated_samples/jobs_v4beta1_generated_profile_service_update_profile_sync.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateProfile -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-talent - - -# [START jobs_v4beta1_generated_ProfileService_UpdateProfile_sync] -from google.cloud import talent_v4beta1 - - -def sample_update_profile(): - # Create a client - client = talent_v4beta1.ProfileServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.UpdateProfileRequest( - ) - - # Make the request - response = client.update_profile(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_ProfileService_UpdateProfile_sync] diff --git a/samples/generated_samples/snippet_metadata_talent_v4beta1.json b/samples/generated_samples/snippet_metadata_talent_v4beta1.json index abf494cd..7d67e977 100644 --- a/samples/generated_samples/snippet_metadata_talent_v4beta1.json +++ b/samples/generated_samples/snippet_metadata_talent_v4beta1.json @@ -15,30 +15,30 @@ "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient", - "shortName": "ApplicationServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient.create_application", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.create_company", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.CreateApplication", + "fullName": "google.cloud.talent.v4beta1.CompanyService.CreateCompany", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "CreateApplication" + "shortName": "CreateCompany" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateApplicationRequest" + "type": "google.cloud.talent_v4beta1.types.CreateCompanyRequest" }, { "name": "parent", "type": "str" }, { - "name": "application", - "type": "google.cloud.talent_v4beta1.types.Application" + "name": "company", + "type": "google.cloud.talent_v4beta1.types.Company" }, { "name": "retry", @@ -53,22 +53,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Application", - "shortName": "create_application" + "resultType": "google.cloud.talent_v4beta1.types.Company", + "shortName": "create_company" }, - "description": "Sample for CreateApplication", - "file": "jobs_v4beta1_generated_application_service_create_application_async.py", + "description": "Sample for CreateCompany", + "file": "jobs_v4beta1_generated_company_service_create_company_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_CreateApplication_async", + "regionTag": "jobs_v4beta1_generated_CompanyService_CreateCompany_async", "segments": [ { - "end": 50, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 49, "start": 27, "type": "SHORT" }, @@ -78,51 +78,51 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 43, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 46, + "start": 44, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 50, + "start": 47, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_create_application_async.py" + "title": "jobs_v4beta1_generated_company_service_create_company_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient", - "shortName": "ApplicationServiceClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", + "shortName": "CompanyServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient.create_application", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.create_company", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.CreateApplication", + "fullName": "google.cloud.talent.v4beta1.CompanyService.CreateCompany", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "CreateApplication" + "shortName": "CreateCompany" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateApplicationRequest" + "type": "google.cloud.talent_v4beta1.types.CreateCompanyRequest" }, { "name": "parent", "type": "str" }, { - "name": "application", - "type": "google.cloud.talent_v4beta1.types.Application" + "name": "company", + "type": "google.cloud.talent_v4beta1.types.Company" }, { "name": "retry", @@ -137,22 +137,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Application", - "shortName": "create_application" + "resultType": "google.cloud.talent_v4beta1.types.Company", + "shortName": "create_company" }, - "description": "Sample for CreateApplication", - "file": "jobs_v4beta1_generated_application_service_create_application_sync.py", + "description": "Sample for CreateCompany", + "file": "jobs_v4beta1_generated_company_service_create_company_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_CreateApplication_sync", + "regionTag": "jobs_v4beta1_generated_CompanyService_CreateCompany_sync", "segments": [ { - "end": 50, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 49, "start": 27, "type": "SHORT" }, @@ -162,44 +162,44 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 43, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 46, + "start": 44, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 50, + "start": 47, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_create_application_sync.py" + "title": "jobs_v4beta1_generated_company_service_create_company_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient", - "shortName": "ApplicationServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient.delete_application", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.delete_company", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.DeleteApplication", + "fullName": "google.cloud.talent.v4beta1.CompanyService.DeleteCompany", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "DeleteApplication" + "shortName": "DeleteCompany" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteApplicationRequest" + "type": "google.cloud.talent_v4beta1.types.DeleteCompanyRequest" }, { "name": "name", @@ -218,13 +218,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_application" + "shortName": "delete_company" }, - "description": "Sample for DeleteApplication", - "file": "jobs_v4beta1_generated_application_service_delete_application_async.py", + "description": "Sample for DeleteCompany", + "file": "jobs_v4beta1_generated_company_service_delete_company_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_DeleteApplication_async", + "regionTag": "jobs_v4beta1_generated_CompanyService_DeleteCompany_async", "segments": [ { "end": 42, @@ -255,28 +255,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_delete_application_async.py" + "title": "jobs_v4beta1_generated_company_service_delete_company_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient", - "shortName": "ApplicationServiceClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", + "shortName": "CompanyServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient.delete_application", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.delete_company", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.DeleteApplication", + "fullName": "google.cloud.talent.v4beta1.CompanyService.DeleteCompany", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "DeleteApplication" + "shortName": "DeleteCompany" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteApplicationRequest" + "type": "google.cloud.talent_v4beta1.types.DeleteCompanyRequest" }, { "name": "name", @@ -295,13 +295,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_application" + "shortName": "delete_company" }, - "description": "Sample for DeleteApplication", - "file": "jobs_v4beta1_generated_application_service_delete_application_sync.py", + "description": "Sample for DeleteCompany", + "file": "jobs_v4beta1_generated_company_service_delete_company_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_DeleteApplication_sync", + "regionTag": "jobs_v4beta1_generated_CompanyService_DeleteCompany_sync", "segments": [ { "end": 42, @@ -332,29 +332,29 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_delete_application_sync.py" + "title": "jobs_v4beta1_generated_company_service_delete_company_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient", - "shortName": "ApplicationServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient.get_application", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.get_company", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.GetApplication", + "fullName": "google.cloud.talent.v4beta1.CompanyService.GetCompany", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "GetApplication" + "shortName": "GetCompany" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetApplicationRequest" + "type": "google.cloud.talent_v4beta1.types.GetCompanyRequest" }, { "name": "name", @@ -373,14 +373,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Application", - "shortName": "get_application" + "resultType": "google.cloud.talent_v4beta1.types.Company", + "shortName": "get_company" }, - "description": "Sample for GetApplication", - "file": "jobs_v4beta1_generated_application_service_get_application_async.py", + "description": "Sample for GetCompany", + "file": "jobs_v4beta1_generated_company_service_get_company_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_GetApplication_async", + "regionTag": "jobs_v4beta1_generated_CompanyService_GetCompany_async", "segments": [ { "end": 44, @@ -413,28 +413,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_get_application_async.py" + "title": "jobs_v4beta1_generated_company_service_get_company_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient", - "shortName": "ApplicationServiceClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", + "shortName": "CompanyServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient.get_application", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.get_company", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.GetApplication", + "fullName": "google.cloud.talent.v4beta1.CompanyService.GetCompany", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "GetApplication" + "shortName": "GetCompany" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetApplicationRequest" + "type": "google.cloud.talent_v4beta1.types.GetCompanyRequest" }, { "name": "name", @@ -453,14 +453,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Application", - "shortName": "get_application" + "resultType": "google.cloud.talent_v4beta1.types.Company", + "shortName": "get_company" }, - "description": "Sample for GetApplication", - "file": "jobs_v4beta1_generated_application_service_get_application_sync.py", + "description": "Sample for GetCompany", + "file": "jobs_v4beta1_generated_company_service_get_company_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_GetApplication_sync", + "regionTag": "jobs_v4beta1_generated_CompanyService_GetCompany_sync", "segments": [ { "end": 44, @@ -493,29 +493,29 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_get_application_sync.py" + "title": "jobs_v4beta1_generated_company_service_get_company_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient", - "shortName": "ApplicationServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient.list_applications", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.list_companies", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.ListApplications", + "fullName": "google.cloud.talent.v4beta1.CompanyService.ListCompanies", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "ListApplications" + "shortName": "ListCompanies" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListApplicationsRequest" + "type": "google.cloud.talent_v4beta1.types.ListCompaniesRequest" }, { "name": "parent", @@ -534,14 +534,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.application_service.pagers.ListApplicationsAsyncPager", - "shortName": "list_applications" + "resultType": "google.cloud.talent_v4beta1.services.company_service.pagers.ListCompaniesAsyncPager", + "shortName": "list_companies" }, - "description": "Sample for ListApplications", - "file": "jobs_v4beta1_generated_application_service_list_applications_async.py", + "description": "Sample for ListCompanies", + "file": "jobs_v4beta1_generated_company_service_list_companies_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_ListApplications_async", + "regionTag": "jobs_v4beta1_generated_CompanyService_ListCompanies_async", "segments": [ { "end": 45, @@ -574,28 +574,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_list_applications_async.py" + "title": "jobs_v4beta1_generated_company_service_list_companies_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient", - "shortName": "ApplicationServiceClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", + "shortName": "CompanyServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient.list_applications", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.list_companies", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.ListApplications", + "fullName": "google.cloud.talent.v4beta1.CompanyService.ListCompanies", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "ListApplications" + "shortName": "ListCompanies" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListApplicationsRequest" + "type": "google.cloud.talent_v4beta1.types.ListCompaniesRequest" }, { "name": "parent", @@ -614,14 +614,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.application_service.pagers.ListApplicationsPager", - "shortName": "list_applications" + "resultType": "google.cloud.talent_v4beta1.services.company_service.pagers.ListCompaniesPager", + "shortName": "list_companies" }, - "description": "Sample for ListApplications", - "file": "jobs_v4beta1_generated_application_service_list_applications_sync.py", + "description": "Sample for ListCompanies", + "file": "jobs_v4beta1_generated_company_service_list_companies_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_ListApplications_sync", + "regionTag": "jobs_v4beta1_generated_CompanyService_ListCompanies_sync", "segments": [ { "end": 45, @@ -654,33 +654,33 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_list_applications_sync.py" + "title": "jobs_v4beta1_generated_company_service_list_companies_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient", - "shortName": "ApplicationServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceAsyncClient.update_application", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.update_company", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.UpdateApplication", + "fullName": "google.cloud.talent.v4beta1.CompanyService.UpdateCompany", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "UpdateApplication" + "shortName": "UpdateCompany" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateApplicationRequest" + "type": "google.cloud.talent_v4beta1.types.UpdateCompanyRequest" }, { - "name": "application", - "type": "google.cloud.talent_v4beta1.types.Application" + "name": "company", + "type": "google.cloud.talent_v4beta1.types.Company" }, { "name": "retry", @@ -695,22 +695,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Application", - "shortName": "update_application" + "resultType": "google.cloud.talent_v4beta1.types.Company", + "shortName": "update_company" }, - "description": "Sample for UpdateApplication", - "file": "jobs_v4beta1_generated_application_service_update_application_async.py", + "description": "Sample for UpdateCompany", + "file": "jobs_v4beta1_generated_company_service_update_company_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_UpdateApplication_async", + "regionTag": "jobs_v4beta1_generated_CompanyService_UpdateCompany_async", "segments": [ { - "end": 49, + "end": 48, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 48, "start": 27, "type": "SHORT" }, @@ -720,47 +720,47 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 45, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 49, + "start": 46, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_update_application_async.py" + "title": "jobs_v4beta1_generated_company_service_update_company_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient", - "shortName": "ApplicationServiceClient" + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", + "shortName": "CompanyServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ApplicationServiceClient.update_application", + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.update_company", "method": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService.UpdateApplication", + "fullName": "google.cloud.talent.v4beta1.CompanyService.UpdateCompany", "service": { - "fullName": "google.cloud.talent.v4beta1.ApplicationService", - "shortName": "ApplicationService" + "fullName": "google.cloud.talent.v4beta1.CompanyService", + "shortName": "CompanyService" }, - "shortName": "UpdateApplication" + "shortName": "UpdateCompany" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateApplicationRequest" + "type": "google.cloud.talent_v4beta1.types.UpdateCompanyRequest" }, { - "name": "application", - "type": "google.cloud.talent_v4beta1.types.Application" + "name": "company", + "type": "google.cloud.talent_v4beta1.types.Company" }, { "name": "retry", @@ -775,22 +775,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Application", - "shortName": "update_application" + "resultType": "google.cloud.talent_v4beta1.types.Company", + "shortName": "update_company" }, - "description": "Sample for UpdateApplication", - "file": "jobs_v4beta1_generated_application_service_update_application_sync.py", + "description": "Sample for UpdateCompany", + "file": "jobs_v4beta1_generated_company_service_update_company_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ApplicationService_UpdateApplication_sync", + "regionTag": "jobs_v4beta1_generated_CompanyService_UpdateCompany_sync", "segments": [ { - "end": 49, + "end": 48, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 48, "start": 27, "type": "SHORT" }, @@ -800,52 +800,44 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 42, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 45, + "start": 43, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 49, + "start": 46, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_application_service_update_application_sync.py" + "title": "jobs_v4beta1_generated_company_service_update_company_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.CompletionAsyncClient", + "shortName": "CompletionAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.create_company", + "fullName": "google.cloud.talent_v4beta1.CompletionAsyncClient.complete_query", "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.CreateCompany", + "fullName": "google.cloud.talent.v4beta1.Completion.CompleteQuery", "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" + "fullName": "google.cloud.talent.v4beta1.Completion", + "shortName": "Completion" }, - "shortName": "CreateCompany" + "shortName": "CompleteQuery" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateCompanyRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "company", - "type": "google.cloud.talent_v4beta1.types.Company" + "type": "google.cloud.talent_v4beta1.types.CompleteQueryRequest" }, { "name": "retry", @@ -860,22 +852,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Company", - "shortName": "create_company" + "resultType": "google.cloud.talent_v4beta1.types.CompleteQueryResponse", + "shortName": "complete_query" }, - "description": "Sample for CreateCompany", - "file": "jobs_v4beta1_generated_company_service_create_company_async.py", + "description": "Sample for CompleteQuery", + "file": "jobs_v4beta1_generated_completion_complete_query_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_CreateCompany_async", + "regionTag": "jobs_v4beta1_generated_Completion_CompleteQuery_async", "segments": [ { - "end": 49, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 46, "start": 27, "type": "SHORT" }, @@ -885,1839 +877,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 43, + "end": 40, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_company_service_create_company_async.py" + "title": "jobs_v4beta1_generated_completion_complete_query_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", - "shortName": "CompanyServiceClient" + "fullName": "google.cloud.talent_v4beta1.CompletionClient", + "shortName": "CompletionClient" }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.create_company", - "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.CreateCompany", - "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "CreateCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateCompanyRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "company", - "type": "google.cloud.talent_v4beta1.types.Company" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.Company", - "shortName": "create_company" - }, - "description": "Sample for CreateCompany", - "file": "jobs_v4beta1_generated_company_service_create_company_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_CreateCompany_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 43, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 46, - "start": 44, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "start": 47, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_create_company_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.delete_company", - "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.DeleteCompany", - "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "DeleteCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteCompanyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_company" - }, - "description": "Sample for DeleteCompany", - "file": "jobs_v4beta1_generated_company_service_delete_company_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_DeleteCompany_async", - "segments": [ - { - "end": 42, - "start": 27, - "type": "FULL" - }, - { - "end": 42, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 38, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 39, - "type": "REQUEST_EXECUTION" - }, - { - "end": 43, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_delete_company_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.delete_company", - "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.DeleteCompany", - "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "DeleteCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteCompanyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_company" - }, - "description": "Sample for DeleteCompany", - "file": "jobs_v4beta1_generated_company_service_delete_company_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_DeleteCompany_sync", - "segments": [ - { - "end": 42, - "start": 27, - "type": "FULL" - }, - { - "end": 42, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 38, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 39, - "type": "REQUEST_EXECUTION" - }, - { - "end": 43, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_delete_company_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.get_company", - "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.GetCompany", - "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "GetCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetCompanyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.Company", - "shortName": "get_company" - }, - "description": "Sample for GetCompany", - "file": "jobs_v4beta1_generated_company_service_get_company_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_GetCompany_async", - "segments": [ - { - "end": 44, - "start": 27, - "type": "FULL" - }, - { - "end": 44, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 38, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 41, - "start": 39, - "type": "REQUEST_EXECUTION" - }, - { - "end": 45, - "start": 42, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_get_company_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.get_company", - "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.GetCompany", - "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "GetCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetCompanyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.Company", - "shortName": "get_company" - }, - "description": "Sample for GetCompany", - "file": "jobs_v4beta1_generated_company_service_get_company_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_GetCompany_sync", - "segments": [ - { - "end": 44, - "start": 27, - "type": "FULL" - }, - { - "end": 44, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 38, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 41, - "start": 39, - "type": "REQUEST_EXECUTION" - }, - { - "end": 45, - "start": 42, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_get_company_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.list_companies", - "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.ListCompanies", - "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "ListCompanies" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListCompaniesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.services.company_service.pagers.ListCompaniesAsyncPager", - "shortName": "list_companies" - }, - "description": "Sample for ListCompanies", - "file": "jobs_v4beta1_generated_company_service_list_companies_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_ListCompanies_async", - "segments": [ - { - "end": 45, - "start": 27, - "type": "FULL" - }, - { - "end": 45, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 38, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 41, - "start": 39, - "type": "REQUEST_EXECUTION" - }, - { - "end": 46, - "start": 42, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_list_companies_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.list_companies", - "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.ListCompanies", - "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "ListCompanies" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListCompaniesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.services.company_service.pagers.ListCompaniesPager", - "shortName": "list_companies" - }, - "description": "Sample for ListCompanies", - "file": "jobs_v4beta1_generated_company_service_list_companies_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_ListCompanies_sync", - "segments": [ - { - "end": 45, - "start": 27, - "type": "FULL" - }, - { - "end": 45, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 38, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 41, - "start": 39, - "type": "REQUEST_EXECUTION" - }, - { - "end": 46, - "start": 42, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_list_companies_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.update_company", - "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.UpdateCompany", - "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "UpdateCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateCompanyRequest" - }, - { - "name": "company", - "type": "google.cloud.talent_v4beta1.types.Company" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.Company", - "shortName": "update_company" - }, - "description": "Sample for UpdateCompany", - "file": "jobs_v4beta1_generated_company_service_update_company_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_UpdateCompany_async", - "segments": [ - { - "end": 48, - "start": 27, - "type": "FULL" - }, - { - "end": 48, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 42, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 45, - "start": 43, - "type": "REQUEST_EXECUTION" - }, - { - "end": 49, - "start": 46, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_update_company_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient.update_company", - "method": { - "fullName": "google.cloud.talent.v4beta1.CompanyService.UpdateCompany", - "service": { - "fullName": "google.cloud.talent.v4beta1.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "UpdateCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateCompanyRequest" - }, - { - "name": "company", - "type": "google.cloud.talent_v4beta1.types.Company" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.Company", - "shortName": "update_company" - }, - "description": "Sample for UpdateCompany", - "file": "jobs_v4beta1_generated_company_service_update_company_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_UpdateCompany_sync", - "segments": [ - { - "end": 48, - "start": 27, - "type": "FULL" - }, - { - "end": 48, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 42, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 45, - "start": 43, - "type": "REQUEST_EXECUTION" - }, - { - "end": 49, - "start": 46, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_update_company_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.CompletionAsyncClient", - "shortName": "CompletionAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompletionAsyncClient.complete_query", - "method": { - "fullName": "google.cloud.talent.v4beta1.Completion.CompleteQuery", - "service": { - "fullName": "google.cloud.talent.v4beta1.Completion", - "shortName": "Completion" - }, - "shortName": "CompleteQuery" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.CompleteQueryRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.CompleteQueryResponse", - "shortName": "complete_query" - }, - "description": "Sample for CompleteQuery", - "file": "jobs_v4beta1_generated_completion_complete_query_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_Completion_CompleteQuery_async", - "segments": [ - { - "end": 46, - "start": 27, - "type": "FULL" - }, - { - "end": 46, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 40, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 43, - "start": 41, - "type": "REQUEST_EXECUTION" - }, - { - "end": 47, - "start": 44, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_completion_complete_query_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.CompletionClient", - "shortName": "CompletionClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompletionClient.complete_query", - "method": { - "fullName": "google.cloud.talent.v4beta1.Completion.CompleteQuery", - "service": { - "fullName": "google.cloud.talent.v4beta1.Completion", - "shortName": "Completion" - }, - "shortName": "CompleteQuery" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.CompleteQueryRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.CompleteQueryResponse", - "shortName": "complete_query" - }, - "description": "Sample for CompleteQuery", - "file": "jobs_v4beta1_generated_completion_complete_query_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_Completion_CompleteQuery_sync", - "segments": [ - { - "end": 46, - "start": 27, - "type": "FULL" - }, - { - "end": 46, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 40, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 43, - "start": 41, - "type": "REQUEST_EXECUTION" - }, - { - "end": 47, - "start": 44, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_completion_complete_query_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.EventServiceAsyncClient", - "shortName": "EventServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.EventServiceAsyncClient.create_client_event", - "method": { - "fullName": "google.cloud.talent.v4beta1.EventService.CreateClientEvent", - "service": { - "fullName": "google.cloud.talent.v4beta1.EventService", - "shortName": "EventService" - }, - "shortName": "CreateClientEvent" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateClientEventRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "client_event", - "type": "google.cloud.talent_v4beta1.types.ClientEvent" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.ClientEvent", - "shortName": "create_client_event" - }, - "description": "Sample for CreateClientEvent", - "file": "jobs_v4beta1_generated_event_service_create_client_event_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_EventService_CreateClientEvent_async", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_event_service_create_client_event_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.EventServiceClient", - "shortName": "EventServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.EventServiceClient.create_client_event", - "method": { - "fullName": "google.cloud.talent.v4beta1.EventService.CreateClientEvent", - "service": { - "fullName": "google.cloud.talent.v4beta1.EventService", - "shortName": "EventService" - }, - "shortName": "CreateClientEvent" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateClientEventRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "client_event", - "type": "google.cloud.talent_v4beta1.types.ClientEvent" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.ClientEvent", - "shortName": "create_client_event" - }, - "description": "Sample for CreateClientEvent", - "file": "jobs_v4beta1_generated_event_service_create_client_event_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_EventService_CreateClientEvent_sync", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_event_service_create_client_event_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.batch_create_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.BatchCreateJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "BatchCreateJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.BatchCreateJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "jobs", - "type": "Sequence[google.cloud.talent_v4beta1.types.Job]" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "batch_create_jobs" - }, - "description": "Sample for BatchCreateJobs", - "file": "jobs_v4beta1_generated_job_service_batch_create_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_BatchCreateJobs_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_batch_create_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.batch_create_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.BatchCreateJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "BatchCreateJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.BatchCreateJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "jobs", - "type": "Sequence[google.cloud.talent_v4beta1.types.Job]" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "batch_create_jobs" - }, - "description": "Sample for BatchCreateJobs", - "file": "jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_BatchCreateJobs_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.batch_delete_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.BatchDeleteJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "BatchDeleteJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.BatchDeleteJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "filter", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "batch_delete_jobs" - }, - "description": "Sample for BatchDeleteJobs", - "file": "jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_BatchDeleteJobs_async", - "segments": [ - { - "end": 43, - "start": 27, - "type": "FULL" - }, - { - "end": 43, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 39, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 40, - "type": "REQUEST_EXECUTION" - }, - { - "end": 44, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.batch_delete_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.BatchDeleteJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "BatchDeleteJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.BatchDeleteJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "filter", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "batch_delete_jobs" - }, - "description": "Sample for BatchDeleteJobs", - "file": "jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_BatchDeleteJobs_sync", - "segments": [ - { - "end": 43, - "start": 27, - "type": "FULL" - }, - { - "end": 43, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 39, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 40, - "type": "REQUEST_EXECUTION" - }, - { - "end": 44, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.batch_update_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.BatchUpdateJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "BatchUpdateJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.BatchUpdateJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "jobs", - "type": "Sequence[google.cloud.talent_v4beta1.types.Job]" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "batch_update_jobs" - }, - "description": "Sample for BatchUpdateJobs", - "file": "jobs_v4beta1_generated_job_service_batch_update_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_BatchUpdateJobs_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_batch_update_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.batch_update_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.BatchUpdateJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "BatchUpdateJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.BatchUpdateJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "jobs", - "type": "Sequence[google.cloud.talent_v4beta1.types.Job]" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "batch_update_jobs" - }, - "description": "Sample for BatchUpdateJobs", - "file": "jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_BatchUpdateJobs_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.create_job", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.CreateJob", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "CreateJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateJobRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "job", - "type": "google.cloud.talent_v4beta1.types.Job" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.Job", - "shortName": "create_job" - }, - "description": "Sample for CreateJob", - "file": "jobs_v4beta1_generated_job_service_create_job_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_CreateJob_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_create_job_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.create_job", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.CreateJob", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "CreateJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateJobRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "job", - "type": "google.cloud.talent_v4beta1.types.Job" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4beta1.types.Job", - "shortName": "create_job" - }, - "description": "Sample for CreateJob", - "file": "jobs_v4beta1_generated_job_service_create_job_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_CreateJob_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_create_job_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.delete_job", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.DeleteJob", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "DeleteJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteJobRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_job" - }, - "description": "Sample for DeleteJob", - "file": "jobs_v4beta1_generated_job_service_delete_job_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_DeleteJob_async", - "segments": [ - { - "end": 42, - "start": 27, - "type": "FULL" - }, - { - "end": 42, - "start": 27, - "type": "SHORT" - }, - { - "end": 33, - "start": 31, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 38, - "start": 34, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 39, - "type": "REQUEST_EXECUTION" - }, - { - "end": 43, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_delete_job_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.delete_job", + "fullName": "google.cloud.talent_v4beta1.CompletionClient.complete_query", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.DeleteJob", + "fullName": "google.cloud.talent.v4beta1.Completion.CompleteQuery", "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" + "fullName": "google.cloud.talent.v4beta1.Completion", + "shortName": "Completion" }, - "shortName": "DeleteJob" + "shortName": "CompleteQuery" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteJobRequest" - }, - { - "name": "name", - "type": "str" + "type": "google.cloud.talent_v4beta1.types.CompleteQueryRequest" }, { "name": "retry", @@ -2732,21 +928,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_job" + "resultType": "google.cloud.talent_v4beta1.types.CompleteQueryResponse", + "shortName": "complete_query" }, - "description": "Sample for DeleteJob", - "file": "jobs_v4beta1_generated_job_service_delete_job_sync.py", + "description": "Sample for CompleteQuery", + "file": "jobs_v4beta1_generated_completion_complete_query_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_DeleteJob_sync", + "regionTag": "jobs_v4beta1_generated_Completion_CompleteQuery_sync", "segments": [ { - "end": 42, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 46, "start": 27, "type": "SHORT" }, @@ -2756,47 +953,53 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 38, + "end": 40, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_delete_job_sync.py" + "title": "jobs_v4beta1_generated_completion_complete_query_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.EventServiceAsyncClient", + "shortName": "EventServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.get_job", + "fullName": "google.cloud.talent_v4beta1.EventServiceAsyncClient.create_client_event", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.GetJob", + "fullName": "google.cloud.talent.v4beta1.EventService.CreateClientEvent", "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" + "fullName": "google.cloud.talent.v4beta1.EventService", + "shortName": "EventService" }, - "shortName": "GetJob" + "shortName": "CreateClientEvent" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetJobRequest" + "type": "google.cloud.talent_v4beta1.types.CreateClientEventRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "client_event", + "type": "google.cloud.talent_v4beta1.types.ClientEvent" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -2810,22 +1013,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Job", - "shortName": "get_job" + "resultType": "google.cloud.talent_v4beta1.types.ClientEvent", + "shortName": "create_client_event" }, - "description": "Sample for GetJob", - "file": "jobs_v4beta1_generated_job_service_get_job_async.py", + "description": "Sample for CreateClientEvent", + "file": "jobs_v4beta1_generated_event_service_create_client_event_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_GetJob_async", + "regionTag": "jobs_v4beta1_generated_EventService_CreateClientEvent_async", "segments": [ { - "end": 44, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 50, "start": 27, "type": "SHORT" }, @@ -2835,48 +1038,52 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 38, + "end": 44, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_get_job_async.py" + "title": "jobs_v4beta1_generated_event_service_create_client_event_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" + "fullName": "google.cloud.talent_v4beta1.EventServiceClient", + "shortName": "EventServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.get_job", + "fullName": "google.cloud.talent_v4beta1.EventServiceClient.create_client_event", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.GetJob", + "fullName": "google.cloud.talent.v4beta1.EventService.CreateClientEvent", "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" + "fullName": "google.cloud.talent.v4beta1.EventService", + "shortName": "EventService" }, - "shortName": "GetJob" + "shortName": "CreateClientEvent" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetJobRequest" + "type": "google.cloud.talent_v4beta1.types.CreateClientEventRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "client_event", + "type": "google.cloud.talent_v4beta1.types.ClientEvent" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -2890,22 +1097,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Job", - "shortName": "get_job" + "resultType": "google.cloud.talent_v4beta1.types.ClientEvent", + "shortName": "create_client_event" }, - "description": "Sample for GetJob", - "file": "jobs_v4beta1_generated_job_service_get_job_sync.py", + "description": "Sample for CreateClientEvent", + "file": "jobs_v4beta1_generated_event_service_create_client_event_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_GetJob_sync", + "regionTag": "jobs_v4beta1_generated_EventService_CreateClientEvent_sync", "segments": [ { - "end": 44, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 50, "start": 27, "type": "SHORT" }, @@ -2915,22 +1122,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 38, + "end": 44, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_get_job_sync.py" + "title": "jobs_v4beta1_generated_event_service_create_client_event_sync.py" }, { "canonical": true, @@ -2940,27 +1147,27 @@ "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.list_jobs", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.batch_create_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.ListJobs", + "fullName": "google.cloud.talent.v4beta1.JobService.BatchCreateJobs", "service": { "fullName": "google.cloud.talent.v4beta1.JobService", "shortName": "JobService" }, - "shortName": "ListJobs" + "shortName": "BatchCreateJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListJobsRequest" + "type": "google.cloud.talent_v4beta1.types.BatchCreateJobsRequest" }, { "name": "parent", "type": "str" }, { - "name": "filter", - "type": "str" + "name": "jobs", + "type": "Sequence[google.cloud.talent_v4beta1.types.Job]" }, { "name": "retry", @@ -2975,22 +1182,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsAsyncPager", - "shortName": "list_jobs" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "batch_create_jobs" }, - "description": "Sample for ListJobs", - "file": "jobs_v4beta1_generated_job_service_list_jobs_async.py", + "description": "Sample for BatchCreateJobs", + "file": "jobs_v4beta1_generated_job_service_batch_create_jobs_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_async", + "regionTag": "jobs_v4beta1_generated_JobService_BatchCreateJobs_async", "segments": [ { - "end": 46, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3000,22 +1207,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 39, + "end": 45, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 43, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_list_jobs_async.py" + "title": "jobs_v4beta1_generated_job_service_batch_create_jobs_async.py" }, { "canonical": true, @@ -3024,27 +1231,27 @@ "fullName": "google.cloud.talent_v4beta1.JobServiceClient", "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.list_jobs", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.batch_create_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.ListJobs", + "fullName": "google.cloud.talent.v4beta1.JobService.BatchCreateJobs", "service": { "fullName": "google.cloud.talent.v4beta1.JobService", "shortName": "JobService" }, - "shortName": "ListJobs" + "shortName": "BatchCreateJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListJobsRequest" + "type": "google.cloud.talent_v4beta1.types.BatchCreateJobsRequest" }, { "name": "parent", "type": "str" }, { - "name": "filter", - "type": "str" + "name": "jobs", + "type": "Sequence[google.cloud.talent_v4beta1.types.Job]" }, { "name": "retry", @@ -3059,22 +1266,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsPager", - "shortName": "list_jobs" + "resultType": "google.api_core.operation.Operation", + "shortName": "batch_create_jobs" }, - "description": "Sample for ListJobs", - "file": "jobs_v4beta1_generated_job_service_list_jobs_sync.py", + "description": "Sample for BatchCreateJobs", + "file": "jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_sync", + "regionTag": "jobs_v4beta1_generated_JobService_BatchCreateJobs_sync", "segments": [ { - "end": 46, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3084,22 +1291,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 39, + "end": 45, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 43, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_list_jobs_sync.py" + "title": "jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py" }, { "canonical": true, @@ -3109,19 +1316,27 @@ "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.search_jobs_for_alert", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.batch_delete_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert", + "fullName": "google.cloud.talent.v4beta1.JobService.BatchDeleteJobs", "service": { "fullName": "google.cloud.talent.v4beta1.JobService", "shortName": "JobService" }, - "shortName": "SearchJobsForAlert" + "shortName": "BatchDeleteJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" + "type": "google.cloud.talent_v4beta1.types.BatchDeleteJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" }, { "name": "retry", @@ -3136,22 +1351,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsForAlertAsyncPager", - "shortName": "search_jobs_for_alert" + "shortName": "batch_delete_jobs" }, - "description": "Sample for SearchJobsForAlert", - "file": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py", + "description": "Sample for BatchDeleteJobs", + "file": "jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_SearchJobsForAlert_async", + "regionTag": "jobs_v4beta1_generated_JobService_BatchDeleteJobs_async", "segments": [ { - "end": 45, + "end": 43, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 43, "start": 27, "type": "SHORT" }, @@ -3161,22 +1375,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 38, + "end": 39, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 44, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py" + "title": "jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py" }, { "canonical": true, @@ -3185,19 +1397,27 @@ "fullName": "google.cloud.talent_v4beta1.JobServiceClient", "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.search_jobs_for_alert", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.batch_delete_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert", + "fullName": "google.cloud.talent.v4beta1.JobService.BatchDeleteJobs", "service": { "fullName": "google.cloud.talent.v4beta1.JobService", "shortName": "JobService" }, - "shortName": "SearchJobsForAlert" + "shortName": "BatchDeleteJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" + "type": "google.cloud.talent_v4beta1.types.BatchDeleteJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" }, { "name": "retry", @@ -3212,22 +1432,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsForAlertPager", - "shortName": "search_jobs_for_alert" + "shortName": "batch_delete_jobs" }, - "description": "Sample for SearchJobsForAlert", - "file": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py", + "description": "Sample for BatchDeleteJobs", + "file": "jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_SearchJobsForAlert_sync", + "regionTag": "jobs_v4beta1_generated_JobService_BatchDeleteJobs_sync", "segments": [ { - "end": 45, + "end": 43, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 43, "start": 27, "type": "SHORT" }, @@ -3237,22 +1456,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 38, + "end": 39, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 44, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py" + "title": "jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py" }, { "canonical": true, @@ -3262,19 +1479,27 @@ "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.search_jobs", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.batch_update_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobs", + "fullName": "google.cloud.talent.v4beta1.JobService.BatchUpdateJobs", "service": { "fullName": "google.cloud.talent.v4beta1.JobService", "shortName": "JobService" }, - "shortName": "SearchJobs" + "shortName": "BatchUpdateJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" + "type": "google.cloud.talent_v4beta1.types.BatchUpdateJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "jobs", + "type": "Sequence[google.cloud.talent_v4beta1.types.Job]" }, { "name": "retry", @@ -3289,22 +1514,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsAsyncPager", - "shortName": "search_jobs" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "batch_update_jobs" }, - "description": "Sample for SearchJobs", - "file": "jobs_v4beta1_generated_job_service_search_jobs_async.py", + "description": "Sample for BatchUpdateJobs", + "file": "jobs_v4beta1_generated_job_service_batch_update_jobs_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_async", + "regionTag": "jobs_v4beta1_generated_JobService_BatchUpdateJobs_async", "segments": [ { - "end": 45, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3314,22 +1539,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 38, + "end": 45, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_search_jobs_async.py" + "title": "jobs_v4beta1_generated_job_service_batch_update_jobs_async.py" }, { "canonical": true, @@ -3338,19 +1563,27 @@ "fullName": "google.cloud.talent_v4beta1.JobServiceClient", "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.search_jobs", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.batch_update_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobs", + "fullName": "google.cloud.talent.v4beta1.JobService.BatchUpdateJobs", "service": { "fullName": "google.cloud.talent.v4beta1.JobService", "shortName": "JobService" }, - "shortName": "SearchJobs" + "shortName": "BatchUpdateJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" + "type": "google.cloud.talent_v4beta1.types.BatchUpdateJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "jobs", + "type": "Sequence[google.cloud.talent_v4beta1.types.Job]" }, { "name": "retry", @@ -3365,22 +1598,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsPager", - "shortName": "search_jobs" + "resultType": "google.api_core.operation.Operation", + "shortName": "batch_update_jobs" }, - "description": "Sample for SearchJobs", - "file": "jobs_v4beta1_generated_job_service_search_jobs_sync.py", + "description": "Sample for BatchUpdateJobs", + "file": "jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_sync", + "regionTag": "jobs_v4beta1_generated_JobService_BatchUpdateJobs_sync", "segments": [ { - "end": 45, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3390,22 +1623,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 38, + "end": 45, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_search_jobs_sync.py" + "title": "jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py" }, { "canonical": true, @@ -3415,19 +1648,23 @@ "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.update_job", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.create_job", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.UpdateJob", + "fullName": "google.cloud.talent.v4beta1.JobService.CreateJob", "service": { "fullName": "google.cloud.talent.v4beta1.JobService", "shortName": "JobService" }, - "shortName": "UpdateJob" + "shortName": "CreateJob" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateJobRequest" + "type": "google.cloud.talent_v4beta1.types.CreateJobRequest" + }, + { + "name": "parent", + "type": "str" }, { "name": "job", @@ -3447,21 +1684,21 @@ } ], "resultType": "google.cloud.talent_v4beta1.types.Job", - "shortName": "update_job" + "shortName": "create_job" }, - "description": "Sample for UpdateJob", - "file": "jobs_v4beta1_generated_job_service_update_job_async.py", + "description": "Sample for CreateJob", + "file": "jobs_v4beta1_generated_job_service_create_job_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_async", + "regionTag": "jobs_v4beta1_generated_JobService_CreateJob_async", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3471,22 +1708,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_update_job_async.py" + "title": "jobs_v4beta1_generated_job_service_create_job_async.py" }, { "canonical": true, @@ -3495,19 +1732,23 @@ "fullName": "google.cloud.talent_v4beta1.JobServiceClient", "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.update_job", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.create_job", "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.UpdateJob", + "fullName": "google.cloud.talent.v4beta1.JobService.CreateJob", "service": { "fullName": "google.cloud.talent.v4beta1.JobService", "shortName": "JobService" }, - "shortName": "UpdateJob" + "shortName": "CreateJob" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateJobRequest" + "type": "google.cloud.talent_v4beta1.types.CreateJobRequest" + }, + { + "name": "parent", + "type": "str" }, { "name": "job", @@ -3527,21 +1768,21 @@ } ], "resultType": "google.cloud.talent_v4beta1.types.Job", - "shortName": "update_job" + "shortName": "create_job" }, - "description": "Sample for UpdateJob", - "file": "jobs_v4beta1_generated_job_service_update_job_sync.py", + "description": "Sample for CreateJob", + "file": "jobs_v4beta1_generated_job_service_create_job_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_sync", + "regionTag": "jobs_v4beta1_generated_JobService_CreateJob_sync", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3551,53 +1792,49 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_job_service_update_job_sync.py" + "title": "jobs_v4beta1_generated_job_service_create_job_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient", - "shortName": "ProfileServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient.create_profile", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.delete_job", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.CreateProfile", + "fullName": "google.cloud.talent.v4beta1.JobService.DeleteJob", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "CreateProfile" + "shortName": "DeleteJob" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateProfileRequest" + "type": "google.cloud.talent_v4beta1.types.DeleteJobRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, - { - "name": "profile", - "type": "google.cloud.talent_v4beta1.types.Profile" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -3611,22 +1848,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Profile", - "shortName": "create_profile" + "shortName": "delete_job" }, - "description": "Sample for CreateProfile", - "file": "jobs_v4beta1_generated_profile_service_create_profile_async.py", + "description": "Sample for DeleteJob", + "file": "jobs_v4beta1_generated_job_service_delete_job_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_CreateProfile_async", + "regionTag": "jobs_v4beta1_generated_JobService_DeleteJob_async", "segments": [ { - "end": 44, + "end": 42, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 42, "start": 27, "type": "SHORT" }, @@ -3641,47 +1877,41 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 41, "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 43, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_create_profile_async.py" + "title": "jobs_v4beta1_generated_job_service_delete_job_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient", - "shortName": "ProfileServiceClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient.create_profile", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.delete_job", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.CreateProfile", + "fullName": "google.cloud.talent.v4beta1.JobService.DeleteJob", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "CreateProfile" + "shortName": "DeleteJob" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateProfileRequest" + "type": "google.cloud.talent_v4beta1.types.DeleteJobRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, - { - "name": "profile", - "type": "google.cloud.talent_v4beta1.types.Profile" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -3695,22 +1925,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Profile", - "shortName": "create_profile" + "shortName": "delete_job" }, - "description": "Sample for CreateProfile", - "file": "jobs_v4beta1_generated_profile_service_create_profile_sync.py", + "description": "Sample for DeleteJob", + "file": "jobs_v4beta1_generated_job_service_delete_job_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_CreateProfile_sync", + "regionTag": "jobs_v4beta1_generated_JobService_DeleteJob_sync", "segments": [ { - "end": 44, + "end": 42, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 42, "start": 27, "type": "SHORT" }, @@ -3725,39 +1954,37 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 41, "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 43, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_create_profile_sync.py" + "title": "jobs_v4beta1_generated_job_service_delete_job_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient", - "shortName": "ProfileServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient.delete_profile", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.get_job", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.DeleteProfile", + "fullName": "google.cloud.talent.v4beta1.JobService.GetJob", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "DeleteProfile" + "shortName": "GetJob" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteProfileRequest" + "type": "google.cloud.talent_v4beta1.types.GetJobRequest" }, { "name": "name", @@ -3776,21 +2003,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_profile" + "resultType": "google.cloud.talent_v4beta1.types.Job", + "shortName": "get_job" }, - "description": "Sample for DeleteProfile", - "file": "jobs_v4beta1_generated_profile_service_delete_profile_async.py", + "description": "Sample for GetJob", + "file": "jobs_v4beta1_generated_job_service_get_job_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_DeleteProfile_async", + "regionTag": "jobs_v4beta1_generated_JobService_GetJob_async", "segments": [ { - "end": 42, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 44, "start": 27, "type": "SHORT" }, @@ -3805,36 +2033,38 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 41, "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_delete_profile_async.py" + "title": "jobs_v4beta1_generated_job_service_get_job_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient", - "shortName": "ProfileServiceClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient.delete_profile", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.get_job", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.DeleteProfile", + "fullName": "google.cloud.talent.v4beta1.JobService.GetJob", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "DeleteProfile" + "shortName": "GetJob" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteProfileRequest" + "type": "google.cloud.talent_v4beta1.types.GetJobRequest" }, { "name": "name", @@ -3853,21 +2083,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_profile" + "resultType": "google.cloud.talent_v4beta1.types.Job", + "shortName": "get_job" }, - "description": "Sample for DeleteProfile", - "file": "jobs_v4beta1_generated_profile_service_delete_profile_sync.py", + "description": "Sample for GetJob", + "file": "jobs_v4beta1_generated_job_service_get_job_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_DeleteProfile_sync", + "regionTag": "jobs_v4beta1_generated_JobService_GetJob_sync", "segments": [ { - "end": 42, + "end": 44, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 44, "start": 27, "type": "SHORT" }, @@ -3882,40 +2113,46 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 41, "start": 39, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 45, + "start": 42, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_delete_profile_sync.py" + "title": "jobs_v4beta1_generated_job_service_get_job_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient", - "shortName": "ProfileServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient.get_profile", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.list_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.GetProfile", + "fullName": "google.cloud.talent.v4beta1.JobService.ListJobs", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "GetProfile" + "shortName": "ListJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetProfileRequest" + "type": "google.cloud.talent_v4beta1.types.ListJobsRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "filter", "type": "str" }, { @@ -3931,22 +2168,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Profile", - "shortName": "get_profile" + "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsAsyncPager", + "shortName": "list_jobs" }, - "description": "Sample for GetProfile", - "file": "jobs_v4beta1_generated_profile_service_get_profile_async.py", + "description": "Sample for ListJobs", + "file": "jobs_v4beta1_generated_job_service_list_jobs_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_GetProfile_async", + "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_async", "segments": [ { - "end": 44, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 46, "start": 27, "type": "SHORT" }, @@ -3956,46 +2193,50 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 38, + "end": 39, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 47, + "start": 43, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_get_profile_async.py" + "title": "jobs_v4beta1_generated_job_service_list_jobs_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient", - "shortName": "ProfileServiceClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient.get_profile", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.list_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.GetProfile", + "fullName": "google.cloud.talent.v4beta1.JobService.ListJobs", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "GetProfile" + "shortName": "ListJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetProfileRequest" + "type": "google.cloud.talent_v4beta1.types.ListJobsRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "filter", "type": "str" }, { @@ -4011,22 +2252,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Profile", - "shortName": "get_profile" + "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsPager", + "shortName": "list_jobs" }, - "description": "Sample for GetProfile", - "file": "jobs_v4beta1_generated_profile_service_get_profile_sync.py", + "description": "Sample for ListJobs", + "file": "jobs_v4beta1_generated_job_service_list_jobs_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_GetProfile_sync", + "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_sync", "segments": [ { - "end": 44, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 46, "start": 27, "type": "SHORT" }, @@ -4036,48 +2277,44 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 38, + "end": 39, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 47, + "start": 43, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_get_profile_sync.py" + "title": "jobs_v4beta1_generated_job_service_list_jobs_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient", - "shortName": "ProfileServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient.list_profiles", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.search_jobs_for_alert", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.ListProfiles", + "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "ListProfiles" + "shortName": "SearchJobsForAlert" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListProfilesRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" }, { "name": "retry", @@ -4092,14 +2329,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.profile_service.pagers.ListProfilesAsyncPager", - "shortName": "list_profiles" + "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsForAlertAsyncPager", + "shortName": "search_jobs_for_alert" }, - "description": "Sample for ListProfiles", - "file": "jobs_v4beta1_generated_profile_service_list_profiles_async.py", + "description": "Sample for SearchJobsForAlert", + "file": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_ListProfiles_async", + "regionTag": "jobs_v4beta1_generated_JobService_SearchJobsForAlert_async", "segments": [ { "end": 45, @@ -4132,32 +2369,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_list_profiles_async.py" + "title": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient", - "shortName": "ProfileServiceClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient.list_profiles", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.search_jobs_for_alert", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.ListProfiles", + "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "ListProfiles" + "shortName": "SearchJobsForAlert" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListProfilesRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" }, { "name": "retry", @@ -4172,14 +2405,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.profile_service.pagers.ListProfilesPager", - "shortName": "list_profiles" + "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsForAlertPager", + "shortName": "search_jobs_for_alert" }, - "description": "Sample for ListProfiles", - "file": "jobs_v4beta1_generated_profile_service_list_profiles_sync.py", + "description": "Sample for SearchJobsForAlert", + "file": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_ListProfiles_sync", + "regionTag": "jobs_v4beta1_generated_JobService_SearchJobsForAlert_sync", "segments": [ { "end": 45, @@ -4212,29 +2445,29 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_list_profiles_sync.py" + "title": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient", - "shortName": "ProfileServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient.search_profiles", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.search_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.SearchProfiles", + "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobs", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "SearchProfiles" + "shortName": "SearchJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchProfilesRequest" + "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" }, { "name": "retry", @@ -4249,14 +2482,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.profile_service.pagers.SearchProfilesAsyncPager", - "shortName": "search_profiles" + "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsAsyncPager", + "shortName": "search_jobs" }, - "description": "Sample for SearchProfiles", - "file": "jobs_v4beta1_generated_profile_service_search_profiles_async.py", + "description": "Sample for SearchJobs", + "file": "jobs_v4beta1_generated_job_service_search_jobs_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_SearchProfiles_async", + "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_async", "segments": [ { "end": 45, @@ -4289,28 +2522,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_search_profiles_async.py" + "title": "jobs_v4beta1_generated_job_service_search_jobs_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient", - "shortName": "ProfileServiceClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient.search_profiles", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.search_jobs", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.SearchProfiles", + "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobs", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "SearchProfiles" + "shortName": "SearchJobs" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchProfilesRequest" + "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" }, { "name": "retry", @@ -4325,14 +2558,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.services.profile_service.pagers.SearchProfilesPager", - "shortName": "search_profiles" + "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsPager", + "shortName": "search_jobs" }, - "description": "Sample for SearchProfiles", - "file": "jobs_v4beta1_generated_profile_service_search_profiles_sync.py", + "description": "Sample for SearchJobs", + "file": "jobs_v4beta1_generated_job_service_search_jobs_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_SearchProfiles_sync", + "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_sync", "segments": [ { "end": 45, @@ -4365,33 +2598,33 @@ "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_search_profiles_sync.py" + "title": "jobs_v4beta1_generated_job_service_search_jobs_sync.py" }, { "canonical": true, "clientMethod": { "async": true, "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient", - "shortName": "ProfileServiceAsyncClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceAsyncClient.update_profile", + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.update_job", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.UpdateProfile", + "fullName": "google.cloud.talent.v4beta1.JobService.UpdateJob", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "UpdateProfile" + "shortName": "UpdateJob" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateProfileRequest" + "type": "google.cloud.talent_v4beta1.types.UpdateJobRequest" }, { - "name": "profile", - "type": "google.cloud.talent_v4beta1.types.Profile" + "name": "job", + "type": "google.cloud.talent_v4beta1.types.Job" }, { "name": "retry", @@ -4406,22 +2639,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Profile", - "shortName": "update_profile" + "resultType": "google.cloud.talent_v4beta1.types.Job", + "shortName": "update_job" }, - "description": "Sample for UpdateProfile", - "file": "jobs_v4beta1_generated_profile_service_update_profile_async.py", + "description": "Sample for UpdateJob", + "file": "jobs_v4beta1_generated_job_service_update_job_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_UpdateProfile_async", + "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_async", "segments": [ { - "end": 43, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 43, + "end": 50, "start": 27, "type": "SHORT" }, @@ -4431,47 +2664,47 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 37, + "end": 44, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 40, - "start": 38, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 44, - "start": 41, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_update_profile_async.py" + "title": "jobs_v4beta1_generated_job_service_update_job_async.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient", - "shortName": "ProfileServiceClient" + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" }, - "fullName": "google.cloud.talent_v4beta1.ProfileServiceClient.update_profile", + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.update_job", "method": { - "fullName": "google.cloud.talent.v4beta1.ProfileService.UpdateProfile", + "fullName": "google.cloud.talent.v4beta1.JobService.UpdateJob", "service": { - "fullName": "google.cloud.talent.v4beta1.ProfileService", - "shortName": "ProfileService" + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" }, - "shortName": "UpdateProfile" + "shortName": "UpdateJob" }, "parameters": [ { "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateProfileRequest" + "type": "google.cloud.talent_v4beta1.types.UpdateJobRequest" }, { - "name": "profile", - "type": "google.cloud.talent_v4beta1.types.Profile" + "name": "job", + "type": "google.cloud.talent_v4beta1.types.Job" }, { "name": "retry", @@ -4486,22 +2719,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.talent_v4beta1.types.Profile", - "shortName": "update_profile" + "resultType": "google.cloud.talent_v4beta1.types.Job", + "shortName": "update_job" }, - "description": "Sample for UpdateProfile", - "file": "jobs_v4beta1_generated_profile_service_update_profile_sync.py", + "description": "Sample for UpdateJob", + "file": "jobs_v4beta1_generated_job_service_update_job_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_ProfileService_UpdateProfile_sync", + "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_sync", "segments": [ { - "end": 43, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 43, + "end": 50, "start": 27, "type": "SHORT" }, @@ -4511,22 +2744,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 37, + "end": 44, "start": 34, "type": "REQUEST_INITIALIZATION" }, { - "end": 40, - "start": 38, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 44, - "start": 41, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "jobs_v4beta1_generated_profile_service_update_profile_sync.py" + "title": "jobs_v4beta1_generated_job_service_update_job_sync.py" }, { "canonical": true, diff --git a/scripts/fixup_talent_v4beta1_keywords.py b/scripts/fixup_talent_v4beta1_keywords.py index b4d5636c..3058f60b 100644 --- a/scripts/fixup_talent_v4beta1_keywords.py +++ b/scripts/fixup_talent_v4beta1_keywords.py @@ -43,34 +43,23 @@ class talentCallTransformer(cst.CSTTransformer): 'batch_delete_jobs': ('parent', 'filter', ), 'batch_update_jobs': ('parent', 'jobs', 'update_mask', ), 'complete_query': ('parent', 'query', 'page_size', 'language_codes', 'company', 'scope', 'type_', ), - 'create_application': ('parent', 'application', ), 'create_client_event': ('parent', 'client_event', ), 'create_company': ('parent', 'company', ), 'create_job': ('parent', 'job', ), - 'create_profile': ('parent', 'profile', ), 'create_tenant': ('parent', 'tenant', ), - 'delete_application': ('name', ), 'delete_company': ('name', ), 'delete_job': ('name', ), - 'delete_profile': ('name', ), 'delete_tenant': ('name', ), - 'get_application': ('name', ), 'get_company': ('name', ), 'get_job': ('name', ), - 'get_profile': ('name', ), 'get_tenant': ('name', ), - 'list_applications': ('parent', 'page_token', 'page_size', ), 'list_companies': ('parent', 'page_token', 'page_size', 'require_open_jobs', ), 'list_jobs': ('parent', 'filter', 'page_token', 'page_size', 'job_view', ), - 'list_profiles': ('parent', 'filter', 'page_token', 'page_size', 'read_mask', ), 'list_tenants': ('parent', 'page_token', 'page_size', ), - 'search_jobs': ('parent', 'request_metadata', 'search_mode', 'job_query', 'enable_broadening', 'require_precise_result_size', 'histogram_queries', 'job_view', 'offset', 'page_size', 'page_token', 'order_by', 'diversification_level', 'custom_ranking_info', 'disable_keyword_match', ), - 'search_jobs_for_alert': ('parent', 'request_metadata', 'search_mode', 'job_query', 'enable_broadening', 'require_precise_result_size', 'histogram_queries', 'job_view', 'offset', 'page_size', 'page_token', 'order_by', 'diversification_level', 'custom_ranking_info', 'disable_keyword_match', ), - 'search_profiles': ('parent', 'request_metadata', 'profile_query', 'page_size', 'page_token', 'offset', 'disable_spell_check', 'order_by', 'case_sensitive_sort', 'histogram_queries', 'result_set_id', 'strict_keywords_search', ), - 'update_application': ('application', 'update_mask', ), + 'search_jobs': ('parent', 'request_metadata', 'search_mode', 'job_query', 'enable_broadening', 'require_precise_result_size', 'histogram_queries', 'job_view', 'offset', 'page_size', 'page_token', 'order_by', 'diversification_level', 'custom_ranking_info', 'disable_keyword_match', 'keyword_match_mode', ), + 'search_jobs_for_alert': ('parent', 'request_metadata', 'search_mode', 'job_query', 'enable_broadening', 'require_precise_result_size', 'histogram_queries', 'job_view', 'offset', 'page_size', 'page_token', 'order_by', 'diversification_level', 'custom_ranking_info', 'disable_keyword_match', 'keyword_match_mode', ), 'update_company': ('company', 'update_mask', ), 'update_job': ('job', 'update_mask', ), - 'update_profile': ('profile', 'update_mask', ), 'update_tenant': ('tenant', 'update_mask', ), } diff --git a/setup.py b/setup.py index e16e331b..ddb0bbf0 100644 --- a/setup.py +++ b/setup.py @@ -28,10 +28,7 @@ # 'Development Status :: 5 - Production/Stable' release_status = "Development Status :: 5 - Production/Stable" dependencies = [ - # NOTE: Maintainers, please do not require google-api-core>=2.x.x - # Until this issue is closed - # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", + "google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", "proto-plus >= 1.15.0, <2.0.0dev", "protobuf >= 3.19.0, <4.0.0dev", ] diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt deleted file mode 100644 index ec8ca201..00000000 --- a/testing/constraints-3.6.txt +++ /dev/null @@ -1,10 +0,0 @@ -# This constraints file is used to check that lower bounds -# are correct in setup.py -# List *all* library dependencies and extras in this file. -# Pin the version to the lower bound. -# -# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", -# Then this file should have foo==1.14.0 -google-api-core==1.31.5 -proto-plus==1.15.0 -protobuf==3.19.0 diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index ec8ca201..317c02dd 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -5,6 +5,6 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.31.5 +google-api-core==1.32.0 proto-plus==1.15.0 protobuf==3.19.0 diff --git a/tests/unit/gapic/talent_v4/test_company_service.py b/tests/unit/gapic/talent_v4/test_company_service.py index 93a066be..32c4cfd7 100644 --- a/tests/unit/gapic/talent_v4/test_company_service.py +++ b/tests/unit/gapic/talent_v4/test_company_service.py @@ -229,6 +229,7 @@ def test_company_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -246,6 +247,7 @@ def test_company_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -263,6 +265,7 @@ def test_company_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -292,6 +295,25 @@ def test_company_service_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -359,6 +381,7 @@ def test_company_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -393,6 +416,7 @@ def test_company_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -415,6 +439,7 @@ def test_company_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -529,6 +554,7 @@ def test_company_service_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -567,6 +593,7 @@ def test_company_service_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -587,6 +614,7 @@ def test_company_service_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -625,6 +653,7 @@ def test_company_service_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -2391,6 +2420,28 @@ def test_company_service_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.CompanyServiceGrpcTransport, + transports.CompanyServiceGrpcAsyncIOTransport, + ], +) +def test_company_service_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -2883,4 +2934,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) diff --git a/tests/unit/gapic/talent_v4/test_completion.py b/tests/unit/gapic/talent_v4/test_completion.py index 0c859577..9ede802a 100644 --- a/tests/unit/gapic/talent_v4/test_completion.py +++ b/tests/unit/gapic/talent_v4/test_completion.py @@ -217,6 +217,7 @@ def test_completion_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -234,6 +235,7 @@ def test_completion_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -251,6 +253,7 @@ def test_completion_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -280,6 +283,25 @@ def test_completion_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -345,6 +367,7 @@ def test_completion_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -379,6 +402,7 @@ def test_completion_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -401,6 +425,7 @@ def test_completion_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -511,6 +536,7 @@ def test_completion_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -544,6 +570,7 @@ def test_completion_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -562,6 +589,7 @@ def test_completion_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -595,6 +623,7 @@ def test_completion_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -1000,6 +1029,28 @@ def test_completion_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.CompletionGrpcTransport, + transports.CompletionGrpcAsyncIOTransport, + ], +) +def test_completion_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -1481,4 +1532,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) diff --git a/tests/unit/gapic/talent_v4/test_event_service.py b/tests/unit/gapic/talent_v4/test_event_service.py index 554dc0e0..00829d11 100644 --- a/tests/unit/gapic/talent_v4/test_event_service.py +++ b/tests/unit/gapic/talent_v4/test_event_service.py @@ -218,6 +218,7 @@ def test_event_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -235,6 +236,7 @@ def test_event_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -252,6 +254,7 @@ def test_event_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -281,6 +284,25 @@ def test_event_service_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -346,6 +368,7 @@ def test_event_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -380,6 +403,7 @@ def test_event_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -402,6 +426,7 @@ def test_event_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -512,6 +537,7 @@ def test_event_service_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -550,6 +576,7 @@ def test_event_service_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -568,6 +595,7 @@ def test_event_service_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -606,6 +634,7 @@ def test_event_service_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -1127,6 +1156,28 @@ def test_event_service_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.EventServiceGrpcTransport, + transports.EventServiceGrpcAsyncIOTransport, + ], +) +def test_event_service_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -1582,4 +1633,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) diff --git a/tests/unit/gapic/talent_v4/test_job_service.py b/tests/unit/gapic/talent_v4/test_job_service.py index 2d6f046f..f0369cce 100644 --- a/tests/unit/gapic/talent_v4/test_job_service.py +++ b/tests/unit/gapic/talent_v4/test_job_service.py @@ -239,6 +239,7 @@ def test_job_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -256,6 +257,7 @@ def test_job_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -273,6 +275,7 @@ def test_job_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -302,6 +305,25 @@ def test_job_service_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -367,6 +389,7 @@ def test_job_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -401,6 +424,7 @@ def test_job_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -423,6 +447,7 @@ def test_job_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -533,6 +558,7 @@ def test_job_service_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -566,6 +592,7 @@ def test_job_service_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -584,6 +611,7 @@ def test_job_service_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -617,6 +645,7 @@ def test_job_service_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -3541,6 +3570,28 @@ def test_job_service_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.JobServiceGrpcTransport, + transports.JobServiceGrpcAsyncIOTransport, + ], +) +def test_job_service_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -4082,4 +4133,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) diff --git a/tests/unit/gapic/talent_v4/test_tenant_service.py b/tests/unit/gapic/talent_v4/test_tenant_service.py index 83106f72..1099122b 100644 --- a/tests/unit/gapic/talent_v4/test_tenant_service.py +++ b/tests/unit/gapic/talent_v4/test_tenant_service.py @@ -226,6 +226,7 @@ def test_tenant_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -243,6 +244,7 @@ def test_tenant_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -260,6 +262,7 @@ def test_tenant_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -289,6 +292,25 @@ def test_tenant_service_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -356,6 +378,7 @@ def test_tenant_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -390,6 +413,7 @@ def test_tenant_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -412,6 +436,7 @@ def test_tenant_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -526,6 +551,7 @@ def test_tenant_service_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -564,6 +590,7 @@ def test_tenant_service_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -584,6 +611,7 @@ def test_tenant_service_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -622,6 +650,7 @@ def test_tenant_service_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -2244,6 +2273,28 @@ def test_tenant_service_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.TenantServiceGrpcTransport, + transports.TenantServiceGrpcAsyncIOTransport, + ], +) +def test_tenant_service_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -2708,4 +2759,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) diff --git a/tests/unit/gapic/talent_v4beta1/test_application_service.py b/tests/unit/gapic/talent_v4beta1/test_application_service.py deleted file mode 100644 index c840e6af..00000000 --- a/tests/unit/gapic/talent_v4beta1/test_application_service.py +++ /dev/null @@ -1,2989 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os - -# try/except added for compatibility with python < 3.8 -try: - from unittest import mock - from unittest.mock import AsyncMock -except ImportError: - import mock - -import math - -from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -import google.auth -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore -from google.type import date_pb2 # type: ignore -import grpc -from grpc.experimental import aio -from proto.marshal.rules.dates import DurationRule, TimestampRule -import pytest - -from google.cloud.talent_v4beta1.services.application_service import ( - ApplicationServiceAsyncClient, - ApplicationServiceClient, - pagers, - transports, -) -from google.cloud.talent_v4beta1.types import application -from google.cloud.talent_v4beta1.types import application as gct_application -from google.cloud.talent_v4beta1.types import application_service, common - - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return ( - "foo.googleapis.com" - if ("localhost" in client.DEFAULT_ENDPOINT) - else client.DEFAULT_ENDPOINT - ) - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert ApplicationServiceClient._get_default_mtls_endpoint(None) is None - assert ( - ApplicationServiceClient._get_default_mtls_endpoint(api_endpoint) - == api_mtls_endpoint - ) - assert ( - ApplicationServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) - == api_mtls_endpoint - ) - assert ( - ApplicationServiceClient._get_default_mtls_endpoint(sandbox_endpoint) - == sandbox_mtls_endpoint - ) - assert ( - ApplicationServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) - == sandbox_mtls_endpoint - ) - assert ( - ApplicationServiceClient._get_default_mtls_endpoint(non_googleapi) - == non_googleapi - ) - - -@pytest.mark.parametrize( - "client_class,transport_name", - [ - (ApplicationServiceClient, "grpc"), - (ApplicationServiceAsyncClient, "grpc_asyncio"), - ], -) -def test_application_service_client_from_service_account_info( - client_class, transport_name -): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_info" - ) as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info, transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ("jobs.googleapis.com:443") - - -@pytest.mark.parametrize( - "transport_class,transport_name", - [ - (transports.ApplicationServiceGrpcTransport, "grpc"), - (transports.ApplicationServiceGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -def test_application_service_client_service_account_always_use_jwt( - transport_class, transport_name -): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=True) - use_jwt.assert_called_once_with(True) - - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize( - "client_class,transport_name", - [ - (ApplicationServiceClient, "grpc"), - (ApplicationServiceAsyncClient, "grpc_asyncio"), - ], -) -def test_application_service_client_from_service_account_file( - client_class, transport_name -): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_file" - ) as factory: - factory.return_value = creds - client = client_class.from_service_account_file( - "dummy/file/path.json", transport=transport_name - ) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json( - "dummy/file/path.json", transport=transport_name - ) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ("jobs.googleapis.com:443") - - -def test_application_service_client_get_transport_class(): - transport = ApplicationServiceClient.get_transport_class() - available_transports = [ - transports.ApplicationServiceGrpcTransport, - ] - assert transport in available_transports - - transport = ApplicationServiceClient.get_transport_class("grpc") - assert transport == transports.ApplicationServiceGrpcTransport - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (ApplicationServiceClient, transports.ApplicationServiceGrpcTransport, "grpc"), - ( - ApplicationServiceAsyncClient, - transports.ApplicationServiceGrpcAsyncIOTransport, - "grpc_asyncio", - ), - ], -) -@mock.patch.object( - ApplicationServiceClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ApplicationServiceClient), -) -@mock.patch.object( - ApplicationServiceAsyncClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ApplicationServiceAsyncClient), -) -def test_application_service_client_client_options( - client_class, transport_class, transport_name -): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(ApplicationServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(ApplicationServiceClient, "get_transport_class") as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class(transport=transport_name) - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} - ): - with pytest.raises(ValueError): - client = client_class(transport=transport_name) - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name,use_client_cert_env", - [ - ( - ApplicationServiceClient, - transports.ApplicationServiceGrpcTransport, - "grpc", - "true", - ), - ( - ApplicationServiceAsyncClient, - transports.ApplicationServiceGrpcAsyncIOTransport, - "grpc_asyncio", - "true", - ), - ( - ApplicationServiceClient, - transports.ApplicationServiceGrpcTransport, - "grpc", - "false", - ), - ( - ApplicationServiceAsyncClient, - transports.ApplicationServiceGrpcAsyncIOTransport, - "grpc_asyncio", - "false", - ), - ], -) -@mock.patch.object( - ApplicationServiceClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ApplicationServiceClient), -) -@mock.patch.object( - ApplicationServiceAsyncClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ApplicationServiceAsyncClient), -) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_application_service_client_mtls_env_auto( - client_class, transport_class, transport_name, use_client_cert_env -): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - options = client_options.ClientOptions( - client_cert_source=client_cert_source_callback - ) - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=True, - ): - with mock.patch( - "google.auth.transport.mtls.default_client_cert_source", - return_value=client_cert_source_callback, - ): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=False, - ): - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize( - "client_class", [ApplicationServiceClient, ApplicationServiceAsyncClient] -) -@mock.patch.object( - ApplicationServiceClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ApplicationServiceClient), -) -@mock.patch.object( - ApplicationServiceAsyncClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ApplicationServiceAsyncClient), -) -def test_application_service_client_get_mtls_endpoint_and_cert_source(client_class): - mock_client_cert_source = mock.Mock() - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - mock_api_endpoint = "foo" - options = client_options.ClientOptions( - client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint - ) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( - options - ) - assert api_endpoint == mock_api_endpoint - assert cert_source == mock_client_cert_source - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - mock_client_cert_source = mock.Mock() - mock_api_endpoint = "foo" - options = client_options.ClientOptions( - client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint - ) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( - options - ) - assert api_endpoint == mock_api_endpoint - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=False, - ): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=True, - ): - with mock.patch( - "google.auth.transport.mtls.default_client_cert_source", - return_value=mock_client_cert_source, - ): - ( - api_endpoint, - cert_source, - ) = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source == mock_client_cert_source - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (ApplicationServiceClient, transports.ApplicationServiceGrpcTransport, "grpc"), - ( - ApplicationServiceAsyncClient, - transports.ApplicationServiceGrpcAsyncIOTransport, - "grpc_asyncio", - ), - ], -) -def test_application_service_client_client_options_scopes( - client_class, transport_class, transport_name -): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name,grpc_helpers", - [ - ( - ApplicationServiceClient, - transports.ApplicationServiceGrpcTransport, - "grpc", - grpc_helpers, - ), - ( - ApplicationServiceAsyncClient, - transports.ApplicationServiceGrpcAsyncIOTransport, - "grpc_asyncio", - grpc_helpers_async, - ), - ], -) -def test_application_service_client_client_options_credentials_file( - client_class, transport_class, transport_name, grpc_helpers -): - # Check the case credentials file is provided. - options = client_options.ClientOptions(credentials_file="credentials.json") - - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -def test_application_service_client_client_options_from_dict(): - with mock.patch( - "google.cloud.talent_v4beta1.services.application_service.transports.ApplicationServiceGrpcTransport.__init__" - ) as grpc_transport: - grpc_transport.return_value = None - client = ApplicationServiceClient( - client_options={"api_endpoint": "squid.clam.whelk"} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name,grpc_helpers", - [ - ( - ApplicationServiceClient, - transports.ApplicationServiceGrpcTransport, - "grpc", - grpc_helpers, - ), - ( - ApplicationServiceAsyncClient, - transports.ApplicationServiceGrpcAsyncIOTransport, - "grpc_asyncio", - grpc_helpers_async, - ), - ], -) -def test_application_service_client_create_channel_credentials_file( - client_class, transport_class, transport_name, grpc_helpers -): - # Check the case credentials file is provided. - options = client_options.ClientOptions(credentials_file="credentials.json") - - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # test that the credentials from file are saved and used as the credentials. - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel" - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - file_creds = ga_credentials.AnonymousCredentials() - load_creds.return_value = (file_creds, None) - adc.return_value = (creds, None) - client = client_class(client_options=options, transport=transport_name) - create_channel.assert_called_with( - "jobs.googleapis.com:443", - credentials=file_creds, - credentials_file=None, - quota_project_id=None, - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - scopes=None, - default_host="jobs.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "request_type", - [ - application_service.CreateApplicationRequest, - dict, - ], -) -def test_create_application(request_type, transport: str = "grpc"): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = gct_application.Application( - name="name_value", - external_id="external_id_value", - profile="profile_value", - job="job_value", - company="company_value", - stage=gct_application.Application.ApplicationStage.NEW, - state=gct_application.Application.ApplicationState.IN_PROGRESS, - outcome_notes="outcome_notes_value", - outcome=common.Outcome.POSITIVE, - job_title_snippet="job_title_snippet_value", - ) - response = client.create_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.CreateApplicationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_application.Application) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.profile == "profile_value" - assert response.job == "job_value" - assert response.company == "company_value" - assert response.stage == gct_application.Application.ApplicationStage.NEW - assert response.state == gct_application.Application.ApplicationState.IN_PROGRESS - assert response.outcome_notes == "outcome_notes_value" - assert response.outcome == common.Outcome.POSITIVE - assert response.job_title_snippet == "job_title_snippet_value" - - -def test_create_application_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_application), "__call__" - ) as call: - client.create_application() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.CreateApplicationRequest() - - -@pytest.mark.asyncio -async def test_create_application_async( - transport: str = "grpc_asyncio", - request_type=application_service.CreateApplicationRequest, -): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_application.Application( - name="name_value", - external_id="external_id_value", - profile="profile_value", - job="job_value", - company="company_value", - stage=gct_application.Application.ApplicationStage.NEW, - state=gct_application.Application.ApplicationState.IN_PROGRESS, - outcome_notes="outcome_notes_value", - outcome=common.Outcome.POSITIVE, - job_title_snippet="job_title_snippet_value", - ) - ) - response = await client.create_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.CreateApplicationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_application.Application) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.profile == "profile_value" - assert response.job == "job_value" - assert response.company == "company_value" - assert response.stage == gct_application.Application.ApplicationStage.NEW - assert response.state == gct_application.Application.ApplicationState.IN_PROGRESS - assert response.outcome_notes == "outcome_notes_value" - assert response.outcome == common.Outcome.POSITIVE - assert response.job_title_snippet == "job_title_snippet_value" - - -@pytest.mark.asyncio -async def test_create_application_async_from_dict(): - await test_create_application_async(request_type=dict) - - -def test_create_application_field_headers(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.CreateApplicationRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_application), "__call__" - ) as call: - call.return_value = gct_application.Application() - client.create_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_create_application_field_headers_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.CreateApplicationRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_application), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_application.Application() - ) - await client.create_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -def test_create_application_flattened(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = gct_application.Application() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_application( - parent="parent_value", - application=gct_application.Application(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - arg = args[0].application - mock_val = gct_application.Application(name="name_value") - assert arg == mock_val - - -def test_create_application_flattened_error(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_application( - application_service.CreateApplicationRequest(), - parent="parent_value", - application=gct_application.Application(name="name_value"), - ) - - -@pytest.mark.asyncio -async def test_create_application_flattened_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = gct_application.Application() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_application.Application() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_application( - parent="parent_value", - application=gct_application.Application(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - arg = args[0].application - mock_val = gct_application.Application(name="name_value") - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_create_application_flattened_error_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_application( - application_service.CreateApplicationRequest(), - parent="parent_value", - application=gct_application.Application(name="name_value"), - ) - - -@pytest.mark.parametrize( - "request_type", - [ - application_service.GetApplicationRequest, - dict, - ], -) -def test_get_application(request_type, transport: str = "grpc"): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_application), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = application.Application( - name="name_value", - external_id="external_id_value", - profile="profile_value", - job="job_value", - company="company_value", - stage=application.Application.ApplicationStage.NEW, - state=application.Application.ApplicationState.IN_PROGRESS, - outcome_notes="outcome_notes_value", - outcome=common.Outcome.POSITIVE, - job_title_snippet="job_title_snippet_value", - ) - response = client.get_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.GetApplicationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, application.Application) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.profile == "profile_value" - assert response.job == "job_value" - assert response.company == "company_value" - assert response.stage == application.Application.ApplicationStage.NEW - assert response.state == application.Application.ApplicationState.IN_PROGRESS - assert response.outcome_notes == "outcome_notes_value" - assert response.outcome == common.Outcome.POSITIVE - assert response.job_title_snippet == "job_title_snippet_value" - - -def test_get_application_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_application), "__call__") as call: - client.get_application() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.GetApplicationRequest() - - -@pytest.mark.asyncio -async def test_get_application_async( - transport: str = "grpc_asyncio", - request_type=application_service.GetApplicationRequest, -): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_application), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - application.Application( - name="name_value", - external_id="external_id_value", - profile="profile_value", - job="job_value", - company="company_value", - stage=application.Application.ApplicationStage.NEW, - state=application.Application.ApplicationState.IN_PROGRESS, - outcome_notes="outcome_notes_value", - outcome=common.Outcome.POSITIVE, - job_title_snippet="job_title_snippet_value", - ) - ) - response = await client.get_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.GetApplicationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, application.Application) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.profile == "profile_value" - assert response.job == "job_value" - assert response.company == "company_value" - assert response.stage == application.Application.ApplicationStage.NEW - assert response.state == application.Application.ApplicationState.IN_PROGRESS - assert response.outcome_notes == "outcome_notes_value" - assert response.outcome == common.Outcome.POSITIVE - assert response.job_title_snippet == "job_title_snippet_value" - - -@pytest.mark.asyncio -async def test_get_application_async_from_dict(): - await test_get_application_async(request_type=dict) - - -def test_get_application_field_headers(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.GetApplicationRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_application), "__call__") as call: - call.return_value = application.Application() - client.get_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_get_application_field_headers_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.GetApplicationRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_application), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - application.Application() - ) - await client.get_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -def test_get_application_flattened(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_application), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = application.Application() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_application( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -def test_get_application_flattened_error(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_application( - application_service.GetApplicationRequest(), - name="name_value", - ) - - -@pytest.mark.asyncio -async def test_get_application_flattened_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_application), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = application.Application() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - application.Application() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_application( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_get_application_flattened_error_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_application( - application_service.GetApplicationRequest(), - name="name_value", - ) - - -@pytest.mark.parametrize( - "request_type", - [ - application_service.UpdateApplicationRequest, - dict, - ], -) -def test_update_application(request_type, transport: str = "grpc"): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = gct_application.Application( - name="name_value", - external_id="external_id_value", - profile="profile_value", - job="job_value", - company="company_value", - stage=gct_application.Application.ApplicationStage.NEW, - state=gct_application.Application.ApplicationState.IN_PROGRESS, - outcome_notes="outcome_notes_value", - outcome=common.Outcome.POSITIVE, - job_title_snippet="job_title_snippet_value", - ) - response = client.update_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.UpdateApplicationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_application.Application) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.profile == "profile_value" - assert response.job == "job_value" - assert response.company == "company_value" - assert response.stage == gct_application.Application.ApplicationStage.NEW - assert response.state == gct_application.Application.ApplicationState.IN_PROGRESS - assert response.outcome_notes == "outcome_notes_value" - assert response.outcome == common.Outcome.POSITIVE - assert response.job_title_snippet == "job_title_snippet_value" - - -def test_update_application_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_application), "__call__" - ) as call: - client.update_application() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.UpdateApplicationRequest() - - -@pytest.mark.asyncio -async def test_update_application_async( - transport: str = "grpc_asyncio", - request_type=application_service.UpdateApplicationRequest, -): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_application.Application( - name="name_value", - external_id="external_id_value", - profile="profile_value", - job="job_value", - company="company_value", - stage=gct_application.Application.ApplicationStage.NEW, - state=gct_application.Application.ApplicationState.IN_PROGRESS, - outcome_notes="outcome_notes_value", - outcome=common.Outcome.POSITIVE, - job_title_snippet="job_title_snippet_value", - ) - ) - response = await client.update_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.UpdateApplicationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_application.Application) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.profile == "profile_value" - assert response.job == "job_value" - assert response.company == "company_value" - assert response.stage == gct_application.Application.ApplicationStage.NEW - assert response.state == gct_application.Application.ApplicationState.IN_PROGRESS - assert response.outcome_notes == "outcome_notes_value" - assert response.outcome == common.Outcome.POSITIVE - assert response.job_title_snippet == "job_title_snippet_value" - - -@pytest.mark.asyncio -async def test_update_application_async_from_dict(): - await test_update_application_async(request_type=dict) - - -def test_update_application_field_headers(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.UpdateApplicationRequest() - - request.application.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_application), "__call__" - ) as call: - call.return_value = gct_application.Application() - client.update_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "application.name=name_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_update_application_field_headers_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.UpdateApplicationRequest() - - request.application.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_application), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_application.Application() - ) - await client.update_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "application.name=name_value", - ) in kw["metadata"] - - -def test_update_application_flattened(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = gct_application.Application() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_application( - application=gct_application.Application(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].application - mock_val = gct_application.Application(name="name_value") - assert arg == mock_val - - -def test_update_application_flattened_error(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_application( - application_service.UpdateApplicationRequest(), - application=gct_application.Application(name="name_value"), - ) - - -@pytest.mark.asyncio -async def test_update_application_flattened_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = gct_application.Application() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_application.Application() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_application( - application=gct_application.Application(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].application - mock_val = gct_application.Application(name="name_value") - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_update_application_flattened_error_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_application( - application_service.UpdateApplicationRequest(), - application=gct_application.Application(name="name_value"), - ) - - -@pytest.mark.parametrize( - "request_type", - [ - application_service.DeleteApplicationRequest, - dict, - ], -) -def test_delete_application(request_type, transport: str = "grpc"): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.DeleteApplicationRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_application_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_application), "__call__" - ) as call: - client.delete_application() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.DeleteApplicationRequest() - - -@pytest.mark.asyncio -async def test_delete_application_async( - transport: str = "grpc_asyncio", - request_type=application_service.DeleteApplicationRequest, -): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.DeleteApplicationRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_application_async_from_dict(): - await test_delete_application_async(request_type=dict) - - -def test_delete_application_field_headers(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.DeleteApplicationRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_application), "__call__" - ) as call: - call.return_value = None - client.delete_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_delete_application_field_headers_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.DeleteApplicationRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_application), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_application(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -def test_delete_application_flattened(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = None - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_application( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -def test_delete_application_flattened_error(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_application( - application_service.DeleteApplicationRequest(), - name="name_value", - ) - - -@pytest.mark.asyncio -async def test_delete_application_flattened_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_application), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_application( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_delete_application_flattened_error_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_application( - application_service.DeleteApplicationRequest(), - name="name_value", - ) - - -@pytest.mark.parametrize( - "request_type", - [ - application_service.ListApplicationsRequest, - dict, - ], -) -def test_list_applications(request_type, transport: str = "grpc"): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = application_service.ListApplicationsResponse( - next_page_token="next_page_token_value", - ) - response = client.list_applications(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.ListApplicationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListApplicationsPager) - assert response.next_page_token == "next_page_token_value" - - -def test_list_applications_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), "__call__" - ) as call: - client.list_applications() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.ListApplicationsRequest() - - -@pytest.mark.asyncio -async def test_list_applications_async( - transport: str = "grpc_asyncio", - request_type=application_service.ListApplicationsRequest, -): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - application_service.ListApplicationsResponse( - next_page_token="next_page_token_value", - ) - ) - response = await client.list_applications(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == application_service.ListApplicationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListApplicationsAsyncPager) - assert response.next_page_token == "next_page_token_value" - - -@pytest.mark.asyncio -async def test_list_applications_async_from_dict(): - await test_list_applications_async(request_type=dict) - - -def test_list_applications_field_headers(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.ListApplicationsRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), "__call__" - ) as call: - call.return_value = application_service.ListApplicationsResponse() - client.list_applications(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_list_applications_field_headers_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = application_service.ListApplicationsRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - application_service.ListApplicationsResponse() - ) - await client.list_applications(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -def test_list_applications_flattened(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = application_service.ListApplicationsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_applications( - parent="parent_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - - -def test_list_applications_flattened_error(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_applications( - application_service.ListApplicationsRequest(), - parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_list_applications_flattened_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = application_service.ListApplicationsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - application_service.ListApplicationsResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_applications( - parent="parent_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_list_applications_flattened_error_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_applications( - application_service.ListApplicationsRequest(), - parent="parent_value", - ) - - -def test_list_applications_pager(transport_name: str = "grpc"): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), "__call__" - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - application.Application(), - application.Application(), - ], - next_page_token="abc", - ), - application_service.ListApplicationsResponse( - applications=[], - next_page_token="def", - ), - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - ], - next_page_token="ghi", - ), - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - application.Application(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_applications(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, application.Application) for i in results) - - -def test_list_applications_pages(transport_name: str = "grpc"): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), "__call__" - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - application.Application(), - application.Application(), - ], - next_page_token="abc", - ), - application_service.ListApplicationsResponse( - applications=[], - next_page_token="def", - ), - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - ], - next_page_token="ghi", - ), - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - application.Application(), - ], - ), - RuntimeError, - ) - pages = list(client.list_applications(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.asyncio -async def test_list_applications_async_pager(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - application.Application(), - application.Application(), - ], - next_page_token="abc", - ), - application_service.ListApplicationsResponse( - applications=[], - next_page_token="def", - ), - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - ], - next_page_token="ghi", - ), - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - application.Application(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_applications( - request={}, - ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, application.Application) for i in responses) - - -@pytest.mark.asyncio -async def test_list_applications_async_pages(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_applications), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - application.Application(), - application.Application(), - ], - next_page_token="abc", - ), - application_service.ListApplicationsResponse( - applications=[], - next_page_token="def", - ), - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - ], - next_page_token="ghi", - ), - application_service.ListApplicationsResponse( - applications=[ - application.Application(), - application.Application(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in ( - await client.list_applications(request={}) - ).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.ApplicationServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.ApplicationServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ApplicationServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.ApplicationServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ApplicationServiceClient( - client_options=options, - transport=transport, - ) - - # It is an error to provide an api_key and a credential. - options = mock.Mock() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ApplicationServiceClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.ApplicationServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ApplicationServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.ApplicationServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = ApplicationServiceClient(transport=transport) - assert client.transport is transport - - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.ApplicationServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.ApplicationServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ApplicationServiceGrpcTransport, - transports.ApplicationServiceGrpcAsyncIOTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - - -@pytest.mark.parametrize( - "transport_name", - [ - "grpc", - ], -) -def test_transport_kind(transport_name): - transport = ApplicationServiceClient.get_transport_class(transport_name)( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert transport.kind == transport_name - - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.ApplicationServiceGrpcTransport, - ) - - -def test_application_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.ApplicationServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", - ) - - -def test_application_service_base_transport(): - # Instantiate the base transport. - with mock.patch( - "google.cloud.talent_v4beta1.services.application_service.transports.ApplicationServiceTransport.__init__" - ) as Transport: - Transport.return_value = None - transport = transports.ApplicationServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - "create_application", - "get_application", - "update_application", - "delete_application", - "list_applications", - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Catch all for all remaining methods and properties - remainder = [ - "kind", - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_application_service_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.talent_v4beta1.services.application_service.transports.ApplicationServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ApplicationServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=None, - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - quota_project_id="octopus", - ) - - -def test_application_service_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( - "google.cloud.talent_v4beta1.services.application_service.transports.ApplicationServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ApplicationServiceTransport() - adc.assert_called_once() - - -def test_application_service_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - ApplicationServiceClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ApplicationServiceGrpcTransport, - transports.ApplicationServiceGrpcAsyncIOTransport, - ], -) -def test_application_service_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.ApplicationServiceGrpcTransport, grpc_helpers), - (transports.ApplicationServiceGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -def test_application_service_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - - create_channel.assert_called_with( - "jobs.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - scopes=["1", "2"], - default_host="jobs.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ApplicationServiceGrpcTransport, - transports.ApplicationServiceGrpcAsyncIOTransport, - ], -) -def test_application_service_grpc_transport_client_cert_source_for_mtls( - transport_class, -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds, - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback, - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, private_key=expected_key - ) - - -@pytest.mark.parametrize( - "transport_name", - [ - "grpc", - "grpc_asyncio", - ], -) -def test_application_service_host_no_port(transport_name): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), - transport=transport_name, - ) - assert client.transport._host == ("jobs.googleapis.com:443") - - -@pytest.mark.parametrize( - "transport_name", - [ - "grpc", - "grpc_asyncio", - ], -) -def test_application_service_host_with_port(transport_name): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="jobs.googleapis.com:8000" - ), - transport=transport_name, - ) - assert client.transport._host == ("jobs.googleapis.com:8000") - - -def test_application_service_grpc_transport_channel(): - channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ApplicationServiceGrpcTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_application_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ApplicationServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [ - transports.ApplicationServiceGrpcTransport, - transports.ApplicationServiceGrpcAsyncIOTransport, - ], -) -def test_application_service_transport_channel_mtls_with_client_cert_source( - transport_class, -): - with mock.patch( - "grpc.ssl_channel_credentials", autospec=True - ) as grpc_ssl_channel_cred: - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [ - transports.ApplicationServiceGrpcTransport, - transports.ApplicationServiceGrpcAsyncIOTransport, - ], -) -def test_application_service_transport_channel_mtls_with_adc(transport_class): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_application_path(): - project = "squid" - tenant = "clam" - profile = "whelk" - application = "octopus" - expected = "projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}".format( - project=project, - tenant=tenant, - profile=profile, - application=application, - ) - actual = ApplicationServiceClient.application_path( - project, tenant, profile, application - ) - assert expected == actual - - -def test_parse_application_path(): - expected = { - "project": "oyster", - "tenant": "nudibranch", - "profile": "cuttlefish", - "application": "mussel", - } - path = ApplicationServiceClient.application_path(**expected) - - # Check that the path construction is reversible. - actual = ApplicationServiceClient.parse_application_path(path) - assert expected == actual - - -def test_company_path(): - project = "winkle" - tenant = "nautilus" - company = "scallop" - expected = "projects/{project}/tenants/{tenant}/companies/{company}".format( - project=project, - tenant=tenant, - company=company, - ) - actual = ApplicationServiceClient.company_path(project, tenant, company) - assert expected == actual - - -def test_parse_company_path(): - expected = { - "project": "abalone", - "tenant": "squid", - "company": "clam", - } - path = ApplicationServiceClient.company_path(**expected) - - # Check that the path construction is reversible. - actual = ApplicationServiceClient.parse_company_path(path) - assert expected == actual - - -def test_job_path(): - project = "whelk" - tenant = "octopus" - job = "oyster" - expected = "projects/{project}/tenants/{tenant}/jobs/{job}".format( - project=project, - tenant=tenant, - job=job, - ) - actual = ApplicationServiceClient.job_path(project, tenant, job) - assert expected == actual - - -def test_parse_job_path(): - expected = { - "project": "nudibranch", - "tenant": "cuttlefish", - "job": "mussel", - } - path = ApplicationServiceClient.job_path(**expected) - - # Check that the path construction is reversible. - actual = ApplicationServiceClient.parse_job_path(path) - assert expected == actual - - -def test_profile_path(): - project = "winkle" - tenant = "nautilus" - profile = "scallop" - expected = "projects/{project}/tenants/{tenant}/profiles/{profile}".format( - project=project, - tenant=tenant, - profile=profile, - ) - actual = ApplicationServiceClient.profile_path(project, tenant, profile) - assert expected == actual - - -def test_parse_profile_path(): - expected = { - "project": "abalone", - "tenant": "squid", - "profile": "clam", - } - path = ApplicationServiceClient.profile_path(**expected) - - # Check that the path construction is reversible. - actual = ApplicationServiceClient.parse_profile_path(path) - assert expected == actual - - -def test_common_billing_account_path(): - billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format( - billing_account=billing_account, - ) - actual = ApplicationServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "octopus", - } - path = ApplicationServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = ApplicationServiceClient.parse_common_billing_account_path(path) - assert expected == actual - - -def test_common_folder_path(): - folder = "oyster" - expected = "folders/{folder}".format( - folder=folder, - ) - actual = ApplicationServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nudibranch", - } - path = ApplicationServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = ApplicationServiceClient.parse_common_folder_path(path) - assert expected == actual - - -def test_common_organization_path(): - organization = "cuttlefish" - expected = "organizations/{organization}".format( - organization=organization, - ) - actual = ApplicationServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "mussel", - } - path = ApplicationServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = ApplicationServiceClient.parse_common_organization_path(path) - assert expected == actual - - -def test_common_project_path(): - project = "winkle" - expected = "projects/{project}".format( - project=project, - ) - actual = ApplicationServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nautilus", - } - path = ApplicationServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = ApplicationServiceClient.parse_common_project_path(path) - assert expected == actual - - -def test_common_location_path(): - project = "scallop" - location = "abalone" - expected = "projects/{project}/locations/{location}".format( - project=project, - location=location, - ) - actual = ApplicationServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "squid", - "location": "clam", - } - path = ApplicationServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = ApplicationServiceClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_with_default_client_info(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object( - transports.ApplicationServiceTransport, "_prep_wrapped_messages" - ) as prep: - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object( - transports.ApplicationServiceTransport, "_prep_wrapped_messages" - ) as prep: - transport_class = ApplicationServiceClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - -@pytest.mark.asyncio -async def test_transport_close_async(): - client = ApplicationServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc_asyncio", - ) - with mock.patch.object( - type(getattr(client.transport, "grpc_channel")), "close" - ) as close: - async with client: - close.assert_not_called() - close.assert_called_once() - - -def test_transport_close(): - transports = { - "grpc": "_grpc_channel", - } - - for transport, close_name in transports.items(): - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport - ) - with mock.patch.object( - type(getattr(client.transport, close_name)), "close" - ) as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -def test_client_ctx(): - transports = [ - "grpc", - ] - for transport in transports: - client = ApplicationServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() - - -@pytest.mark.parametrize( - "client_class,transport_class", - [ - (ApplicationServiceClient, transports.ApplicationServiceGrpcTransport), - ( - ApplicationServiceAsyncClient, - transports.ApplicationServiceGrpcAsyncIOTransport, - ), - ], -) -def test_api_key_credentials(client_class, transport_class): - with mock.patch.object( - google.auth._default, "get_api_key_credentials", create=True - ) as get_api_key_credentials: - mock_cred = mock.Mock() - get_api_key_credentials.return_value = mock_cred - options = client_options.ClientOptions() - options.api_key = "api_key" - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=mock_cred, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) diff --git a/tests/unit/gapic/talent_v4beta1/test_company_service.py b/tests/unit/gapic/talent_v4beta1/test_company_service.py index cdb5e3b0..55d238e8 100644 --- a/tests/unit/gapic/talent_v4beta1/test_company_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_company_service.py @@ -30,6 +30,7 @@ import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError +from google.longrunning import operations_pb2 from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.type import latlng_pb2 # type: ignore @@ -229,6 +230,7 @@ def test_company_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -246,6 +248,7 @@ def test_company_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -263,6 +266,7 @@ def test_company_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -292,6 +296,25 @@ def test_company_service_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -359,6 +382,7 @@ def test_company_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -393,6 +417,7 @@ def test_company_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -415,6 +440,7 @@ def test_company_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -529,6 +555,7 @@ def test_company_service_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -567,6 +594,7 @@ def test_company_service_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -587,6 +615,7 @@ def test_company_service_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -625,6 +654,7 @@ def test_company_service_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -2291,6 +2321,7 @@ def test_company_service_base_transport(): "update_company", "delete_company", "list_companies", + "get_operation", ) for method in methods: with pytest.raises(NotImplementedError): @@ -2381,6 +2412,28 @@ def test_company_service_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.CompanyServiceGrpcTransport, + transports.CompanyServiceGrpcAsyncIOTransport, + ], +) +def test_company_service_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -2790,6 +2843,151 @@ async def test_transport_close_async(): close.assert_called_once() +def test_get_operation(transport: str = "grpc"): + client = CompanyServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + response = client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +@pytest.mark.asyncio +async def test_get_operation(transport: str = "grpc"): + client = CompanyServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_get_operation_field_headers(): + client = CompanyServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = operations_pb2.Operation() + + client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_operation_field_headers_async(): + client = CompanyServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +def test_get_operation_from_dict(): + client = CompanyServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + + response = client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +@pytest.mark.asyncio +async def test_get_operation_from_dict_async(): + client = CompanyServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + def test_transport_close(): transports = { "grpc": "_grpc_channel", @@ -2850,4 +3048,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) diff --git a/tests/unit/gapic/talent_v4beta1/test_completion.py b/tests/unit/gapic/talent_v4beta1/test_completion.py index 0f182181..66b80a37 100644 --- a/tests/unit/gapic/talent_v4beta1/test_completion.py +++ b/tests/unit/gapic/talent_v4beta1/test_completion.py @@ -30,6 +30,7 @@ import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError +from google.longrunning import operations_pb2 from google.oauth2 import service_account import grpc from grpc.experimental import aio @@ -217,6 +218,7 @@ def test_completion_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -234,6 +236,7 @@ def test_completion_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -251,6 +254,7 @@ def test_completion_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -280,6 +284,25 @@ def test_completion_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -345,6 +368,7 @@ def test_completion_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -379,6 +403,7 @@ def test_completion_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -401,6 +426,7 @@ def test_completion_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -511,6 +537,7 @@ def test_completion_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -544,6 +571,7 @@ def test_completion_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -562,6 +590,7 @@ def test_completion_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -595,6 +624,7 @@ def test_completion_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -910,7 +940,10 @@ def test_completion_base_transport(): # Every method on the transport should just blindly # raise NotImplementedError. - methods = ("complete_query",) + methods = ( + "complete_query", + "get_operation", + ) for method in methods: with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) @@ -1000,6 +1033,28 @@ def test_completion_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.CompletionGrpcTransport, + transports.CompletionGrpcAsyncIOTransport, + ], +) +def test_completion_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -1398,6 +1453,151 @@ async def test_transport_close_async(): close.assert_called_once() +def test_get_operation(transport: str = "grpc"): + client = CompletionClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + response = client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +@pytest.mark.asyncio +async def test_get_operation(transport: str = "grpc"): + client = CompletionAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_get_operation_field_headers(): + client = CompletionClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = operations_pb2.Operation() + + client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_operation_field_headers_async(): + client = CompletionAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +def test_get_operation_from_dict(): + client = CompletionClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + + response = client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +@pytest.mark.asyncio +async def test_get_operation_from_dict_async(): + client = CompletionAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + def test_transport_close(): transports = { "grpc": "_grpc_channel", @@ -1458,4 +1658,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) diff --git a/tests/unit/gapic/talent_v4beta1/test_event_service.py b/tests/unit/gapic/talent_v4beta1/test_event_service.py index e00cd53f..e507cdc7 100644 --- a/tests/unit/gapic/talent_v4beta1/test_event_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_event_service.py @@ -30,6 +30,7 @@ import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError +from google.longrunning import operations_pb2 from google.oauth2 import service_account from google.protobuf import timestamp_pb2 # type: ignore import grpc @@ -218,6 +219,7 @@ def test_event_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -235,6 +237,7 @@ def test_event_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -252,6 +255,7 @@ def test_event_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -281,6 +285,25 @@ def test_event_service_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -346,6 +369,7 @@ def test_event_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -380,6 +404,7 @@ def test_event_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -402,6 +427,7 @@ def test_event_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -512,6 +538,7 @@ def test_event_service_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -550,6 +577,7 @@ def test_event_service_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -568,6 +596,7 @@ def test_event_service_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -606,6 +635,7 @@ def test_event_service_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -1037,7 +1067,10 @@ def test_event_service_base_transport(): # Every method on the transport should just blindly # raise NotImplementedError. - methods = ("create_client_event",) + methods = ( + "create_client_event", + "get_operation", + ) for method in methods: with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) @@ -1127,6 +1160,28 @@ def test_event_service_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.EventServiceGrpcTransport, + transports.EventServiceGrpcAsyncIOTransport, + ], +) +def test_event_service_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -1525,6 +1580,151 @@ async def test_transport_close_async(): close.assert_called_once() +def test_get_operation(transport: str = "grpc"): + client = EventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + response = client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +@pytest.mark.asyncio +async def test_get_operation(transport: str = "grpc"): + client = EventServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_get_operation_field_headers(): + client = EventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = operations_pb2.Operation() + + client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_operation_field_headers_async(): + client = EventServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +def test_get_operation_from_dict(): + client = EventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + + response = client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +@pytest.mark.asyncio +async def test_get_operation_from_dict_async(): + client = EventServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + def test_transport_close(): transports = { "grpc": "_grpc_channel", @@ -1585,4 +1785,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) diff --git a/tests/unit/gapic/talent_v4beta1/test_job_service.py b/tests/unit/gapic/talent_v4beta1/test_job_service.py index c150387e..6f218c4f 100644 --- a/tests/unit/gapic/talent_v4beta1/test_job_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_job_service.py @@ -239,6 +239,7 @@ def test_job_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -256,6 +257,7 @@ def test_job_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -273,6 +275,7 @@ def test_job_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -302,6 +305,25 @@ def test_job_service_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -367,6 +389,7 @@ def test_job_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -401,6 +424,7 @@ def test_job_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -423,6 +447,7 @@ def test_job_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -533,6 +558,7 @@ def test_job_service_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -566,6 +592,7 @@ def test_job_service_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -584,6 +611,7 @@ def test_job_service_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -617,6 +645,7 @@ def test_job_service_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -3828,6 +3857,7 @@ def test_job_service_base_transport(): "list_jobs", "search_jobs", "search_jobs_for_alert", + "get_operation", ) for method in methods: with pytest.raises(NotImplementedError): @@ -3923,6 +3953,28 @@ def test_job_service_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.JobServiceGrpcTransport, + transports.JobServiceGrpcAsyncIOTransport, + ], +) +def test_job_service_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -4381,6 +4433,151 @@ async def test_transport_close_async(): close.assert_called_once() +def test_get_operation(transport: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + response = client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +@pytest.mark.asyncio +async def test_get_operation(transport: str = "grpc"): + client = JobServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_get_operation_field_headers(): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = operations_pb2.Operation() + + client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_operation_field_headers_async(): + client = JobServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +def test_get_operation_from_dict(): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + + response = client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +@pytest.mark.asyncio +async def test_get_operation_from_dict_async(): + client = JobServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + def test_transport_close(): transports = { "grpc": "_grpc_channel", @@ -4441,4 +4638,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) diff --git a/tests/unit/gapic/talent_v4beta1/test_profile_service.py b/tests/unit/gapic/talent_v4beta1/test_profile_service.py deleted file mode 100644 index 53df5a3e..00000000 --- a/tests/unit/gapic/talent_v4beta1/test_profile_service.py +++ /dev/null @@ -1,3167 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os - -# try/except added for compatibility with python < 3.8 -try: - from unittest import mock - from unittest.mock import AsyncMock -except ImportError: - import mock - -import math - -from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -import google.auth -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.oauth2 import service_account -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore -from google.type import date_pb2 # type: ignore -from google.type import latlng_pb2 # type: ignore -from google.type import postal_address_pb2 # type: ignore -import grpc -from grpc.experimental import aio -from proto.marshal.rules.dates import DurationRule, TimestampRule -import pytest - -from google.cloud.talent_v4beta1.services.profile_service import ( - ProfileServiceAsyncClient, - ProfileServiceClient, - pagers, - transports, -) -from google.cloud.talent_v4beta1.types import common, filters, histogram -from google.cloud.talent_v4beta1.types import profile -from google.cloud.talent_v4beta1.types import profile as gct_profile -from google.cloud.talent_v4beta1.types import profile_service - - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return ( - "foo.googleapis.com" - if ("localhost" in client.DEFAULT_ENDPOINT) - else client.DEFAULT_ENDPOINT - ) - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert ProfileServiceClient._get_default_mtls_endpoint(None) is None - assert ( - ProfileServiceClient._get_default_mtls_endpoint(api_endpoint) - == api_mtls_endpoint - ) - assert ( - ProfileServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) - == api_mtls_endpoint - ) - assert ( - ProfileServiceClient._get_default_mtls_endpoint(sandbox_endpoint) - == sandbox_mtls_endpoint - ) - assert ( - ProfileServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) - == sandbox_mtls_endpoint - ) - assert ( - ProfileServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - ) - - -@pytest.mark.parametrize( - "client_class,transport_name", - [ - (ProfileServiceClient, "grpc"), - (ProfileServiceAsyncClient, "grpc_asyncio"), - ], -) -def test_profile_service_client_from_service_account_info(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_info" - ) as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info, transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ("jobs.googleapis.com:443") - - -@pytest.mark.parametrize( - "transport_class,transport_name", - [ - (transports.ProfileServiceGrpcTransport, "grpc"), - (transports.ProfileServiceGrpcAsyncIOTransport, "grpc_asyncio"), - ], -) -def test_profile_service_client_service_account_always_use_jwt( - transport_class, transport_name -): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=True) - use_jwt.assert_called_once_with(True) - - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize( - "client_class,transport_name", - [ - (ProfileServiceClient, "grpc"), - (ProfileServiceAsyncClient, "grpc_asyncio"), - ], -) -def test_profile_service_client_from_service_account_file(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_file" - ) as factory: - factory.return_value = creds - client = client_class.from_service_account_file( - "dummy/file/path.json", transport=transport_name - ) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json( - "dummy/file/path.json", transport=transport_name - ) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ("jobs.googleapis.com:443") - - -def test_profile_service_client_get_transport_class(): - transport = ProfileServiceClient.get_transport_class() - available_transports = [ - transports.ProfileServiceGrpcTransport, - ] - assert transport in available_transports - - transport = ProfileServiceClient.get_transport_class("grpc") - assert transport == transports.ProfileServiceGrpcTransport - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (ProfileServiceClient, transports.ProfileServiceGrpcTransport, "grpc"), - ( - ProfileServiceAsyncClient, - transports.ProfileServiceGrpcAsyncIOTransport, - "grpc_asyncio", - ), - ], -) -@mock.patch.object( - ProfileServiceClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ProfileServiceClient), -) -@mock.patch.object( - ProfileServiceAsyncClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ProfileServiceAsyncClient), -) -def test_profile_service_client_client_options( - client_class, transport_class, transport_name -): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(ProfileServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(ProfileServiceClient, "get_transport_class") as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class(transport=transport_name) - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} - ): - with pytest.raises(ValueError): - client = client_class(transport=transport_name) - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name,use_client_cert_env", - [ - (ProfileServiceClient, transports.ProfileServiceGrpcTransport, "grpc", "true"), - ( - ProfileServiceAsyncClient, - transports.ProfileServiceGrpcAsyncIOTransport, - "grpc_asyncio", - "true", - ), - (ProfileServiceClient, transports.ProfileServiceGrpcTransport, "grpc", "false"), - ( - ProfileServiceAsyncClient, - transports.ProfileServiceGrpcAsyncIOTransport, - "grpc_asyncio", - "false", - ), - ], -) -@mock.patch.object( - ProfileServiceClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ProfileServiceClient), -) -@mock.patch.object( - ProfileServiceAsyncClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ProfileServiceAsyncClient), -) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_profile_service_client_mtls_env_auto( - client_class, transport_class, transport_name, use_client_cert_env -): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - options = client_options.ClientOptions( - client_cert_source=client_cert_source_callback - ) - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=True, - ): - with mock.patch( - "google.auth.transport.mtls.default_client_cert_source", - return_value=client_cert_source_callback, - ): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=False, - ): - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize( - "client_class", [ProfileServiceClient, ProfileServiceAsyncClient] -) -@mock.patch.object( - ProfileServiceClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ProfileServiceClient), -) -@mock.patch.object( - ProfileServiceAsyncClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(ProfileServiceAsyncClient), -) -def test_profile_service_client_get_mtls_endpoint_and_cert_source(client_class): - mock_client_cert_source = mock.Mock() - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - mock_api_endpoint = "foo" - options = client_options.ClientOptions( - client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint - ) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( - options - ) - assert api_endpoint == mock_api_endpoint - assert cert_source == mock_client_cert_source - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - mock_client_cert_source = mock.Mock() - mock_api_endpoint = "foo" - options = client_options.ClientOptions( - client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint - ) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( - options - ) - assert api_endpoint == mock_api_endpoint - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=False, - ): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=True, - ): - with mock.patch( - "google.auth.transport.mtls.default_client_cert_source", - return_value=mock_client_cert_source, - ): - ( - api_endpoint, - cert_source, - ) = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source == mock_client_cert_source - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - (ProfileServiceClient, transports.ProfileServiceGrpcTransport, "grpc"), - ( - ProfileServiceAsyncClient, - transports.ProfileServiceGrpcAsyncIOTransport, - "grpc_asyncio", - ), - ], -) -def test_profile_service_client_client_options_scopes( - client_class, transport_class, transport_name -): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name,grpc_helpers", - [ - ( - ProfileServiceClient, - transports.ProfileServiceGrpcTransport, - "grpc", - grpc_helpers, - ), - ( - ProfileServiceAsyncClient, - transports.ProfileServiceGrpcAsyncIOTransport, - "grpc_asyncio", - grpc_helpers_async, - ), - ], -) -def test_profile_service_client_client_options_credentials_file( - client_class, transport_class, transport_name, grpc_helpers -): - # Check the case credentials file is provided. - options = client_options.ClientOptions(credentials_file="credentials.json") - - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -def test_profile_service_client_client_options_from_dict(): - with mock.patch( - "google.cloud.talent_v4beta1.services.profile_service.transports.ProfileServiceGrpcTransport.__init__" - ) as grpc_transport: - grpc_transport.return_value = None - client = ProfileServiceClient( - client_options={"api_endpoint": "squid.clam.whelk"} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name,grpc_helpers", - [ - ( - ProfileServiceClient, - transports.ProfileServiceGrpcTransport, - "grpc", - grpc_helpers, - ), - ( - ProfileServiceAsyncClient, - transports.ProfileServiceGrpcAsyncIOTransport, - "grpc_asyncio", - grpc_helpers_async, - ), - ], -) -def test_profile_service_client_create_channel_credentials_file( - client_class, transport_class, transport_name, grpc_helpers -): - # Check the case credentials file is provided. - options = client_options.ClientOptions(credentials_file="credentials.json") - - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # test that the credentials from file are saved and used as the credentials. - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel" - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - file_creds = ga_credentials.AnonymousCredentials() - load_creds.return_value = (file_creds, None) - adc.return_value = (creds, None) - client = client_class(client_options=options, transport=transport_name) - create_channel.assert_called_with( - "jobs.googleapis.com:443", - credentials=file_creds, - credentials_file=None, - quota_project_id=None, - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - scopes=None, - default_host="jobs.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "request_type", - [ - profile_service.ListProfilesRequest, - dict, - ], -) -def test_list_profiles(request_type, transport: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = profile_service.ListProfilesResponse( - next_page_token="next_page_token_value", - ) - response = client.list_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.ListProfilesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListProfilesPager) - assert response.next_page_token == "next_page_token_value" - - -def test_list_profiles_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: - client.list_profiles() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.ListProfilesRequest() - - -@pytest.mark.asyncio -async def test_list_profiles_async( - transport: str = "grpc_asyncio", request_type=profile_service.ListProfilesRequest -): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - profile_service.ListProfilesResponse( - next_page_token="next_page_token_value", - ) - ) - response = await client.list_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.ListProfilesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListProfilesAsyncPager) - assert response.next_page_token == "next_page_token_value" - - -@pytest.mark.asyncio -async def test_list_profiles_async_from_dict(): - await test_list_profiles_async(request_type=dict) - - -def test_list_profiles_field_headers(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.ListProfilesRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: - call.return_value = profile_service.ListProfilesResponse() - client.list_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_list_profiles_field_headers_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.ListProfilesRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - profile_service.ListProfilesResponse() - ) - await client.list_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -def test_list_profiles_flattened(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = profile_service.ListProfilesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_profiles( - parent="parent_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - - -def test_list_profiles_flattened_error(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_profiles( - profile_service.ListProfilesRequest(), - parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_list_profiles_flattened_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = profile_service.ListProfilesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - profile_service.ListProfilesResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_profiles( - parent="parent_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_list_profiles_flattened_error_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_profiles( - profile_service.ListProfilesRequest(), - parent="parent_value", - ) - - -def test_list_profiles_pager(transport_name: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - profile.Profile(), - profile.Profile(), - ], - next_page_token="abc", - ), - profile_service.ListProfilesResponse( - profiles=[], - next_page_token="def", - ), - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - ], - next_page_token="ghi", - ), - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - profile.Profile(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_profiles(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, profile.Profile) for i in results) - - -def test_list_profiles_pages(transport_name: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - profile.Profile(), - profile.Profile(), - ], - next_page_token="abc", - ), - profile_service.ListProfilesResponse( - profiles=[], - next_page_token="def", - ), - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - ], - next_page_token="ghi", - ), - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - profile.Profile(), - ], - ), - RuntimeError, - ) - pages = list(client.list_profiles(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.asyncio -async def test_list_profiles_async_pager(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_profiles), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - profile.Profile(), - profile.Profile(), - ], - next_page_token="abc", - ), - profile_service.ListProfilesResponse( - profiles=[], - next_page_token="def", - ), - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - ], - next_page_token="ghi", - ), - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - profile.Profile(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_profiles( - request={}, - ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, profile.Profile) for i in responses) - - -@pytest.mark.asyncio -async def test_list_profiles_async_pages(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_profiles), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - profile.Profile(), - profile.Profile(), - ], - next_page_token="abc", - ), - profile_service.ListProfilesResponse( - profiles=[], - next_page_token="def", - ), - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - ], - next_page_token="ghi", - ), - profile_service.ListProfilesResponse( - profiles=[ - profile.Profile(), - profile.Profile(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in ( - await client.list_profiles(request={}) - ).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize( - "request_type", - [ - profile_service.CreateProfileRequest, - dict, - ], -) -def test_create_profile(request_type, transport: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = gct_profile.Profile( - name="name_value", - external_id="external_id_value", - source="source_value", - uri="uri_value", - group_id="group_id_value", - applications=["applications_value"], - assignments=["assignments_value"], - processed=True, - keyword_snippet="keyword_snippet_value", - ) - response = client.create_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.CreateProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_profile.Profile) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.source == "source_value" - assert response.uri == "uri_value" - assert response.group_id == "group_id_value" - assert response.applications == ["applications_value"] - assert response.assignments == ["assignments_value"] - assert response.processed is True - assert response.keyword_snippet == "keyword_snippet_value" - - -def test_create_profile_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_profile), "__call__") as call: - client.create_profile() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.CreateProfileRequest() - - -@pytest.mark.asyncio -async def test_create_profile_async( - transport: str = "grpc_asyncio", request_type=profile_service.CreateProfileRequest -): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_profile.Profile( - name="name_value", - external_id="external_id_value", - source="source_value", - uri="uri_value", - group_id="group_id_value", - applications=["applications_value"], - assignments=["assignments_value"], - processed=True, - keyword_snippet="keyword_snippet_value", - ) - ) - response = await client.create_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.CreateProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_profile.Profile) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.source == "source_value" - assert response.uri == "uri_value" - assert response.group_id == "group_id_value" - assert response.applications == ["applications_value"] - assert response.assignments == ["assignments_value"] - assert response.processed is True - assert response.keyword_snippet == "keyword_snippet_value" - - -@pytest.mark.asyncio -async def test_create_profile_async_from_dict(): - await test_create_profile_async(request_type=dict) - - -def test_create_profile_field_headers(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.CreateProfileRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_profile), "__call__") as call: - call.return_value = gct_profile.Profile() - client.create_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_create_profile_field_headers_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.CreateProfileRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_profile), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_profile.Profile()) - await client.create_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -def test_create_profile_flattened(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = gct_profile.Profile() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_profile( - parent="parent_value", - profile=gct_profile.Profile(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - arg = args[0].profile - mock_val = gct_profile.Profile(name="name_value") - assert arg == mock_val - - -def test_create_profile_flattened_error(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_profile( - profile_service.CreateProfileRequest(), - parent="parent_value", - profile=gct_profile.Profile(name="name_value"), - ) - - -@pytest.mark.asyncio -async def test_create_profile_flattened_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = gct_profile.Profile() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_profile.Profile()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_profile( - parent="parent_value", - profile=gct_profile.Profile(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - arg = args[0].profile - mock_val = gct_profile.Profile(name="name_value") - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_create_profile_flattened_error_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_profile( - profile_service.CreateProfileRequest(), - parent="parent_value", - profile=gct_profile.Profile(name="name_value"), - ) - - -@pytest.mark.parametrize( - "request_type", - [ - profile_service.GetProfileRequest, - dict, - ], -) -def test_get_profile(request_type, transport: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = profile.Profile( - name="name_value", - external_id="external_id_value", - source="source_value", - uri="uri_value", - group_id="group_id_value", - applications=["applications_value"], - assignments=["assignments_value"], - processed=True, - keyword_snippet="keyword_snippet_value", - ) - response = client.get_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.GetProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, profile.Profile) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.source == "source_value" - assert response.uri == "uri_value" - assert response.group_id == "group_id_value" - assert response.applications == ["applications_value"] - assert response.assignments == ["assignments_value"] - assert response.processed is True - assert response.keyword_snippet == "keyword_snippet_value" - - -def test_get_profile_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_profile), "__call__") as call: - client.get_profile() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.GetProfileRequest() - - -@pytest.mark.asyncio -async def test_get_profile_async( - transport: str = "grpc_asyncio", request_type=profile_service.GetProfileRequest -): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - profile.Profile( - name="name_value", - external_id="external_id_value", - source="source_value", - uri="uri_value", - group_id="group_id_value", - applications=["applications_value"], - assignments=["assignments_value"], - processed=True, - keyword_snippet="keyword_snippet_value", - ) - ) - response = await client.get_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.GetProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, profile.Profile) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.source == "source_value" - assert response.uri == "uri_value" - assert response.group_id == "group_id_value" - assert response.applications == ["applications_value"] - assert response.assignments == ["assignments_value"] - assert response.processed is True - assert response.keyword_snippet == "keyword_snippet_value" - - -@pytest.mark.asyncio -async def test_get_profile_async_from_dict(): - await test_get_profile_async(request_type=dict) - - -def test_get_profile_field_headers(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.GetProfileRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_profile), "__call__") as call: - call.return_value = profile.Profile() - client.get_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_get_profile_field_headers_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.GetProfileRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_profile), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(profile.Profile()) - await client.get_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -def test_get_profile_flattened(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = profile.Profile() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_profile( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -def test_get_profile_flattened_error(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_profile( - profile_service.GetProfileRequest(), - name="name_value", - ) - - -@pytest.mark.asyncio -async def test_get_profile_flattened_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = profile.Profile() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(profile.Profile()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_profile( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_get_profile_flattened_error_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_profile( - profile_service.GetProfileRequest(), - name="name_value", - ) - - -@pytest.mark.parametrize( - "request_type", - [ - profile_service.UpdateProfileRequest, - dict, - ], -) -def test_update_profile(request_type, transport: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = gct_profile.Profile( - name="name_value", - external_id="external_id_value", - source="source_value", - uri="uri_value", - group_id="group_id_value", - applications=["applications_value"], - assignments=["assignments_value"], - processed=True, - keyword_snippet="keyword_snippet_value", - ) - response = client.update_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.UpdateProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_profile.Profile) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.source == "source_value" - assert response.uri == "uri_value" - assert response.group_id == "group_id_value" - assert response.applications == ["applications_value"] - assert response.assignments == ["assignments_value"] - assert response.processed is True - assert response.keyword_snippet == "keyword_snippet_value" - - -def test_update_profile_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_profile), "__call__") as call: - client.update_profile() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.UpdateProfileRequest() - - -@pytest.mark.asyncio -async def test_update_profile_async( - transport: str = "grpc_asyncio", request_type=profile_service.UpdateProfileRequest -): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_profile.Profile( - name="name_value", - external_id="external_id_value", - source="source_value", - uri="uri_value", - group_id="group_id_value", - applications=["applications_value"], - assignments=["assignments_value"], - processed=True, - keyword_snippet="keyword_snippet_value", - ) - ) - response = await client.update_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.UpdateProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_profile.Profile) - assert response.name == "name_value" - assert response.external_id == "external_id_value" - assert response.source == "source_value" - assert response.uri == "uri_value" - assert response.group_id == "group_id_value" - assert response.applications == ["applications_value"] - assert response.assignments == ["assignments_value"] - assert response.processed is True - assert response.keyword_snippet == "keyword_snippet_value" - - -@pytest.mark.asyncio -async def test_update_profile_async_from_dict(): - await test_update_profile_async(request_type=dict) - - -def test_update_profile_field_headers(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.UpdateProfileRequest() - - request.profile.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_profile), "__call__") as call: - call.return_value = gct_profile.Profile() - client.update_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "profile.name=name_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_update_profile_field_headers_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.UpdateProfileRequest() - - request.profile.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_profile), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_profile.Profile()) - await client.update_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "profile.name=name_value", - ) in kw["metadata"] - - -def test_update_profile_flattened(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = gct_profile.Profile() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_profile( - profile=gct_profile.Profile(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].profile - mock_val = gct_profile.Profile(name="name_value") - assert arg == mock_val - - -def test_update_profile_flattened_error(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_profile( - profile_service.UpdateProfileRequest(), - profile=gct_profile.Profile(name="name_value"), - ) - - -@pytest.mark.asyncio -async def test_update_profile_flattened_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = gct_profile.Profile() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_profile.Profile()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_profile( - profile=gct_profile.Profile(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].profile - mock_val = gct_profile.Profile(name="name_value") - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_update_profile_flattened_error_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_profile( - profile_service.UpdateProfileRequest(), - profile=gct_profile.Profile(name="name_value"), - ) - - -@pytest.mark.parametrize( - "request_type", - [ - profile_service.DeleteProfileRequest, - dict, - ], -) -def test_delete_profile(request_type, transport: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.DeleteProfileRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_profile_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: - client.delete_profile() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.DeleteProfileRequest() - - -@pytest.mark.asyncio -async def test_delete_profile_async( - transport: str = "grpc_asyncio", request_type=profile_service.DeleteProfileRequest -): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.DeleteProfileRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_profile_async_from_dict(): - await test_delete_profile_async(request_type=dict) - - -def test_delete_profile_field_headers(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.DeleteProfileRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: - call.return_value = None - client.delete_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_delete_profile_field_headers_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.DeleteProfileRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -def test_delete_profile_flattened(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_profile( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -def test_delete_profile_flattened_error(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_profile( - profile_service.DeleteProfileRequest(), - name="name_value", - ) - - -@pytest.mark.asyncio -async def test_delete_profile_flattened_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_profile( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_delete_profile_flattened_error_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_profile( - profile_service.DeleteProfileRequest(), - name="name_value", - ) - - -@pytest.mark.parametrize( - "request_type", - [ - profile_service.SearchProfilesRequest, - dict, - ], -) -def test_search_profiles(request_type, transport: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = profile_service.SearchProfilesResponse( - estimated_total_size=2141, - next_page_token="next_page_token_value", - result_set_id="result_set_id_value", - ) - response = client.search_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.SearchProfilesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchProfilesPager) - assert response.estimated_total_size == 2141 - assert response.next_page_token == "next_page_token_value" - assert response.result_set_id == "result_set_id_value" - - -def test_search_profiles_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: - client.search_profiles() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.SearchProfilesRequest() - - -@pytest.mark.asyncio -async def test_search_profiles_async( - transport: str = "grpc_asyncio", request_type=profile_service.SearchProfilesRequest -): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - profile_service.SearchProfilesResponse( - estimated_total_size=2141, - next_page_token="next_page_token_value", - result_set_id="result_set_id_value", - ) - ) - response = await client.search_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == profile_service.SearchProfilesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchProfilesAsyncPager) - assert response.estimated_total_size == 2141 - assert response.next_page_token == "next_page_token_value" - assert response.result_set_id == "result_set_id_value" - - -@pytest.mark.asyncio -async def test_search_profiles_async_from_dict(): - await test_search_profiles_async(request_type=dict) - - -def test_search_profiles_field_headers(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.SearchProfilesRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: - call.return_value = profile_service.SearchProfilesResponse() - client.search_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_search_profiles_field_headers_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = profile_service.SearchProfilesRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - profile_service.SearchProfilesResponse() - ) - await client.search_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -def test_search_profiles_pager(transport_name: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - ], - next_page_token="abc", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[], - next_page_token="def", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - ], - next_page_token="ghi", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.search_profiles(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, histogram.HistogramQueryResult) for i in results) - - -def test_search_profiles_pages(transport_name: str = "grpc"): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - ], - next_page_token="abc", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[], - next_page_token="def", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - ], - next_page_token="ghi", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - ], - ), - RuntimeError, - ) - pages = list(client.search_profiles(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.asyncio -async def test_search_profiles_async_pager(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_profiles), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - ], - next_page_token="abc", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[], - next_page_token="def", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - ], - next_page_token="ghi", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - ], - ), - RuntimeError, - ) - async_pager = await client.search_profiles( - request={}, - ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, histogram.HistogramQueryResult) for i in responses) - - -@pytest.mark.asyncio -async def test_search_profiles_async_pages(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_profiles), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - ], - next_page_token="abc", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[], - next_page_token="def", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - ], - next_page_token="ghi", - ), - profile_service.SearchProfilesResponse( - histogram_query_results=[ - histogram.HistogramQueryResult(), - histogram.HistogramQueryResult(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in ( - await client.search_profiles(request={}) - ).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.ProfileServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.ProfileServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ProfileServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.ProfileServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ProfileServiceClient( - client_options=options, - transport=transport, - ) - - # It is an error to provide an api_key and a credential. - options = mock.Mock() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ProfileServiceClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.ProfileServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ProfileServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.ProfileServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = ProfileServiceClient(transport=transport) - assert client.transport is transport - - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.ProfileServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.ProfileServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ProfileServiceGrpcTransport, - transports.ProfileServiceGrpcAsyncIOTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - - -@pytest.mark.parametrize( - "transport_name", - [ - "grpc", - ], -) -def test_transport_kind(transport_name): - transport = ProfileServiceClient.get_transport_class(transport_name)( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert transport.kind == transport_name - - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.ProfileServiceGrpcTransport, - ) - - -def test_profile_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.ProfileServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", - ) - - -def test_profile_service_base_transport(): - # Instantiate the base transport. - with mock.patch( - "google.cloud.talent_v4beta1.services.profile_service.transports.ProfileServiceTransport.__init__" - ) as Transport: - Transport.return_value = None - transport = transports.ProfileServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - "list_profiles", - "create_profile", - "get_profile", - "update_profile", - "delete_profile", - "search_profiles", - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Catch all for all remaining methods and properties - remainder = [ - "kind", - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_profile_service_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.talent_v4beta1.services.profile_service.transports.ProfileServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ProfileServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=None, - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - quota_project_id="octopus", - ) - - -def test_profile_service_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( - "google.cloud.talent_v4beta1.services.profile_service.transports.ProfileServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ProfileServiceTransport() - adc.assert_called_once() - - -def test_profile_service_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - ProfileServiceClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ProfileServiceGrpcTransport, - transports.ProfileServiceGrpcAsyncIOTransport, - ], -) -def test_profile_service_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.ProfileServiceGrpcTransport, grpc_helpers), - (transports.ProfileServiceGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -def test_profile_service_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - - create_channel.assert_called_with( - "jobs.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/jobs", - ), - scopes=["1", "2"], - default_host="jobs.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ProfileServiceGrpcTransport, - transports.ProfileServiceGrpcAsyncIOTransport, - ], -) -def test_profile_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds, - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback, - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, private_key=expected_key - ) - - -@pytest.mark.parametrize( - "transport_name", - [ - "grpc", - "grpc_asyncio", - ], -) -def test_profile_service_host_no_port(transport_name): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), - transport=transport_name, - ) - assert client.transport._host == ("jobs.googleapis.com:443") - - -@pytest.mark.parametrize( - "transport_name", - [ - "grpc", - "grpc_asyncio", - ], -) -def test_profile_service_host_with_port(transport_name): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="jobs.googleapis.com:8000" - ), - transport=transport_name, - ) - assert client.transport._host == ("jobs.googleapis.com:8000") - - -def test_profile_service_grpc_transport_channel(): - channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ProfileServiceGrpcTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_profile_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ProfileServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [ - transports.ProfileServiceGrpcTransport, - transports.ProfileServiceGrpcAsyncIOTransport, - ], -) -def test_profile_service_transport_channel_mtls_with_client_cert_source( - transport_class, -): - with mock.patch( - "grpc.ssl_channel_credentials", autospec=True - ) as grpc_ssl_channel_cred: - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize( - "transport_class", - [ - transports.ProfileServiceGrpcTransport, - transports.ProfileServiceGrpcAsyncIOTransport, - ], -) -def test_profile_service_transport_channel_mtls_with_adc(transport_class): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object( - transport_class, "create_channel" - ) as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_profile_path(): - project = "squid" - tenant = "clam" - profile = "whelk" - expected = "projects/{project}/tenants/{tenant}/profiles/{profile}".format( - project=project, - tenant=tenant, - profile=profile, - ) - actual = ProfileServiceClient.profile_path(project, tenant, profile) - assert expected == actual - - -def test_parse_profile_path(): - expected = { - "project": "octopus", - "tenant": "oyster", - "profile": "nudibranch", - } - path = ProfileServiceClient.profile_path(**expected) - - # Check that the path construction is reversible. - actual = ProfileServiceClient.parse_profile_path(path) - assert expected == actual - - -def test_tenant_path(): - project = "cuttlefish" - tenant = "mussel" - expected = "projects/{project}/tenants/{tenant}".format( - project=project, - tenant=tenant, - ) - actual = ProfileServiceClient.tenant_path(project, tenant) - assert expected == actual - - -def test_parse_tenant_path(): - expected = { - "project": "winkle", - "tenant": "nautilus", - } - path = ProfileServiceClient.tenant_path(**expected) - - # Check that the path construction is reversible. - actual = ProfileServiceClient.parse_tenant_path(path) - assert expected == actual - - -def test_common_billing_account_path(): - billing_account = "scallop" - expected = "billingAccounts/{billing_account}".format( - billing_account=billing_account, - ) - actual = ProfileServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "abalone", - } - path = ProfileServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = ProfileServiceClient.parse_common_billing_account_path(path) - assert expected == actual - - -def test_common_folder_path(): - folder = "squid" - expected = "folders/{folder}".format( - folder=folder, - ) - actual = ProfileServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "clam", - } - path = ProfileServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = ProfileServiceClient.parse_common_folder_path(path) - assert expected == actual - - -def test_common_organization_path(): - organization = "whelk" - expected = "organizations/{organization}".format( - organization=organization, - ) - actual = ProfileServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "octopus", - } - path = ProfileServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = ProfileServiceClient.parse_common_organization_path(path) - assert expected == actual - - -def test_common_project_path(): - project = "oyster" - expected = "projects/{project}".format( - project=project, - ) - actual = ProfileServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nudibranch", - } - path = ProfileServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = ProfileServiceClient.parse_common_project_path(path) - assert expected == actual - - -def test_common_location_path(): - project = "cuttlefish" - location = "mussel" - expected = "projects/{project}/locations/{location}".format( - project=project, - location=location, - ) - actual = ProfileServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "winkle", - "location": "nautilus", - } - path = ProfileServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = ProfileServiceClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_with_default_client_info(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object( - transports.ProfileServiceTransport, "_prep_wrapped_messages" - ) as prep: - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object( - transports.ProfileServiceTransport, "_prep_wrapped_messages" - ) as prep: - transport_class = ProfileServiceClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - -@pytest.mark.asyncio -async def test_transport_close_async(): - client = ProfileServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc_asyncio", - ) - with mock.patch.object( - type(getattr(client.transport, "grpc_channel")), "close" - ) as close: - async with client: - close.assert_not_called() - close.assert_called_once() - - -def test_transport_close(): - transports = { - "grpc": "_grpc_channel", - } - - for transport, close_name in transports.items(): - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport - ) - with mock.patch.object( - type(getattr(client.transport, close_name)), "close" - ) as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -def test_client_ctx(): - transports = [ - "grpc", - ] - for transport in transports: - client = ProfileServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() - - -@pytest.mark.parametrize( - "client_class,transport_class", - [ - (ProfileServiceClient, transports.ProfileServiceGrpcTransport), - (ProfileServiceAsyncClient, transports.ProfileServiceGrpcAsyncIOTransport), - ], -) -def test_api_key_credentials(client_class, transport_class): - with mock.patch.object( - google.auth._default, "get_api_key_credentials", create=True - ) as get_api_key_credentials: - mock_cred = mock.Mock() - get_api_key_credentials.return_value = mock_cred - options = client_options.ClientOptions() - options.api_key = "api_key" - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=mock_cred, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) diff --git a/tests/unit/gapic/talent_v4beta1/test_tenant_service.py b/tests/unit/gapic/talent_v4beta1/test_tenant_service.py index 5fc4db14..2713cac1 100644 --- a/tests/unit/gapic/talent_v4beta1/test_tenant_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_tenant_service.py @@ -30,6 +30,7 @@ import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError +from google.longrunning import operations_pb2 from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore import grpc @@ -226,6 +227,7 @@ def test_tenant_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -243,6 +245,7 @@ def test_tenant_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -260,6 +263,7 @@ def test_tenant_service_client_client_options( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -289,6 +293,25 @@ def test_tenant_service_client_client_options( quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", ) @@ -356,6 +379,7 @@ def test_tenant_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -390,6 +414,7 @@ def test_tenant_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -412,6 +437,7 @@ def test_tenant_service_client_mtls_env_auto( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -526,6 +552,7 @@ def test_tenant_service_client_client_options_scopes( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -564,6 +591,7 @@ def test_tenant_service_client_client_options_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -584,6 +612,7 @@ def test_tenant_service_client_client_options_from_dict(): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) @@ -622,6 +651,7 @@ def test_tenant_service_client_create_channel_credentials_file( quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, ) # test that the credentials from file are saved and used as the credentials. @@ -2192,6 +2222,7 @@ def test_tenant_service_base_transport(): "update_tenant", "delete_tenant", "list_tenants", + "get_operation", ) for method in methods: with pytest.raises(NotImplementedError): @@ -2282,6 +2313,28 @@ def test_tenant_service_transport_auth_adc(transport_class): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.TenantServiceGrpcTransport, + transports.TenantServiceGrpcAsyncIOTransport, + ], +) +def test_tenant_service_transport_auth_gdch_credentials(transport_class): + host = "https://language.com" + api_audience_tests = [None, "https://language2.com"] + api_audience_expect = [host, "https://language2.com"] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, "default", autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock( + return_value=gdch_mock + ) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with(e) + + @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -2686,6 +2739,151 @@ async def test_transport_close_async(): close.assert_called_once() +def test_get_operation(transport: str = "grpc"): + client = TenantServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + response = client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +@pytest.mark.asyncio +async def test_get_operation(transport: str = "grpc"): + client = TenantServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_get_operation_field_headers(): + client = TenantServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = operations_pb2.Operation() + + client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_operation_field_headers_async(): + client = TenantServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +def test_get_operation_from_dict(): + client = TenantServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + + response = client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +@pytest.mark.asyncio +async def test_get_operation_from_dict_async(): + client = TenantServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + def test_transport_close(): transports = { "grpc": "_grpc_channel", @@ -2746,4 +2944,5 @@ def test_api_key_credentials(client_class, transport_class): quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, always_use_jwt_access=True, + api_audience=None, )