From 06129f7e4e91a496376d6b7325c9b7f23a323cf7 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 7 Sep 2022 00:59:05 +0000 Subject: [PATCH 1/2] feat: Bump gapic-generator-python version to 1.3.0 PiperOrigin-RevId: 472561635 Source-Link: https://github.com/googleapis/googleapis/commit/332ecf599f8e747d8d1213b77ae7db26eff12814 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4313d682880fd9d7247291164d4e9d3d5bd9f177 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDMxM2Q2ODI4ODBmZDlkNzI0NzI5MTE2NGQ0ZTlkM2Q1YmQ5ZjE3NyJ9 --- owl-bot-staging/v4/.coveragerc | 17 + owl-bot-staging/v4/.flake8 | 33 + owl-bot-staging/v4/MANIFEST.in | 2 + owl-bot-staging/v4/README.rst | 49 + owl-bot-staging/v4/docs/conf.py | 376 ++ owl-bot-staging/v4/docs/index.rst | 7 + .../v4/docs/talent_v4/company_service.rst | 10 + .../v4/docs/talent_v4/completion.rst | 6 + .../v4/docs/talent_v4/event_service.rst | 6 + .../v4/docs/talent_v4/job_service.rst | 10 + .../v4/docs/talent_v4/services.rst | 10 + .../v4/docs/talent_v4/tenant_service.rst | 10 + owl-bot-staging/v4/docs/talent_v4/types.rst | 7 + .../v4/google/cloud/talent/__init__.py | 161 + .../v4/google/cloud/talent/py.typed | 2 + .../v4/google/cloud/talent_v4/__init__.py | 162 + .../cloud/talent_v4/gapic_metadata.json | 299 ++ .../v4/google/cloud/talent_v4/py.typed | 2 + .../cloud/talent_v4/services/__init__.py | 15 + .../services/company_service/__init__.py | 22 + .../services/company_service/async_client.py | 805 +++ .../services/company_service/client.py | 993 ++++ .../services/company_service/pagers.py | 140 + .../company_service/transports/__init__.py | 33 + .../company_service/transports/base.py | 235 + .../company_service/transports/grpc.py | 374 ++ .../transports/grpc_asyncio.py | 373 ++ .../talent_v4/services/completion/__init__.py | 22 + .../services/completion/async_client.py | 295 ++ .../talent_v4/services/completion/client.py | 498 ++ .../completion/transports/__init__.py | 33 + .../services/completion/transports/base.py | 162 + .../services/completion/transports/grpc.py | 266 + .../completion/transports/grpc_asyncio.py | 265 + .../services/event_service/__init__.py | 22 + .../services/event_service/async_client.py | 340 ++ .../services/event_service/client.py | 540 ++ .../event_service/transports/__init__.py | 33 + .../services/event_service/transports/base.py | 156 + .../services/event_service/transports/grpc.py | 271 + .../event_service/transports/grpc_asyncio.py | 270 + .../services/job_service/__init__.py | 22 + .../services/job_service/async_client.py | 1431 ++++++ .../talent_v4/services/job_service/client.py | 1630 ++++++ .../talent_v4/services/job_service/pagers.py | 140 + .../job_service/transports/__init__.py | 33 + .../services/job_service/transports/base.py | 312 ++ .../services/job_service/transports/grpc.py | 547 +++ .../job_service/transports/grpc_asyncio.py | 546 ++ .../services/tenant_service/__init__.py | 22 + .../services/tenant_service/async_client.py | 797 +++ .../services/tenant_service/client.py | 976 ++++ .../services/tenant_service/pagers.py | 140 + .../tenant_service/transports/__init__.py | 33 + .../tenant_service/transports/base.py | 235 + .../tenant_service/transports/grpc.py | 372 ++ .../tenant_service/transports/grpc_asyncio.py | 371 ++ .../google/cloud/talent_v4/types/__init__.py | 164 + .../v4/google/cloud/talent_v4/types/common.py | 849 ++++ .../google/cloud/talent_v4/types/company.py | 175 + .../cloud/talent_v4/types/company_service.py | 210 + .../talent_v4/types/completion_service.py | 163 + .../v4/google/cloud/talent_v4/types/event.py | 143 + .../cloud/talent_v4/types/event_service.py | 56 + .../google/cloud/talent_v4/types/filters.py | 499 ++ .../google/cloud/talent_v4/types/histogram.py | 82 + .../v4/google/cloud/talent_v4/types/job.py | 569 +++ .../cloud/talent_v4/types/job_service.py | 1126 +++++ .../v4/google/cloud/talent_v4/types/tenant.py | 58 + .../cloud/talent_v4/types/tenant_service.py | 194 + owl-bot-staging/v4/mypy.ini | 3 + owl-bot-staging/v4/noxfile.py | 179 + ...ed_company_service_create_company_async.py | 57 + ...ted_company_service_create_company_sync.py | 57 + ...ed_company_service_delete_company_async.py | 50 + ...ted_company_service_delete_company_sync.py | 50 + ...rated_company_service_get_company_async.py | 52 + ...erated_company_service_get_company_sync.py | 52 + ...ed_company_service_list_companies_async.py | 53 + ...ted_company_service_list_companies_sync.py | 53 + ...ed_company_service_update_company_async.py | 56 + ...ted_company_service_update_company_sync.py | 56 + ...nerated_completion_complete_query_async.py | 54 + ...enerated_completion_complete_query_sync.py | 54 + ...event_service_create_client_event_async.py | 58 + ..._event_service_create_client_event_sync.py | 58 + ...ted_job_service_batch_create_jobs_async.py | 63 + ...ated_job_service_batch_create_jobs_sync.py | 63 + ...ted_job_service_batch_delete_jobs_async.py | 56 + ...ated_job_service_batch_delete_jobs_sync.py | 56 + ...ted_job_service_batch_update_jobs_async.py | 63 + ...ated_job_service_batch_update_jobs_sync.py | 63 + ..._generated_job_service_create_job_async.py | 59 + ...4_generated_job_service_create_job_sync.py | 59 + ..._generated_job_service_delete_job_async.py | 50 + ...4_generated_job_service_delete_job_sync.py | 50 + ..._v4_generated_job_service_get_job_async.py | 52 + ...s_v4_generated_job_service_get_job_sync.py | 52 + ...4_generated_job_service_list_jobs_async.py | 54 + ...v4_generated_job_service_list_jobs_sync.py | 54 + ...generated_job_service_search_jobs_async.py | 52 + ...job_service_search_jobs_for_alert_async.py | 52 + ..._job_service_search_jobs_for_alert_sync.py | 52 + ..._generated_job_service_search_jobs_sync.py | 52 + ..._generated_job_service_update_job_async.py | 58 + ...4_generated_job_service_update_job_sync.py | 58 + ...ated_tenant_service_create_tenant_async.py | 56 + ...rated_tenant_service_create_tenant_sync.py | 56 + ...ated_tenant_service_delete_tenant_async.py | 50 + ...rated_tenant_service_delete_tenant_sync.py | 50 + ...nerated_tenant_service_get_tenant_async.py | 52 + ...enerated_tenant_service_get_tenant_sync.py | 52 + ...rated_tenant_service_list_tenants_async.py | 53 + ...erated_tenant_service_list_tenants_sync.py | 53 + ...ated_tenant_service_update_tenant_async.py | 55 + ...rated_tenant_service_update_tenant_sync.py | 55 + .../snippet_metadata_talent_v4.json | 3602 ++++++++++++++ .../v4/scripts/fixup_talent_v4_keywords.py | 197 + owl-bot-staging/v4/setup.py | 58 + owl-bot-staging/v4/tests/__init__.py | 16 + owl-bot-staging/v4/tests/unit/__init__.py | 16 + .../v4/tests/unit/gapic/__init__.py | 16 + .../v4/tests/unit/gapic/talent_v4/__init__.py | 16 + .../gapic/talent_v4/test_company_service.py | 2687 ++++++++++ .../unit/gapic/talent_v4/test_completion.py | 1328 +++++ .../gapic/talent_v4/test_event_service.py | 1413 ++++++ .../unit/gapic/talent_v4/test_job_service.py | 3895 +++++++++++++++ .../gapic/talent_v4/test_tenant_service.py | 2543 ++++++++++ owl-bot-staging/v4beta1/.coveragerc | 17 + owl-bot-staging/v4beta1/.flake8 | 33 + owl-bot-staging/v4beta1/MANIFEST.in | 2 + owl-bot-staging/v4beta1/README.rst | 49 + owl-bot-staging/v4beta1/docs/conf.py | 376 ++ owl-bot-staging/v4beta1/docs/index.rst | 7 + .../docs/talent_v4beta1/company_service.rst | 10 + .../docs/talent_v4beta1/completion.rst | 6 + .../docs/talent_v4beta1/event_service.rst | 6 + .../docs/talent_v4beta1/job_service.rst | 10 + .../v4beta1/docs/talent_v4beta1/services.rst | 10 + .../docs/talent_v4beta1/tenant_service.rst | 10 + .../v4beta1/docs/talent_v4beta1/types.rst | 7 + .../v4beta1/google/cloud/talent/__init__.py | 155 + .../v4beta1/google/cloud/talent/py.typed | 2 + .../google/cloud/talent_v4beta1/__init__.py | 156 + .../cloud/talent_v4beta1/gapic_metadata.json | 299 ++ .../google/cloud/talent_v4beta1/py.typed | 2 + .../cloud/talent_v4beta1/services/__init__.py | 15 + .../services/company_service/__init__.py | 22 + .../services/company_service/async_client.py | 846 ++++ .../services/company_service/client.py | 1027 ++++ .../services/company_service/pagers.py | 140 + .../company_service/transports/__init__.py | 33 + .../company_service/transports/base.py | 245 + .../company_service/transports/grpc.py | 393 ++ .../transports/grpc_asyncio.py | 392 ++ .../services/completion/__init__.py | 22 + .../services/completion/async_client.py | 345 ++ .../services/completion/client.py | 541 ++ .../completion/transports/__init__.py | 33 + .../services/completion/transports/base.py | 172 + .../services/completion/transports/grpc.py | 285 ++ .../completion/transports/grpc_asyncio.py | 284 ++ .../services/event_service/__init__.py | 22 + .../services/event_service/async_client.py | 394 ++ .../services/event_service/client.py | 596 +++ .../event_service/transports/__init__.py | 33 + .../services/event_service/transports/base.py | 166 + .../services/event_service/transports/grpc.py | 290 ++ .../event_service/transports/grpc_asyncio.py | 289 ++ .../services/job_service/__init__.py | 22 + .../services/job_service/async_client.py | 1476 ++++++ .../services/job_service/client.py | 1668 +++++++ .../services/job_service/pagers.py | 382 ++ .../job_service/transports/__init__.py | 33 + .../services/job_service/transports/base.py | 322 ++ .../services/job_service/transports/grpc.py | 567 +++ .../job_service/transports/grpc_asyncio.py | 566 +++ .../services/tenant_service/__init__.py | 22 + .../services/tenant_service/async_client.py | 829 ++++ .../services/tenant_service/client.py | 1010 ++++ .../services/tenant_service/pagers.py | 140 + .../tenant_service/transports/__init__.py | 33 + .../tenant_service/transports/base.py | 245 + .../tenant_service/transports/grpc.py | 391 ++ .../tenant_service/transports/grpc_asyncio.py | 390 ++ .../cloud/talent_v4beta1/types/__init__.py | 158 + .../cloud/talent_v4beta1/types/batch.py | 25 + .../cloud/talent_v4beta1/types/common.py | 846 ++++ .../cloud/talent_v4beta1/types/company.py | 178 + .../talent_v4beta1/types/company_service.py | 222 + .../types/completion_service.py | 169 + .../cloud/talent_v4beta1/types/event.py | 155 + .../talent_v4beta1/types/event_service.py | 58 + .../cloud/talent_v4beta1/types/filters.py | 511 ++ .../cloud/talent_v4beta1/types/histogram.py | 84 + .../google/cloud/talent_v4beta1/types/job.py | 567 +++ .../cloud/talent_v4beta1/types/job_service.py | 1110 +++++ .../cloud/talent_v4beta1/types/tenant.py | 91 + .../talent_v4beta1/types/tenant_service.py | 194 + owl-bot-staging/v4beta1/mypy.ini | 3 + owl-bot-staging/v4beta1/noxfile.py | 179 + ...ed_company_service_create_company_async.py | 57 + ...ted_company_service_create_company_sync.py | 57 + ...ed_company_service_delete_company_async.py | 50 + ...ted_company_service_delete_company_sync.py | 50 + ...rated_company_service_get_company_async.py | 52 + ...erated_company_service_get_company_sync.py | 52 + ...ed_company_service_list_companies_async.py | 53 + ...ted_company_service_list_companies_sync.py | 53 + ...ed_company_service_update_company_async.py | 56 + ...ted_company_service_update_company_sync.py | 56 + ...nerated_completion_complete_query_async.py | 54 + ...enerated_completion_complete_query_sync.py | 54 + ...event_service_create_client_event_async.py | 58 + ..._event_service_create_client_event_sync.py | 58 + ...ted_job_service_batch_create_jobs_async.py | 63 + ...ated_job_service_batch_create_jobs_sync.py | 63 + ...ted_job_service_batch_delete_jobs_async.py | 51 + ...ated_job_service_batch_delete_jobs_sync.py | 51 + ...ted_job_service_batch_update_jobs_async.py | 63 + ...ated_job_service_batch_update_jobs_sync.py | 63 + ..._generated_job_service_create_job_async.py | 59 + ...1_generated_job_service_create_job_sync.py | 59 + ..._generated_job_service_delete_job_async.py | 50 + ...1_generated_job_service_delete_job_sync.py | 50 + ...ta1_generated_job_service_get_job_async.py | 52 + ...eta1_generated_job_service_get_job_sync.py | 52 + ...1_generated_job_service_list_jobs_async.py | 54 + ...a1_generated_job_service_list_jobs_sync.py | 54 + ...generated_job_service_search_jobs_async.py | 53 + ...job_service_search_jobs_for_alert_async.py | 53 + ..._job_service_search_jobs_for_alert_sync.py | 53 + ..._generated_job_service_search_jobs_sync.py | 53 + ..._generated_job_service_update_job_async.py | 58 + ...1_generated_job_service_update_job_sync.py | 58 + ...ated_tenant_service_create_tenant_async.py | 56 + ...rated_tenant_service_create_tenant_sync.py | 56 + ...ated_tenant_service_delete_tenant_async.py | 50 + ...rated_tenant_service_delete_tenant_sync.py | 50 + ...nerated_tenant_service_get_tenant_async.py | 52 + ...enerated_tenant_service_get_tenant_sync.py | 52 + ...rated_tenant_service_list_tenants_async.py | 53 + ...erated_tenant_service_list_tenants_sync.py | 53 + ...ated_tenant_service_update_tenant_async.py | 55 + ...rated_tenant_service_update_tenant_sync.py | 55 + .../snippet_metadata_talent_v4beta1.json | 3572 ++++++++++++++ .../scripts/fixup_talent_v4beta1_keywords.py | 197 + owl-bot-staging/v4beta1/setup.py | 58 + owl-bot-staging/v4beta1/tests/__init__.py | 16 + .../v4beta1/tests/unit/__init__.py | 16 + .../v4beta1/tests/unit/gapic/__init__.py | 16 + .../unit/gapic/talent_v4beta1/__init__.py | 16 + .../talent_v4beta1/test_company_service.py | 2789 +++++++++++ .../gapic/talent_v4beta1/test_completion.py | 1440 ++++++ .../talent_v4beta1/test_event_service.py | 1546 ++++++ .../gapic/talent_v4beta1/test_job_service.py | 4375 +++++++++++++++++ .../talent_v4beta1/test_tenant_service.py | 2688 ++++++++++ 257 files changed, 77127 insertions(+) create mode 100644 owl-bot-staging/v4/.coveragerc create mode 100644 owl-bot-staging/v4/.flake8 create mode 100644 owl-bot-staging/v4/MANIFEST.in create mode 100644 owl-bot-staging/v4/README.rst create mode 100644 owl-bot-staging/v4/docs/conf.py create mode 100644 owl-bot-staging/v4/docs/index.rst create mode 100644 owl-bot-staging/v4/docs/talent_v4/company_service.rst create mode 100644 owl-bot-staging/v4/docs/talent_v4/completion.rst create mode 100644 owl-bot-staging/v4/docs/talent_v4/event_service.rst create mode 100644 owl-bot-staging/v4/docs/talent_v4/job_service.rst create mode 100644 owl-bot-staging/v4/docs/talent_v4/services.rst create mode 100644 owl-bot-staging/v4/docs/talent_v4/tenant_service.rst create mode 100644 owl-bot-staging/v4/docs/talent_v4/types.rst create mode 100644 owl-bot-staging/v4/google/cloud/talent/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent/py.typed create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/gapic_metadata.json create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/py.typed create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/async_client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/pagers.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/base.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/async_client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/base.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/async_client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/base.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/async_client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/pagers.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/base.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/async_client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/client.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/pagers.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/base.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/__init__.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/common.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/company.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/company_service.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/completion_service.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/event.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/event_service.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/filters.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/histogram.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/job.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/job_service.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/tenant.py create mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/tenant_service.py create mode 100644 owl-bot-staging/v4/mypy.ini create mode 100644 owl-bot-staging/v4/noxfile.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py create mode 100644 owl-bot-staging/v4/samples/generated_samples/snippet_metadata_talent_v4.json create mode 100644 owl-bot-staging/v4/scripts/fixup_talent_v4_keywords.py create mode 100644 owl-bot-staging/v4/setup.py create mode 100644 owl-bot-staging/v4/tests/__init__.py create mode 100644 owl-bot-staging/v4/tests/unit/__init__.py create mode 100644 owl-bot-staging/v4/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/__init__.py create mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_company_service.py create mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_completion.py create mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_event_service.py create mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_job_service.py create mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_tenant_service.py create mode 100644 owl-bot-staging/v4beta1/.coveragerc create mode 100644 owl-bot-staging/v4beta1/.flake8 create mode 100644 owl-bot-staging/v4beta1/MANIFEST.in create mode 100644 owl-bot-staging/v4beta1/README.rst create mode 100644 owl-bot-staging/v4beta1/docs/conf.py create mode 100644 owl-bot-staging/v4beta1/docs/index.rst create mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/company_service.rst create mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/completion.rst create mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/event_service.rst create mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/job_service.rst create mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/services.rst create mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/tenant_service.rst create mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/types.rst create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent/py.typed create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/py.typed create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/async_client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/pagers.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/base.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/async_client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/base.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/async_client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/base.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/async_client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/pagers.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/base.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/async_client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/client.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/pagers.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/__init__.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/batch.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/common.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company_service.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/completion_service.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event_service.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/filters.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/histogram.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job_service.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant.py create mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant_service.py create mode 100644 owl-bot-staging/v4beta1/mypy.ini create mode 100644 owl-bot-staging/v4beta1/noxfile.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py create mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/snippet_metadata_talent_v4beta1.json create mode 100644 owl-bot-staging/v4beta1/scripts/fixup_talent_v4beta1_keywords.py create mode 100644 owl-bot-staging/v4beta1/setup.py create mode 100644 owl-bot-staging/v4beta1/tests/__init__.py create mode 100644 owl-bot-staging/v4beta1/tests/unit/__init__.py create mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/__init__.py create mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_company_service.py create mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_completion.py create mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_event_service.py create mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_job_service.py create mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_tenant_service.py diff --git a/owl-bot-staging/v4/.coveragerc b/owl-bot-staging/v4/.coveragerc new file mode 100644 index 00000000..4ad22152 --- /dev/null +++ b/owl-bot-staging/v4/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/talent/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v4/.flake8 b/owl-bot-staging/v4/.flake8 new file mode 100644 index 00000000..29227d4c --- /dev/null +++ b/owl-bot-staging/v4/.flake8 @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 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 +# +# https://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 by synthtool. DO NOT EDIT! +[flake8] +ignore = E203, E266, E501, W503 +exclude = + # Exclude generated code. + **/proto/** + **/gapic/** + **/services/** + **/types/** + *_pb2.py + + # Standard linting exemptions. + **/.nox/** + __pycache__, + .git, + *.pyc, + conf.py diff --git a/owl-bot-staging/v4/MANIFEST.in b/owl-bot-staging/v4/MANIFEST.in new file mode 100644 index 00000000..54dfff12 --- /dev/null +++ b/owl-bot-staging/v4/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/talent *.py +recursive-include google/cloud/talent_v4 *.py diff --git a/owl-bot-staging/v4/README.rst b/owl-bot-staging/v4/README.rst new file mode 100644 index 00000000..97bb9aff --- /dev/null +++ b/owl-bot-staging/v4/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Talent API +================================================= + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. Enable the Google Cloud Talent API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v4/docs/conf.py b/owl-bot-staging/v4/docs/conf.py new file mode 100644 index 00000000..3dd2f845 --- /dev/null +++ b/owl-bot-staging/v4/docs/conf.py @@ -0,0 +1,376 @@ +# -*- 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. +# +# +# google-cloud-talent documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "4.0.1" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The root toctree document. +root_doc = "index" + +# General information about the project. +project = u"google-cloud-talent" +copyright = u"2022, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-talent-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + root_doc, + "google-cloud-talent.tex", + u"google-cloud-talent Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + root_doc, + "google-cloud-talent", + u"Google Cloud Talent Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + root_doc, + "google-cloud-talent", + u"google-cloud-talent Documentation", + author, + "google-cloud-talent", + "GAPIC library for Google Cloud Talent API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/v4/docs/index.rst b/owl-bot-staging/v4/docs/index.rst new file mode 100644 index 00000000..0390203e --- /dev/null +++ b/owl-bot-staging/v4/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + talent_v4/services + talent_v4/types diff --git a/owl-bot-staging/v4/docs/talent_v4/company_service.rst b/owl-bot-staging/v4/docs/talent_v4/company_service.rst new file mode 100644 index 00000000..7d9acfc3 --- /dev/null +++ b/owl-bot-staging/v4/docs/talent_v4/company_service.rst @@ -0,0 +1,10 @@ +CompanyService +-------------------------------- + +.. automodule:: google.cloud.talent_v4.services.company_service + :members: + :inherited-members: + +.. automodule:: google.cloud.talent_v4.services.company_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/completion.rst b/owl-bot-staging/v4/docs/talent_v4/completion.rst new file mode 100644 index 00000000..3044c5a8 --- /dev/null +++ b/owl-bot-staging/v4/docs/talent_v4/completion.rst @@ -0,0 +1,6 @@ +Completion +---------------------------- + +.. automodule:: google.cloud.talent_v4.services.completion + :members: + :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/event_service.rst b/owl-bot-staging/v4/docs/talent_v4/event_service.rst new file mode 100644 index 00000000..1c90bae1 --- /dev/null +++ b/owl-bot-staging/v4/docs/talent_v4/event_service.rst @@ -0,0 +1,6 @@ +EventService +------------------------------ + +.. automodule:: google.cloud.talent_v4.services.event_service + :members: + :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/job_service.rst b/owl-bot-staging/v4/docs/talent_v4/job_service.rst new file mode 100644 index 00000000..d8824847 --- /dev/null +++ b/owl-bot-staging/v4/docs/talent_v4/job_service.rst @@ -0,0 +1,10 @@ +JobService +---------------------------- + +.. automodule:: google.cloud.talent_v4.services.job_service + :members: + :inherited-members: + +.. automodule:: google.cloud.talent_v4.services.job_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/services.rst b/owl-bot-staging/v4/docs/talent_v4/services.rst new file mode 100644 index 00000000..b2eb192c --- /dev/null +++ b/owl-bot-staging/v4/docs/talent_v4/services.rst @@ -0,0 +1,10 @@ +Services for Google Cloud Talent v4 API +======================================= +.. toctree:: + :maxdepth: 2 + + company_service + completion + event_service + job_service + tenant_service diff --git a/owl-bot-staging/v4/docs/talent_v4/tenant_service.rst b/owl-bot-staging/v4/docs/talent_v4/tenant_service.rst new file mode 100644 index 00000000..26f09b23 --- /dev/null +++ b/owl-bot-staging/v4/docs/talent_v4/tenant_service.rst @@ -0,0 +1,10 @@ +TenantService +------------------------------- + +.. automodule:: google.cloud.talent_v4.services.tenant_service + :members: + :inherited-members: + +.. automodule:: google.cloud.talent_v4.services.tenant_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/types.rst b/owl-bot-staging/v4/docs/talent_v4/types.rst new file mode 100644 index 00000000..9c08edc9 --- /dev/null +++ b/owl-bot-staging/v4/docs/talent_v4/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Talent v4 API +==================================== + +.. automodule:: google.cloud.talent_v4.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v4/google/cloud/talent/__init__.py b/owl-bot-staging/v4/google/cloud/talent/__init__.py new file mode 100644 index 00000000..8ba93499 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent/__init__.py @@ -0,0 +1,161 @@ +# -*- 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.cloud.talent_v4.services.company_service.client import CompanyServiceClient +from google.cloud.talent_v4.services.company_service.async_client import CompanyServiceAsyncClient +from google.cloud.talent_v4.services.completion.client import CompletionClient +from google.cloud.talent_v4.services.completion.async_client import CompletionAsyncClient +from google.cloud.talent_v4.services.event_service.client import EventServiceClient +from google.cloud.talent_v4.services.event_service.async_client import EventServiceAsyncClient +from google.cloud.talent_v4.services.job_service.client import JobServiceClient +from google.cloud.talent_v4.services.job_service.async_client import JobServiceAsyncClient +from google.cloud.talent_v4.services.tenant_service.client import TenantServiceClient +from google.cloud.talent_v4.services.tenant_service.async_client import TenantServiceAsyncClient + +from google.cloud.talent_v4.types.common import BatchOperationMetadata +from google.cloud.talent_v4.types.common import CompensationInfo +from google.cloud.talent_v4.types.common import CustomAttribute +from google.cloud.talent_v4.types.common import DeviceInfo +from google.cloud.talent_v4.types.common import Location +from google.cloud.talent_v4.types.common import RequestMetadata +from google.cloud.talent_v4.types.common import ResponseMetadata +from google.cloud.talent_v4.types.common import SpellingCorrection +from google.cloud.talent_v4.types.common import TimestampRange +from google.cloud.talent_v4.types.common import CommuteMethod +from google.cloud.talent_v4.types.common import CompanySize +from google.cloud.talent_v4.types.common import DegreeType +from google.cloud.talent_v4.types.common import EmploymentType +from google.cloud.talent_v4.types.common import HtmlSanitization +from google.cloud.talent_v4.types.common import JobBenefit +from google.cloud.talent_v4.types.common import JobCategory +from google.cloud.talent_v4.types.common import JobLevel +from google.cloud.talent_v4.types.common import PostingRegion +from google.cloud.talent_v4.types.common import Visibility +from google.cloud.talent_v4.types.company import Company +from google.cloud.talent_v4.types.company_service import CreateCompanyRequest +from google.cloud.talent_v4.types.company_service import DeleteCompanyRequest +from google.cloud.talent_v4.types.company_service import GetCompanyRequest +from google.cloud.talent_v4.types.company_service import ListCompaniesRequest +from google.cloud.talent_v4.types.company_service import ListCompaniesResponse +from google.cloud.talent_v4.types.company_service import UpdateCompanyRequest +from google.cloud.talent_v4.types.completion_service import CompleteQueryRequest +from google.cloud.talent_v4.types.completion_service import CompleteQueryResponse +from google.cloud.talent_v4.types.event import ClientEvent +from google.cloud.talent_v4.types.event import JobEvent +from google.cloud.talent_v4.types.event_service import CreateClientEventRequest +from google.cloud.talent_v4.types.filters import CommuteFilter +from google.cloud.talent_v4.types.filters import CompensationFilter +from google.cloud.talent_v4.types.filters import JobQuery +from google.cloud.talent_v4.types.filters import LocationFilter +from google.cloud.talent_v4.types.histogram import HistogramQuery +from google.cloud.talent_v4.types.histogram import HistogramQueryResult +from google.cloud.talent_v4.types.job import Job +from google.cloud.talent_v4.types.job_service import BatchCreateJobsRequest +from google.cloud.talent_v4.types.job_service import BatchCreateJobsResponse +from google.cloud.talent_v4.types.job_service import BatchDeleteJobsRequest +from google.cloud.talent_v4.types.job_service import BatchDeleteJobsResponse +from google.cloud.talent_v4.types.job_service import BatchUpdateJobsRequest +from google.cloud.talent_v4.types.job_service import BatchUpdateJobsResponse +from google.cloud.talent_v4.types.job_service import CreateJobRequest +from google.cloud.talent_v4.types.job_service import DeleteJobRequest +from google.cloud.talent_v4.types.job_service import GetJobRequest +from google.cloud.talent_v4.types.job_service import JobResult +from google.cloud.talent_v4.types.job_service import ListJobsRequest +from google.cloud.talent_v4.types.job_service import ListJobsResponse +from google.cloud.talent_v4.types.job_service import SearchJobsRequest +from google.cloud.talent_v4.types.job_service import SearchJobsResponse +from google.cloud.talent_v4.types.job_service import UpdateJobRequest +from google.cloud.talent_v4.types.job_service import JobView +from google.cloud.talent_v4.types.tenant import Tenant +from google.cloud.talent_v4.types.tenant_service import CreateTenantRequest +from google.cloud.talent_v4.types.tenant_service import DeleteTenantRequest +from google.cloud.talent_v4.types.tenant_service import GetTenantRequest +from google.cloud.talent_v4.types.tenant_service import ListTenantsRequest +from google.cloud.talent_v4.types.tenant_service import ListTenantsResponse +from google.cloud.talent_v4.types.tenant_service import UpdateTenantRequest + +__all__ = ('CompanyServiceClient', + 'CompanyServiceAsyncClient', + 'CompletionClient', + 'CompletionAsyncClient', + 'EventServiceClient', + 'EventServiceAsyncClient', + 'JobServiceClient', + 'JobServiceAsyncClient', + 'TenantServiceClient', + 'TenantServiceAsyncClient', + 'BatchOperationMetadata', + 'CompensationInfo', + 'CustomAttribute', + 'DeviceInfo', + 'Location', + 'RequestMetadata', + 'ResponseMetadata', + 'SpellingCorrection', + 'TimestampRange', + 'CommuteMethod', + 'CompanySize', + 'DegreeType', + 'EmploymentType', + 'HtmlSanitization', + 'JobBenefit', + 'JobCategory', + 'JobLevel', + 'PostingRegion', + 'Visibility', + 'Company', + 'CreateCompanyRequest', + 'DeleteCompanyRequest', + 'GetCompanyRequest', + 'ListCompaniesRequest', + 'ListCompaniesResponse', + 'UpdateCompanyRequest', + 'CompleteQueryRequest', + 'CompleteQueryResponse', + 'ClientEvent', + 'JobEvent', + 'CreateClientEventRequest', + 'CommuteFilter', + 'CompensationFilter', + 'JobQuery', + 'LocationFilter', + 'HistogramQuery', + 'HistogramQueryResult', + 'Job', + 'BatchCreateJobsRequest', + 'BatchCreateJobsResponse', + 'BatchDeleteJobsRequest', + 'BatchDeleteJobsResponse', + 'BatchUpdateJobsRequest', + 'BatchUpdateJobsResponse', + 'CreateJobRequest', + 'DeleteJobRequest', + 'GetJobRequest', + 'JobResult', + 'ListJobsRequest', + 'ListJobsResponse', + 'SearchJobsRequest', + 'SearchJobsResponse', + 'UpdateJobRequest', + 'JobView', + 'Tenant', + 'CreateTenantRequest', + 'DeleteTenantRequest', + 'GetTenantRequest', + 'ListTenantsRequest', + 'ListTenantsResponse', + 'UpdateTenantRequest', +) diff --git a/owl-bot-staging/v4/google/cloud/talent/py.typed b/owl-bot-staging/v4/google/cloud/talent/py.typed new file mode 100644 index 00000000..d9645927 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-talent package uses inline types. diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/__init__.py new file mode 100644 index 00000000..cecc3ca5 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/__init__.py @@ -0,0 +1,162 @@ +# -*- 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 .services.company_service import CompanyServiceClient +from .services.company_service import CompanyServiceAsyncClient +from .services.completion import CompletionClient +from .services.completion import CompletionAsyncClient +from .services.event_service import EventServiceClient +from .services.event_service import EventServiceAsyncClient +from .services.job_service import JobServiceClient +from .services.job_service import JobServiceAsyncClient +from .services.tenant_service import TenantServiceClient +from .services.tenant_service import TenantServiceAsyncClient + +from .types.common import BatchOperationMetadata +from .types.common import CompensationInfo +from .types.common import CustomAttribute +from .types.common import DeviceInfo +from .types.common import Location +from .types.common import RequestMetadata +from .types.common import ResponseMetadata +from .types.common import SpellingCorrection +from .types.common import TimestampRange +from .types.common import CommuteMethod +from .types.common import CompanySize +from .types.common import DegreeType +from .types.common import EmploymentType +from .types.common import HtmlSanitization +from .types.common import JobBenefit +from .types.common import JobCategory +from .types.common import JobLevel +from .types.common import PostingRegion +from .types.common import Visibility +from .types.company import Company +from .types.company_service import CreateCompanyRequest +from .types.company_service import DeleteCompanyRequest +from .types.company_service import GetCompanyRequest +from .types.company_service import ListCompaniesRequest +from .types.company_service import ListCompaniesResponse +from .types.company_service import UpdateCompanyRequest +from .types.completion_service import CompleteQueryRequest +from .types.completion_service import CompleteQueryResponse +from .types.event import ClientEvent +from .types.event import JobEvent +from .types.event_service import CreateClientEventRequest +from .types.filters import CommuteFilter +from .types.filters import CompensationFilter +from .types.filters import JobQuery +from .types.filters import LocationFilter +from .types.histogram import HistogramQuery +from .types.histogram import HistogramQueryResult +from .types.job import Job +from .types.job_service import BatchCreateJobsRequest +from .types.job_service import BatchCreateJobsResponse +from .types.job_service import BatchDeleteJobsRequest +from .types.job_service import BatchDeleteJobsResponse +from .types.job_service import BatchUpdateJobsRequest +from .types.job_service import BatchUpdateJobsResponse +from .types.job_service import CreateJobRequest +from .types.job_service import DeleteJobRequest +from .types.job_service import GetJobRequest +from .types.job_service import JobResult +from .types.job_service import ListJobsRequest +from .types.job_service import ListJobsResponse +from .types.job_service import SearchJobsRequest +from .types.job_service import SearchJobsResponse +from .types.job_service import UpdateJobRequest +from .types.job_service import JobView +from .types.tenant import Tenant +from .types.tenant_service import CreateTenantRequest +from .types.tenant_service import DeleteTenantRequest +from .types.tenant_service import GetTenantRequest +from .types.tenant_service import ListTenantsRequest +from .types.tenant_service import ListTenantsResponse +from .types.tenant_service import UpdateTenantRequest + +__all__ = ( + 'CompanyServiceAsyncClient', + 'CompletionAsyncClient', + 'EventServiceAsyncClient', + 'JobServiceAsyncClient', + 'TenantServiceAsyncClient', +'BatchCreateJobsRequest', +'BatchCreateJobsResponse', +'BatchDeleteJobsRequest', +'BatchDeleteJobsResponse', +'BatchOperationMetadata', +'BatchUpdateJobsRequest', +'BatchUpdateJobsResponse', +'ClientEvent', +'CommuteFilter', +'CommuteMethod', +'Company', +'CompanyServiceClient', +'CompanySize', +'CompensationFilter', +'CompensationInfo', +'CompleteQueryRequest', +'CompleteQueryResponse', +'CompletionClient', +'CreateClientEventRequest', +'CreateCompanyRequest', +'CreateJobRequest', +'CreateTenantRequest', +'CustomAttribute', +'DegreeType', +'DeleteCompanyRequest', +'DeleteJobRequest', +'DeleteTenantRequest', +'DeviceInfo', +'EmploymentType', +'EventServiceClient', +'GetCompanyRequest', +'GetJobRequest', +'GetTenantRequest', +'HistogramQuery', +'HistogramQueryResult', +'HtmlSanitization', +'Job', +'JobBenefit', +'JobCategory', +'JobEvent', +'JobLevel', +'JobQuery', +'JobResult', +'JobServiceClient', +'JobView', +'ListCompaniesRequest', +'ListCompaniesResponse', +'ListJobsRequest', +'ListJobsResponse', +'ListTenantsRequest', +'ListTenantsResponse', +'Location', +'LocationFilter', +'PostingRegion', +'RequestMetadata', +'ResponseMetadata', +'SearchJobsRequest', +'SearchJobsResponse', +'SpellingCorrection', +'Tenant', +'TenantServiceClient', +'TimestampRange', +'UpdateCompanyRequest', +'UpdateJobRequest', +'UpdateTenantRequest', +'Visibility', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/gapic_metadata.json b/owl-bot-staging/v4/google/cloud/talent_v4/gapic_metadata.json new file mode 100644 index 00000000..3396f471 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/gapic_metadata.json @@ -0,0 +1,299 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.talent_v4", + "protoPackage": "google.cloud.talent.v4", + "schema": "1.0", + "services": { + "CompanyService": { + "clients": { + "grpc": { + "libraryClient": "CompanyServiceClient", + "rpcs": { + "CreateCompany": { + "methods": [ + "create_company" + ] + }, + "DeleteCompany": { + "methods": [ + "delete_company" + ] + }, + "GetCompany": { + "methods": [ + "get_company" + ] + }, + "ListCompanies": { + "methods": [ + "list_companies" + ] + }, + "UpdateCompany": { + "methods": [ + "update_company" + ] + } + } + }, + "grpc-async": { + "libraryClient": "CompanyServiceAsyncClient", + "rpcs": { + "CreateCompany": { + "methods": [ + "create_company" + ] + }, + "DeleteCompany": { + "methods": [ + "delete_company" + ] + }, + "GetCompany": { + "methods": [ + "get_company" + ] + }, + "ListCompanies": { + "methods": [ + "list_companies" + ] + }, + "UpdateCompany": { + "methods": [ + "update_company" + ] + } + } + } + } + }, + "Completion": { + "clients": { + "grpc": { + "libraryClient": "CompletionClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "complete_query" + ] + } + } + }, + "grpc-async": { + "libraryClient": "CompletionAsyncClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "complete_query" + ] + } + } + } + } + }, + "EventService": { + "clients": { + "grpc": { + "libraryClient": "EventServiceClient", + "rpcs": { + "CreateClientEvent": { + "methods": [ + "create_client_event" + ] + } + } + }, + "grpc-async": { + "libraryClient": "EventServiceAsyncClient", + "rpcs": { + "CreateClientEvent": { + "methods": [ + "create_client_event" + ] + } + } + } + } + }, + "JobService": { + "clients": { + "grpc": { + "libraryClient": "JobServiceClient", + "rpcs": { + "BatchCreateJobs": { + "methods": [ + "batch_create_jobs" + ] + }, + "BatchDeleteJobs": { + "methods": [ + "batch_delete_jobs" + ] + }, + "BatchUpdateJobs": { + "methods": [ + "batch_update_jobs" + ] + }, + "CreateJob": { + "methods": [ + "create_job" + ] + }, + "DeleteJob": { + "methods": [ + "delete_job" + ] + }, + "GetJob": { + "methods": [ + "get_job" + ] + }, + "ListJobs": { + "methods": [ + "list_jobs" + ] + }, + "SearchJobs": { + "methods": [ + "search_jobs" + ] + }, + "SearchJobsForAlert": { + "methods": [ + "search_jobs_for_alert" + ] + }, + "UpdateJob": { + "methods": [ + "update_job" + ] + } + } + }, + "grpc-async": { + "libraryClient": "JobServiceAsyncClient", + "rpcs": { + "BatchCreateJobs": { + "methods": [ + "batch_create_jobs" + ] + }, + "BatchDeleteJobs": { + "methods": [ + "batch_delete_jobs" + ] + }, + "BatchUpdateJobs": { + "methods": [ + "batch_update_jobs" + ] + }, + "CreateJob": { + "methods": [ + "create_job" + ] + }, + "DeleteJob": { + "methods": [ + "delete_job" + ] + }, + "GetJob": { + "methods": [ + "get_job" + ] + }, + "ListJobs": { + "methods": [ + "list_jobs" + ] + }, + "SearchJobs": { + "methods": [ + "search_jobs" + ] + }, + "SearchJobsForAlert": { + "methods": [ + "search_jobs_for_alert" + ] + }, + "UpdateJob": { + "methods": [ + "update_job" + ] + } + } + } + } + }, + "TenantService": { + "clients": { + "grpc": { + "libraryClient": "TenantServiceClient", + "rpcs": { + "CreateTenant": { + "methods": [ + "create_tenant" + ] + }, + "DeleteTenant": { + "methods": [ + "delete_tenant" + ] + }, + "GetTenant": { + "methods": [ + "get_tenant" + ] + }, + "ListTenants": { + "methods": [ + "list_tenants" + ] + }, + "UpdateTenant": { + "methods": [ + "update_tenant" + ] + } + } + }, + "grpc-async": { + "libraryClient": "TenantServiceAsyncClient", + "rpcs": { + "CreateTenant": { + "methods": [ + "create_tenant" + ] + }, + "DeleteTenant": { + "methods": [ + "delete_tenant" + ] + }, + "GetTenant": { + "methods": [ + "get_tenant" + ] + }, + "ListTenants": { + "methods": [ + "list_tenants" + ] + }, + "UpdateTenant": { + "methods": [ + "update_tenant" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/py.typed b/owl-bot-staging/v4/google/cloud/talent_v4/py.typed new file mode 100644 index 00000000..d9645927 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-talent package uses inline types. diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/__init__.py new file mode 100644 index 00000000..e8e1c384 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/__init__.py @@ -0,0 +1,15 @@ +# -*- 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. +# diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/__init__.py new file mode 100644 index 00000000..bf2d436c --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import CompanyServiceClient +from .async_client import CompanyServiceAsyncClient + +__all__ = ( + 'CompanyServiceClient', + 'CompanyServiceAsyncClient', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/async_client.py new file mode 100644 index 00000000..9b6c1bb1 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/async_client.py @@ -0,0 +1,805 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4.services.company_service import pagers +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import company +from google.cloud.talent_v4.types import company as gct_company +from google.cloud.talent_v4.types import company_service +from google.protobuf import field_mask_pb2 # type: ignore +from .transports.base import CompanyServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport +from .client import CompanyServiceClient + + +class CompanyServiceAsyncClient: + """A service that handles company management, including CRUD and + enumeration. + """ + + _client: CompanyServiceClient + + DEFAULT_ENDPOINT = CompanyServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = CompanyServiceClient.DEFAULT_MTLS_ENDPOINT + + company_path = staticmethod(CompanyServiceClient.company_path) + parse_company_path = staticmethod(CompanyServiceClient.parse_company_path) + tenant_path = staticmethod(CompanyServiceClient.tenant_path) + parse_tenant_path = staticmethod(CompanyServiceClient.parse_tenant_path) + common_billing_account_path = staticmethod(CompanyServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(CompanyServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(CompanyServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(CompanyServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(CompanyServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(CompanyServiceClient.parse_common_organization_path) + common_project_path = staticmethod(CompanyServiceClient.common_project_path) + parse_common_project_path = staticmethod(CompanyServiceClient.parse_common_project_path) + common_location_path = staticmethod(CompanyServiceClient.common_location_path) + parse_common_location_path = staticmethod(CompanyServiceClient.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: + CompanyServiceAsyncClient: The constructed client. + """ + return CompanyServiceClient.from_service_account_info.__func__(CompanyServiceAsyncClient, 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: + CompanyServiceAsyncClient: The constructed client. + """ + return CompanyServiceClient.from_service_account_file.__func__(CompanyServiceAsyncClient, 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 CompanyServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> CompanyServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CompanyServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(CompanyServiceClient).get_transport_class, type(CompanyServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, CompanyServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the company 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, ~.CompanyServiceTransport]): 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 = CompanyServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_company(self, + request: Union[company_service.CreateCompanyRequest, dict] = None, + *, + parent: str = None, + company: gct_company.Company = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_company.Company: + r"""Creates a new company entity. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_create_company(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + company = talent_v4.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4.CreateCompanyRequest( + parent="parent_value", + company=company, + ) + + # Make the request + response = await client.create_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CreateCompanyRequest, dict]): + The request object. The Request of the CreateCompany + method. + parent (:class:`str`): + Required. Resource name of the tenant under which the + company 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. + company (:class:`google.cloud.talent_v4.types.Company`): + Required. The company to be created. + This corresponds to the ``company`` 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_v4.types.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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, company]) + 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 = company_service.CreateCompanyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if company is not None: + request.company = company + + # 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_company, + 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_company(self, + request: Union[company_service.GetCompanyRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> company.Company: + r"""Retrieves specified company. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_get_company(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.GetCompanyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.GetCompanyRequest, dict]): + The request object. Request for getting a company by + name. + name (:class:`str`): + Required. The resource name of the company to be + retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, + "projects/api-test-project/tenants/foo/companies/bar". + + 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_v4.types.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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 = company_service.GetCompanyRequest(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_company, + 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_company(self, + request: Union[company_service.UpdateCompanyRequest, dict] = None, + *, + company: gct_company.Company = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_company.Company: + r"""Updates specified company. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_update_company(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + company = talent_v4.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4.UpdateCompanyRequest( + company=company, + ) + + # Make the request + response = await client.update_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.UpdateCompanyRequest, dict]): + The request object. Request for updating a specified + company. + company (:class:`google.cloud.talent_v4.types.Company`): + Required. The company resource to + replace the current resource in the + system. + + This corresponds to the ``company`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Strongly recommended for the best service experience. + + If + [update_mask][google.cloud.talent.v4.UpdateCompanyRequest.update_mask] + is provided, only the specified fields in + [company][google.cloud.talent.v4.UpdateCompanyRequest.company] + are updated. Otherwise all the fields are updated. + + A field mask to specify the company fields to be + updated. Only top level fields of + [Company][google.cloud.talent.v4.Company] are supported. + + This corresponds to the ``update_mask`` 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_v4.types.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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([company, update_mask]) + 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 = company_service.UpdateCompanyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if company is not None: + request.company = company + if update_mask is not None: + request.update_mask = update_mask + + # 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_company, + 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(( + ("company.name", request.company.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_company(self, + request: Union[company_service.DeleteCompanyRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes specified company. + Prerequisite: The company has no jobs associated with + it. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_delete_company(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.DeleteCompanyRequest( + name="name_value", + ) + + # Make the request + await client.delete_company(request=request) + + Args: + request (Union[google.cloud.talent_v4.types.DeleteCompanyRequest, dict]): + The request object. Request to delete a company. + name (:class:`str`): + Required. The resource name of the company to be + deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/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 = company_service.DeleteCompanyRequest(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_company, + 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_companies(self, + request: Union[company_service.ListCompaniesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCompaniesAsyncPager: + r"""Lists all companies associated with the project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_list_companies(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.ListCompaniesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_companies(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.ListCompaniesRequest, dict]): + The request object. List companies for which the client + has ACL visibility. + parent (:class:`str`): + Required. Resource name of the tenant under which the + company 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_v4.services.company_service.pagers.ListCompaniesAsyncPager: + The List companies 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 = company_service.ListCompaniesRequest(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_companies, + 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.ListCompaniesAsyncPager( + 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__ = ( + "CompanyServiceAsyncClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/client.py new file mode 100644 index 00000000..1f55d47a --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/client.py @@ -0,0 +1,993 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4.services.company_service import pagers +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import company +from google.cloud.talent_v4.types import company as gct_company +from google.cloud.talent_v4.types import company_service +from google.protobuf import field_mask_pb2 # type: ignore +from .transports.base import CompanyServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import CompanyServiceGrpcTransport +from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport + + +class CompanyServiceClientMeta(type): + """Metaclass for the CompanyService 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[CompanyServiceTransport]] + _transport_registry["grpc"] = CompanyServiceGrpcTransport + _transport_registry["grpc_asyncio"] = CompanyServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[CompanyServiceTransport]: + """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 CompanyServiceClient(metaclass=CompanyServiceClientMeta): + """A service that handles company 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: + CompanyServiceClient: 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: + CompanyServiceClient: 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) -> CompanyServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CompanyServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @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 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, CompanyServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the company 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, CompanyServiceTransport]): 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, CompanyServiceTransport): + # transport is a CompanyServiceTransport 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, + api_audience=client_options.api_audience, + ) + + def create_company(self, + request: Union[company_service.CreateCompanyRequest, dict] = None, + *, + parent: str = None, + company: gct_company.Company = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_company.Company: + r"""Creates a new company entity. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_create_company(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + company = talent_v4.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4.CreateCompanyRequest( + parent="parent_value", + company=company, + ) + + # Make the request + response = client.create_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CreateCompanyRequest, dict]): + The request object. The Request of the CreateCompany + method. + parent (str): + Required. Resource name of the tenant under which the + company 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. + company (google.cloud.talent_v4.types.Company): + Required. The company to be created. + This corresponds to the ``company`` 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_v4.types.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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, company]) + 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 company_service.CreateCompanyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.CreateCompanyRequest): + request = company_service.CreateCompanyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if company is not None: + request.company = company + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_company] + + # 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_company(self, + request: Union[company_service.GetCompanyRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> company.Company: + r"""Retrieves specified company. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_get_company(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4.GetCompanyRequest( + name="name_value", + ) + + # Make the request + response = client.get_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.GetCompanyRequest, dict]): + The request object. Request for getting a company by + name. + name (str): + Required. The resource name of the company to be + retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, + "projects/api-test-project/tenants/foo/companies/bar". + + 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_v4.types.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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 company_service.GetCompanyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.GetCompanyRequest): + request = company_service.GetCompanyRequest(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_company] + + # 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_company(self, + request: Union[company_service.UpdateCompanyRequest, dict] = None, + *, + company: gct_company.Company = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_company.Company: + r"""Updates specified company. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_update_company(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + company = talent_v4.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4.UpdateCompanyRequest( + company=company, + ) + + # Make the request + response = client.update_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.UpdateCompanyRequest, dict]): + The request object. Request for updating a specified + company. + company (google.cloud.talent_v4.types.Company): + Required. The company resource to + replace the current resource in the + system. + + This corresponds to the ``company`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Strongly recommended for the best service experience. + + If + [update_mask][google.cloud.talent.v4.UpdateCompanyRequest.update_mask] + is provided, only the specified fields in + [company][google.cloud.talent.v4.UpdateCompanyRequest.company] + are updated. Otherwise all the fields are updated. + + A field mask to specify the company fields to be + updated. Only top level fields of + [Company][google.cloud.talent.v4.Company] are supported. + + This corresponds to the ``update_mask`` 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_v4.types.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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([company, update_mask]) + 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 company_service.UpdateCompanyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.UpdateCompanyRequest): + request = company_service.UpdateCompanyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if company is not None: + request.company = company + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_company] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("company.name", request.company.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_company(self, + request: Union[company_service.DeleteCompanyRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes specified company. + Prerequisite: The company has no jobs associated with + it. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_delete_company(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4.DeleteCompanyRequest( + name="name_value", + ) + + # Make the request + client.delete_company(request=request) + + Args: + request (Union[google.cloud.talent_v4.types.DeleteCompanyRequest, dict]): + The request object. Request to delete a company. + name (str): + Required. The resource name of the company to be + deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/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 company_service.DeleteCompanyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.DeleteCompanyRequest): + request = company_service.DeleteCompanyRequest(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_company] + + # 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_companies(self, + request: Union[company_service.ListCompaniesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCompaniesPager: + r"""Lists all companies associated with the project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_list_companies(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4.ListCompaniesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_companies(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.ListCompaniesRequest, dict]): + The request object. List companies for which the client + has ACL visibility. + parent (str): + Required. Resource name of the tenant under which the + company 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_v4.services.company_service.pagers.ListCompaniesPager: + The List companies 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 company_service.ListCompaniesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.ListCompaniesRequest): + request = company_service.ListCompaniesRequest(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_companies] + + # 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.ListCompaniesPager( + 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__ = ( + "CompanyServiceClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/pagers.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/pagers.py new file mode 100644 index 00000000..08dbe044 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/pagers.py @@ -0,0 +1,140 @@ +# -*- 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, Sequence, Tuple, Optional, Iterator + +from google.cloud.talent_v4.types import company +from google.cloud.talent_v4.types import company_service + + +class ListCompaniesPager: + """A pager for iterating through ``list_companies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4.types.ListCompaniesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``companies`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCompanies`` requests and continue to iterate + through the ``companies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4.types.ListCompaniesResponse` + 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[..., company_service.ListCompaniesResponse], + request: company_service.ListCompaniesRequest, + response: company_service.ListCompaniesResponse, + *, + 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_v4.types.ListCompaniesRequest): + The initial request object. + response (google.cloud.talent_v4.types.ListCompaniesResponse): + 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 = company_service.ListCompaniesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[company_service.ListCompaniesResponse]: + 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[company.Company]: + for page in self.pages: + yield from page.companies + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCompaniesAsyncPager: + """A pager for iterating through ``list_companies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4.types.ListCompaniesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``companies`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCompanies`` requests and continue to iterate + through the ``companies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4.types.ListCompaniesResponse` + 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[company_service.ListCompaniesResponse]], + request: company_service.ListCompaniesRequest, + response: company_service.ListCompaniesResponse, + *, + 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_v4.types.ListCompaniesRequest): + The initial request object. + response (google.cloud.talent_v4.types.ListCompaniesResponse): + 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 = company_service.ListCompaniesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[company_service.ListCompaniesResponse]: + 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[company.Company]: + async def async_generator(): + async for page in self.pages: + for response in page.companies: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/__init__.py new file mode 100644 index 00000000..1b586f42 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 CompanyServiceTransport +from .grpc import CompanyServiceGrpcTransport +from .grpc_asyncio import CompanyServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[CompanyServiceTransport]] +_transport_registry['grpc'] = CompanyServiceGrpcTransport +_transport_registry['grpc_asyncio'] = CompanyServiceGrpcAsyncIOTransport + +__all__ = ( + 'CompanyServiceTransport', + 'CompanyServiceGrpcTransport', + 'CompanyServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/base.py new file mode 100644 index 00000000..fab33738 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/base.py @@ -0,0 +1,235 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4.types import company +from google.cloud.talent_v4.types import company as gct_company +from google.cloud.talent_v4.types import company_service +from google.protobuf import empty_pb2 # type: ignore + +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 CompanyServiceTransport(abc.ABC): + """Abstract transport class for CompanyService.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.create_company: gapic_v1.method.wrap_method( + self.create_company, + default_timeout=30.0, + client_info=client_info, + ), + self.get_company: gapic_v1.method.wrap_method( + self.get_company, + 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_company: gapic_v1.method.wrap_method( + self.update_company, + default_timeout=30.0, + client_info=client_info, + ), + self.delete_company: gapic_v1.method.wrap_method( + self.delete_company, + 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_companies: gapic_v1.method.wrap_method( + self.list_companies, + 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_company(self) -> Callable[ + [company_service.CreateCompanyRequest], + Union[ + gct_company.Company, + Awaitable[gct_company.Company] + ]]: + raise NotImplementedError() + + @property + def get_company(self) -> Callable[ + [company_service.GetCompanyRequest], + Union[ + company.Company, + Awaitable[company.Company] + ]]: + raise NotImplementedError() + + @property + def update_company(self) -> Callable[ + [company_service.UpdateCompanyRequest], + Union[ + gct_company.Company, + Awaitable[gct_company.Company] + ]]: + raise NotImplementedError() + + @property + def delete_company(self) -> Callable[ + [company_service.DeleteCompanyRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def list_companies(self) -> Callable[ + [company_service.ListCompaniesRequest], + Union[ + company_service.ListCompaniesResponse, + Awaitable[company_service.ListCompaniesResponse] + ]]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ( + 'CompanyServiceTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc.py new file mode 100644 index 00000000..aae783fb --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc.py @@ -0,0 +1,374 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4.types import company +from google.cloud.talent_v4.types import company as gct_company +from google.cloud.talent_v4.types import company_service +from google.protobuf import empty_pb2 # type: ignore +from .base import CompanyServiceTransport, DEFAULT_CLIENT_INFO + + +class CompanyServiceGrpcTransport(CompanyServiceTransport): + """gRPC backend transport for CompanyService. + + A service that handles company 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_company(self) -> Callable[ + [company_service.CreateCompanyRequest], + gct_company.Company]: + r"""Return a callable for the create company method over gRPC. + + Creates a new company entity. + + Returns: + Callable[[~.CreateCompanyRequest], + ~.Company]: + 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_company' not in self._stubs: + self._stubs['create_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/CreateCompany', + request_serializer=company_service.CreateCompanyRequest.serialize, + response_deserializer=gct_company.Company.deserialize, + ) + return self._stubs['create_company'] + + @property + def get_company(self) -> Callable[ + [company_service.GetCompanyRequest], + company.Company]: + r"""Return a callable for the get company method over gRPC. + + Retrieves specified company. + + Returns: + Callable[[~.GetCompanyRequest], + ~.Company]: + 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_company' not in self._stubs: + self._stubs['get_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/GetCompany', + request_serializer=company_service.GetCompanyRequest.serialize, + response_deserializer=company.Company.deserialize, + ) + return self._stubs['get_company'] + + @property + def update_company(self) -> Callable[ + [company_service.UpdateCompanyRequest], + gct_company.Company]: + r"""Return a callable for the update company method over gRPC. + + Updates specified company. + + Returns: + Callable[[~.UpdateCompanyRequest], + ~.Company]: + 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_company' not in self._stubs: + self._stubs['update_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/UpdateCompany', + request_serializer=company_service.UpdateCompanyRequest.serialize, + response_deserializer=gct_company.Company.deserialize, + ) + return self._stubs['update_company'] + + @property + def delete_company(self) -> Callable[ + [company_service.DeleteCompanyRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete company method over gRPC. + + Deletes specified company. + Prerequisite: The company has no jobs associated with + it. + + Returns: + Callable[[~.DeleteCompanyRequest], + ~.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_company' not in self._stubs: + self._stubs['delete_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/DeleteCompany', + request_serializer=company_service.DeleteCompanyRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_company'] + + @property + def list_companies(self) -> Callable[ + [company_service.ListCompaniesRequest], + company_service.ListCompaniesResponse]: + r"""Return a callable for the list companies method over gRPC. + + Lists all companies associated with the project. + + Returns: + Callable[[~.ListCompaniesRequest], + ~.ListCompaniesResponse]: + 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_companies' not in self._stubs: + self._stubs['list_companies'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/ListCompanies', + request_serializer=company_service.ListCompaniesRequest.serialize, + response_deserializer=company_service.ListCompaniesResponse.deserialize, + ) + return self._stubs['list_companies'] + + def close(self): + self.grpc_channel.close() + + @property + def kind(self) -> str: + return "grpc" + + +__all__ = ( + 'CompanyServiceGrpcTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py new file mode 100644 index 00000000..2224505f --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py @@ -0,0 +1,373 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4.types import company +from google.cloud.talent_v4.types import company as gct_company +from google.cloud.talent_v4.types import company_service +from google.protobuf import empty_pb2 # type: ignore +from .base import CompanyServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import CompanyServiceGrpcTransport + + +class CompanyServiceGrpcAsyncIOTransport(CompanyServiceTransport): + """gRPC AsyncIO backend transport for CompanyService. + + A service that handles company 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_company(self) -> Callable[ + [company_service.CreateCompanyRequest], + Awaitable[gct_company.Company]]: + r"""Return a callable for the create company method over gRPC. + + Creates a new company entity. + + Returns: + Callable[[~.CreateCompanyRequest], + Awaitable[~.Company]]: + 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_company' not in self._stubs: + self._stubs['create_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/CreateCompany', + request_serializer=company_service.CreateCompanyRequest.serialize, + response_deserializer=gct_company.Company.deserialize, + ) + return self._stubs['create_company'] + + @property + def get_company(self) -> Callable[ + [company_service.GetCompanyRequest], + Awaitable[company.Company]]: + r"""Return a callable for the get company method over gRPC. + + Retrieves specified company. + + Returns: + Callable[[~.GetCompanyRequest], + Awaitable[~.Company]]: + 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_company' not in self._stubs: + self._stubs['get_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/GetCompany', + request_serializer=company_service.GetCompanyRequest.serialize, + response_deserializer=company.Company.deserialize, + ) + return self._stubs['get_company'] + + @property + def update_company(self) -> Callable[ + [company_service.UpdateCompanyRequest], + Awaitable[gct_company.Company]]: + r"""Return a callable for the update company method over gRPC. + + Updates specified company. + + Returns: + Callable[[~.UpdateCompanyRequest], + Awaitable[~.Company]]: + 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_company' not in self._stubs: + self._stubs['update_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/UpdateCompany', + request_serializer=company_service.UpdateCompanyRequest.serialize, + response_deserializer=gct_company.Company.deserialize, + ) + return self._stubs['update_company'] + + @property + def delete_company(self) -> Callable[ + [company_service.DeleteCompanyRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete company method over gRPC. + + Deletes specified company. + Prerequisite: The company has no jobs associated with + it. + + Returns: + Callable[[~.DeleteCompanyRequest], + 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_company' not in self._stubs: + self._stubs['delete_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/DeleteCompany', + request_serializer=company_service.DeleteCompanyRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_company'] + + @property + def list_companies(self) -> Callable[ + [company_service.ListCompaniesRequest], + Awaitable[company_service.ListCompaniesResponse]]: + r"""Return a callable for the list companies method over gRPC. + + Lists all companies associated with the project. + + Returns: + Callable[[~.ListCompaniesRequest], + Awaitable[~.ListCompaniesResponse]]: + 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_companies' not in self._stubs: + self._stubs['list_companies'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.CompanyService/ListCompanies', + request_serializer=company_service.ListCompaniesRequest.serialize, + response_deserializer=company_service.ListCompaniesResponse.deserialize, + ) + return self._stubs['list_companies'] + + def close(self): + return self.grpc_channel.close() + + +__all__ = ( + 'CompanyServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/__init__.py new file mode 100644 index 00000000..28d77594 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import CompletionClient +from .async_client import CompletionAsyncClient + +__all__ = ( + 'CompletionClient', + 'CompletionAsyncClient', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/async_client.py new file mode 100644 index 00000000..99742513 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/async_client.py @@ -0,0 +1,295 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import completion_service +from .transports.base import CompletionTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport +from .client import CompletionClient + + +class CompletionAsyncClient: + """A service handles auto completion.""" + + _client: CompletionClient + + DEFAULT_ENDPOINT = CompletionClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = CompletionClient.DEFAULT_MTLS_ENDPOINT + + company_path = staticmethod(CompletionClient.company_path) + parse_company_path = staticmethod(CompletionClient.parse_company_path) + tenant_path = staticmethod(CompletionClient.tenant_path) + parse_tenant_path = staticmethod(CompletionClient.parse_tenant_path) + common_billing_account_path = staticmethod(CompletionClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(CompletionClient.parse_common_billing_account_path) + common_folder_path = staticmethod(CompletionClient.common_folder_path) + parse_common_folder_path = staticmethod(CompletionClient.parse_common_folder_path) + common_organization_path = staticmethod(CompletionClient.common_organization_path) + parse_common_organization_path = staticmethod(CompletionClient.parse_common_organization_path) + common_project_path = staticmethod(CompletionClient.common_project_path) + parse_common_project_path = staticmethod(CompletionClient.parse_common_project_path) + common_location_path = staticmethod(CompletionClient.common_location_path) + parse_common_location_path = staticmethod(CompletionClient.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: + CompletionAsyncClient: The constructed client. + """ + return CompletionClient.from_service_account_info.__func__(CompletionAsyncClient, 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: + CompletionAsyncClient: The constructed client. + """ + return CompletionClient.from_service_account_file.__func__(CompletionAsyncClient, 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 CompletionClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> CompletionTransport: + """Returns the transport used by the client instance. + + Returns: + CompletionTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(CompletionClient).get_transport_class, type(CompletionClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, CompletionTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the completion 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, ~.CompletionTransport]): 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 = CompletionClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def complete_query(self, + request: Union[completion_service.CompleteQueryRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> completion_service.CompleteQueryResponse: + r"""Completes the specified prefix with keyword + suggestions. Intended for use by a job search + auto-complete search box. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_complete_query(): + # Create a client + client = talent_v4.CompletionAsyncClient() + + # Initialize request argument(s) + request = talent_v4.CompleteQueryRequest( + tenant="tenant_value", + query="query_value", + page_size=951, + ) + + # Make the request + response = await client.complete_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CompleteQueryRequest, dict]): + The request object. Auto-complete parameters. + 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_v4.types.CompleteQueryResponse: + Response of auto-complete query. + """ + # Create or coerce a protobuf request object. + request = completion_service.CompleteQueryRequest(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.complete_query, + 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(( + ("tenant", request.tenant), + )), + ) + + # 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 + + 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__ = ( + "CompletionAsyncClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/client.py new file mode 100644 index 00000000..b2e484d9 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/client.py @@ -0,0 +1,498 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import completion_service +from .transports.base import CompletionTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import CompletionGrpcTransport +from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport + + +class CompletionClientMeta(type): + """Metaclass for the Completion 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[CompletionTransport]] + _transport_registry["grpc"] = CompletionGrpcTransport + _transport_registry["grpc_asyncio"] = CompletionGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[CompletionTransport]: + """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 CompletionClient(metaclass=CompletionClientMeta): + """A service handles auto completion.""" + + @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: + CompletionClient: 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: + CompletionClient: 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) -> CompletionTransport: + """Returns the transport used by the client instance. + + Returns: + CompletionTransport: The transport used by the client + instance. + """ + return self._transport + + @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 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, CompletionTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the completion 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, CompletionTransport]): 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, CompletionTransport): + # transport is a CompletionTransport 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, + api_audience=client_options.api_audience, + ) + + def complete_query(self, + request: Union[completion_service.CompleteQueryRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> completion_service.CompleteQueryResponse: + r"""Completes the specified prefix with keyword + suggestions. Intended for use by a job search + auto-complete search box. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_complete_query(): + # Create a client + client = talent_v4.CompletionClient() + + # Initialize request argument(s) + request = talent_v4.CompleteQueryRequest( + tenant="tenant_value", + query="query_value", + page_size=951, + ) + + # Make the request + response = client.complete_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CompleteQueryRequest, dict]): + The request object. Auto-complete parameters. + 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_v4.types.CompleteQueryResponse: + Response of auto-complete query. + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a completion_service.CompleteQueryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, completion_service.CompleteQueryRequest): + request = completion_service.CompleteQueryRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.complete_query] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("tenant", request.tenant), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + 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__ = ( + "CompletionClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/__init__.py new file mode 100644 index 00000000..14e86855 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 CompletionTransport +from .grpc import CompletionGrpcTransport +from .grpc_asyncio import CompletionGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[CompletionTransport]] +_transport_registry['grpc'] = CompletionGrpcTransport +_transport_registry['grpc_asyncio'] = CompletionGrpcAsyncIOTransport + +__all__ = ( + 'CompletionTransport', + 'CompletionGrpcTransport', + 'CompletionGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/base.py new file mode 100644 index 00000000..77f959f7 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/base.py @@ -0,0 +1,162 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4.types import completion_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 CompletionTransport(abc.ABC): + """Abstract transport class for Completion.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.complete_query: gapic_v1.method.wrap_method( + self.complete_query, + 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 complete_query(self) -> Callable[ + [completion_service.CompleteQueryRequest], + Union[ + completion_service.CompleteQueryResponse, + Awaitable[completion_service.CompleteQueryResponse] + ]]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ( + 'CompletionTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc.py new file mode 100644 index 00000000..ce77a841 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc.py @@ -0,0 +1,266 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4.types import completion_service +from .base import CompletionTransport, DEFAULT_CLIENT_INFO + + +class CompletionGrpcTransport(CompletionTransport): + """gRPC backend transport for Completion. + + A service handles auto completion. + + 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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 complete_query(self) -> Callable[ + [completion_service.CompleteQueryRequest], + completion_service.CompleteQueryResponse]: + r"""Return a callable for the complete query method over gRPC. + + Completes the specified prefix with keyword + suggestions. Intended for use by a job search + auto-complete search box. + + Returns: + Callable[[~.CompleteQueryRequest], + ~.CompleteQueryResponse]: + 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 'complete_query' not in self._stubs: + self._stubs['complete_query'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.Completion/CompleteQuery', + request_serializer=completion_service.CompleteQueryRequest.serialize, + response_deserializer=completion_service.CompleteQueryResponse.deserialize, + ) + return self._stubs['complete_query'] + + def close(self): + self.grpc_channel.close() + + @property + def kind(self) -> str: + return "grpc" + + +__all__ = ( + 'CompletionGrpcTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py new file mode 100644 index 00000000..fae63e49 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py @@ -0,0 +1,265 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4.types import completion_service +from .base import CompletionTransport, DEFAULT_CLIENT_INFO +from .grpc import CompletionGrpcTransport + + +class CompletionGrpcAsyncIOTransport(CompletionTransport): + """gRPC AsyncIO backend transport for Completion. + + A service handles auto completion. + + 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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 complete_query(self) -> Callable[ + [completion_service.CompleteQueryRequest], + Awaitable[completion_service.CompleteQueryResponse]]: + r"""Return a callable for the complete query method over gRPC. + + Completes the specified prefix with keyword + suggestions. Intended for use by a job search + auto-complete search box. + + Returns: + Callable[[~.CompleteQueryRequest], + Awaitable[~.CompleteQueryResponse]]: + 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 'complete_query' not in self._stubs: + self._stubs['complete_query'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.Completion/CompleteQuery', + request_serializer=completion_service.CompleteQueryRequest.serialize, + response_deserializer=completion_service.CompleteQueryResponse.deserialize, + ) + return self._stubs['complete_query'] + + def close(self): + return self.grpc_channel.close() + + +__all__ = ( + 'CompletionGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/__init__.py new file mode 100644 index 00000000..194a67c4 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import EventServiceClient +from .async_client import EventServiceAsyncClient + +__all__ = ( + 'EventServiceClient', + 'EventServiceAsyncClient', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/async_client.py new file mode 100644 index 00000000..bd8d65aa --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/async_client.py @@ -0,0 +1,340 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4.types import event +from google.cloud.talent_v4.types import event_service +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import EventServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport +from .client import EventServiceClient + + +class EventServiceAsyncClient: + """A service handles client event report.""" + + _client: EventServiceClient + + DEFAULT_ENDPOINT = EventServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = EventServiceClient.DEFAULT_MTLS_ENDPOINT + + tenant_path = staticmethod(EventServiceClient.tenant_path) + parse_tenant_path = staticmethod(EventServiceClient.parse_tenant_path) + common_billing_account_path = staticmethod(EventServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(EventServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(EventServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(EventServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(EventServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(EventServiceClient.parse_common_organization_path) + common_project_path = staticmethod(EventServiceClient.common_project_path) + parse_common_project_path = staticmethod(EventServiceClient.parse_common_project_path) + common_location_path = staticmethod(EventServiceClient.common_location_path) + parse_common_location_path = staticmethod(EventServiceClient.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: + EventServiceAsyncClient: The constructed client. + """ + return EventServiceClient.from_service_account_info.__func__(EventServiceAsyncClient, 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: + EventServiceAsyncClient: The constructed client. + """ + return EventServiceClient.from_service_account_file.__func__(EventServiceAsyncClient, 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 EventServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> EventServiceTransport: + """Returns the transport used by the client instance. + + Returns: + EventServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(EventServiceClient).get_transport_class, type(EventServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, EventServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the event 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, ~.EventServiceTransport]): 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 = EventServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_client_event(self, + request: Union[event_service.CreateClientEventRequest, dict] = None, + *, + parent: str = None, + client_event: event.ClientEvent = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> event.ClientEvent: + r"""Report events issued when end user interacts with customer's + application that uses Cloud Talent Solution. You may inspect the + created events in `self service + tools `__. + `Learn + more `__ + about self service tools. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_create_client_event(): + # Create a client + client = talent_v4.EventServiceAsyncClient() + + # Initialize request argument(s) + client_event = talent_v4.ClientEvent() + client_event.job_event.type_ = "INTERVIEW_GRANTED" + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] + client_event.event_id = "event_id_value" + + request = talent_v4.CreateClientEventRequest( + parent="parent_value", + client_event=client_event, + ) + + # Make the request + response = await client.create_client_event(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CreateClientEventRequest, dict]): + The request object. The report event request. + parent (:class:`str`): + Required. Resource name of the tenant under which the + event 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. + client_event (:class:`google.cloud.talent_v4.types.ClientEvent`): + Required. Events issued when end user + interacts with customer's application + that uses Cloud Talent Solution. + + This corresponds to the ``client_event`` 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_v4.types.ClientEvent: + An event issued when an end user + interacts with the application that + implements Cloud Talent Solution. + Providing this information improves the + quality of results for the API clients, + enabling the service to perform + optimally. The number of events sent + must be consistent with other calls, + such as job searches, issued to the + service by the client. + + """ + # 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, client_event]) + 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 = event_service.CreateClientEventRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if client_event is not None: + request.client_event = client_event + + # 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_client_event, + 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 __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__ = ( + "EventServiceAsyncClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/client.py new file mode 100644 index 00000000..0fb2c9cb --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/client.py @@ -0,0 +1,540 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4.types import event +from google.cloud.talent_v4.types import event_service +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import EventServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import EventServiceGrpcTransport +from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport + + +class EventServiceClientMeta(type): + """Metaclass for the EventService 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[EventServiceTransport]] + _transport_registry["grpc"] = EventServiceGrpcTransport + _transport_registry["grpc_asyncio"] = EventServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[EventServiceTransport]: + """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 EventServiceClient(metaclass=EventServiceClientMeta): + """A service handles client event report.""" + + @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: + EventServiceClient: 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: + EventServiceClient: 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) -> EventServiceTransport: + """Returns the transport used by the client instance. + + Returns: + EventServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @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, EventServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the event 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, EventServiceTransport]): 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, EventServiceTransport): + # transport is a EventServiceTransport 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, + api_audience=client_options.api_audience, + ) + + def create_client_event(self, + request: Union[event_service.CreateClientEventRequest, dict] = None, + *, + parent: str = None, + client_event: event.ClientEvent = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> event.ClientEvent: + r"""Report events issued when end user interacts with customer's + application that uses Cloud Talent Solution. You may inspect the + created events in `self service + tools `__. + `Learn + more `__ + about self service tools. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_create_client_event(): + # Create a client + client = talent_v4.EventServiceClient() + + # Initialize request argument(s) + client_event = talent_v4.ClientEvent() + client_event.job_event.type_ = "INTERVIEW_GRANTED" + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] + client_event.event_id = "event_id_value" + + request = talent_v4.CreateClientEventRequest( + parent="parent_value", + client_event=client_event, + ) + + # Make the request + response = client.create_client_event(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CreateClientEventRequest, dict]): + The request object. The report event request. + parent (str): + Required. Resource name of the tenant under which the + event 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. + client_event (google.cloud.talent_v4.types.ClientEvent): + Required. Events issued when end user + interacts with customer's application + that uses Cloud Talent Solution. + + This corresponds to the ``client_event`` 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_v4.types.ClientEvent: + An event issued when an end user + interacts with the application that + implements Cloud Talent Solution. + Providing this information improves the + quality of results for the API clients, + enabling the service to perform + optimally. The number of events sent + must be consistent with other calls, + such as job searches, issued to the + service by the client. + + """ + # 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, client_event]) + 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 event_service.CreateClientEventRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, event_service.CreateClientEventRequest): + request = event_service.CreateClientEventRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if client_event is not None: + request.client_event = client_event + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_client_event] + + # 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 __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__ = ( + "EventServiceClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/__init__.py new file mode 100644 index 00000000..4647d6a8 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 EventServiceTransport +from .grpc import EventServiceGrpcTransport +from .grpc_asyncio import EventServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[EventServiceTransport]] +_transport_registry['grpc'] = EventServiceGrpcTransport +_transport_registry['grpc_asyncio'] = EventServiceGrpcAsyncIOTransport + +__all__ = ( + 'EventServiceTransport', + 'EventServiceGrpcTransport', + 'EventServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/base.py new file mode 100644 index 00000000..fd166e35 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/base.py @@ -0,0 +1,156 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4.types import event +from google.cloud.talent_v4.types import event_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 EventServiceTransport(abc.ABC): + """Abstract transport class for EventService.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.create_client_event: gapic_v1.method.wrap_method( + self.create_client_event, + 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_client_event(self) -> Callable[ + [event_service.CreateClientEventRequest], + Union[ + event.ClientEvent, + Awaitable[event.ClientEvent] + ]]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ( + 'EventServiceTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc.py new file mode 100644 index 00000000..d46d20d8 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc.py @@ -0,0 +1,271 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4.types import event +from google.cloud.talent_v4.types import event_service +from .base import EventServiceTransport, DEFAULT_CLIENT_INFO + + +class EventServiceGrpcTransport(EventServiceTransport): + """gRPC backend transport for EventService. + + A service handles client event report. + + 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_client_event(self) -> Callable[ + [event_service.CreateClientEventRequest], + event.ClientEvent]: + r"""Return a callable for the create client event method over gRPC. + + Report events issued when end user interacts with customer's + application that uses Cloud Talent Solution. You may inspect the + created events in `self service + tools `__. + `Learn + more `__ + about self service tools. + + Returns: + Callable[[~.CreateClientEventRequest], + ~.ClientEvent]: + 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_client_event' not in self._stubs: + self._stubs['create_client_event'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.EventService/CreateClientEvent', + request_serializer=event_service.CreateClientEventRequest.serialize, + response_deserializer=event.ClientEvent.deserialize, + ) + return self._stubs['create_client_event'] + + def close(self): + self.grpc_channel.close() + + @property + def kind(self) -> str: + return "grpc" + + +__all__ = ( + 'EventServiceGrpcTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py new file mode 100644 index 00000000..789b95c9 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py @@ -0,0 +1,270 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4.types import event +from google.cloud.talent_v4.types import event_service +from .base import EventServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import EventServiceGrpcTransport + + +class EventServiceGrpcAsyncIOTransport(EventServiceTransport): + """gRPC AsyncIO backend transport for EventService. + + A service handles client event report. + + 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_client_event(self) -> Callable[ + [event_service.CreateClientEventRequest], + Awaitable[event.ClientEvent]]: + r"""Return a callable for the create client event method over gRPC. + + Report events issued when end user interacts with customer's + application that uses Cloud Talent Solution. You may inspect the + created events in `self service + tools `__. + `Learn + more `__ + about self service tools. + + Returns: + Callable[[~.CreateClientEventRequest], + Awaitable[~.ClientEvent]]: + 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_client_event' not in self._stubs: + self._stubs['create_client_event'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.EventService/CreateClientEvent', + request_serializer=event_service.CreateClientEventRequest.serialize, + response_deserializer=event.ClientEvent.deserialize, + ) + return self._stubs['create_client_event'] + + def close(self): + return self.grpc_channel.close() + + +__all__ = ( + 'EventServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/__init__.py new file mode 100644 index 00000000..3a5ccd23 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import JobServiceClient +from .async_client import JobServiceAsyncClient + +__all__ = ( + 'JobServiceClient', + 'JobServiceAsyncClient', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/async_client.py new file mode 100644 index 00000000..03d79015 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/async_client.py @@ -0,0 +1,1431 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.talent_v4.services.job_service import pagers +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import histogram +from google.cloud.talent_v4.types import job +from google.cloud.talent_v4.types import job as gct_job +from google.cloud.talent_v4.types import job_service +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport +from .client import JobServiceClient + + +class JobServiceAsyncClient: + """A service handles job management, including job CRUD, + enumeration and search. + """ + + _client: JobServiceClient + + DEFAULT_ENDPOINT = JobServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = JobServiceClient.DEFAULT_MTLS_ENDPOINT + + company_path = staticmethod(JobServiceClient.company_path) + parse_company_path = staticmethod(JobServiceClient.parse_company_path) + job_path = staticmethod(JobServiceClient.job_path) + parse_job_path = staticmethod(JobServiceClient.parse_job_path) + tenant_path = staticmethod(JobServiceClient.tenant_path) + parse_tenant_path = staticmethod(JobServiceClient.parse_tenant_path) + common_billing_account_path = staticmethod(JobServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(JobServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(JobServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(JobServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(JobServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(JobServiceClient.parse_common_organization_path) + common_project_path = staticmethod(JobServiceClient.common_project_path) + parse_common_project_path = staticmethod(JobServiceClient.parse_common_project_path) + common_location_path = staticmethod(JobServiceClient.common_location_path) + parse_common_location_path = staticmethod(JobServiceClient.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: + JobServiceAsyncClient: The constructed client. + """ + return JobServiceClient.from_service_account_info.__func__(JobServiceAsyncClient, 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: + JobServiceAsyncClient: The constructed client. + """ + return JobServiceClient.from_service_account_file.__func__(JobServiceAsyncClient, 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 JobServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> JobServiceTransport: + """Returns the transport used by the client instance. + + Returns: + JobServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(JobServiceClient).get_transport_class, type(JobServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, JobServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the job 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, ~.JobServiceTransport]): 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 = JobServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_job(self, + request: Union[job_service.CreateJobRequest, dict] = None, + *, + parent: str = None, + job: gct_job.Job = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_job.Job: + r"""Creates a new job. + Typically, the job becomes searchable within 10 seconds, + but it may take up to 5 minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_create_job(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + job = talent_v4.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = await client.create_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CreateJobRequest, dict]): + The request object. Create job request. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job 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. + job (:class:`google.cloud.talent_v4.types.Job`): + Required. The Job to be created. + This corresponds to the ``job`` 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_v4.types.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4.Company], which is + the hiring entity responsible for the job. + + """ + # 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, job]) + 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 = job_service.CreateJobRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if job is not None: + request.job = job + + # 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_job, + 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 batch_create_jobs(self, + request: Union[job_service.BatchCreateJobsRequest, dict] = None, + *, + parent: str = None, + jobs: Sequence[job.Job] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Begins executing a batch create jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_batch_create_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + jobs = talent_v4.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4.BatchCreateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_create_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.BatchCreateJobsRequest, dict]): + The request object. Request to create a batch of jobs. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job 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. + jobs (:class:`Sequence[google.cloud.talent_v4.types.Job]`): + Required. The jobs to be created. + A maximum of 200 jobs can be created in + a batch. + + This corresponds to the ``jobs`` 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchCreateJobsResponse` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4.JobService.BatchCreateJobs]. It's used to + replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, jobs]) + 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 = job_service.BatchCreateJobsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if jobs: + request.jobs.extend(jobs) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_create_jobs, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + job_service.BatchCreateJobsResponse, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + async def get_job(self, + request: Union[job_service.GetJobRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> job.Job: + r"""Retrieves the specified job, whose status is OPEN or + recently EXPIRED within the last 90 days. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_get_job(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.GetJobRequest( + name="name_value", + ) + + # Make the request + response = await client.get_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.GetJobRequest, dict]): + The request object. Get job request. + name (:class:`str`): + Required. The resource name of the job to retrieve. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/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_v4.types.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4.Company], which is + the hiring entity responsible for the job. + + """ + # 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 = job_service.GetJobRequest(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_job, + 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_job(self, + request: Union[job_service.UpdateJobRequest, dict] = None, + *, + job: gct_job.Job = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_job.Job: + r"""Updates specified job. + Typically, updated contents become visible in search + results within 10 seconds, but it may take up to 5 + minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_update_job(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + job = talent_v4.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4.UpdateJobRequest( + job=job, + ) + + # Make the request + response = await client.update_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.UpdateJobRequest, dict]): + The request object. Update job request. + job (:class:`google.cloud.talent_v4.types.Job`): + Required. The Job to be updated. + This corresponds to the ``job`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Strongly recommended for the best service experience. + + If + [update_mask][google.cloud.talent.v4.UpdateJobRequest.update_mask] + is provided, only the specified fields in + [job][google.cloud.talent.v4.UpdateJobRequest.job] are + updated. Otherwise all the fields are updated. + + A field mask to restrict the fields that are updated. + Only top level fields of + [Job][google.cloud.talent.v4.Job] are supported. + + This corresponds to the ``update_mask`` 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_v4.types.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4.Company], which is + the hiring entity responsible for the job. + + """ + # 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([job, update_mask]) + 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 = job_service.UpdateJobRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if job is not None: + request.job = job + if update_mask is not None: + request.update_mask = update_mask + + # 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_job, + 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(( + ("job.name", request.job.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def batch_update_jobs(self, + request: Union[job_service.BatchUpdateJobsRequest, dict] = None, + *, + parent: str = None, + jobs: Sequence[job.Job] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Begins executing a batch update jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_batch_update_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + jobs = talent_v4.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4.BatchUpdateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_update_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.BatchUpdateJobsRequest, dict]): + The request object. Request to update a batch of jobs. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job 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. + jobs (:class:`Sequence[google.cloud.talent_v4.types.Job]`): + Required. The jobs to be updated. + A maximum of 200 jobs can be updated in + a batch. + + This corresponds to the ``jobs`` 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchUpdateJobsResponse` The result of [JobService.BatchUpdateJobs][google.cloud.talent.v4.JobService.BatchUpdateJobs]. It's used to + replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, jobs]) + 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 = job_service.BatchUpdateJobsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if jobs: + request.jobs.extend(jobs) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_update_jobs, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + job_service.BatchUpdateJobsResponse, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_job(self, + request: Union[job_service.DeleteJobRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes the specified job. + Typically, the job becomes unsearchable within 10 + seconds, but it may take up to 5 minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_delete_job(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.DeleteJobRequest( + name="name_value", + ) + + # Make the request + await client.delete_job(request=request) + + Args: + request (Union[google.cloud.talent_v4.types.DeleteJobRequest, dict]): + The request object. Delete job request. + name (:class:`str`): + Required. The resource name of the job to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/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 = job_service.DeleteJobRequest(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_job, + 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 batch_delete_jobs(self, + request: Union[job_service.BatchDeleteJobsRequest, dict] = None, + *, + parent: str = None, + names: Sequence[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Begins executing a batch delete jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_batch_delete_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.BatchDeleteJobsRequest( + parent="parent_value", + ) + + # Make the request + operation = client.batch_delete_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.BatchDeleteJobsRequest, dict]): + The request object. Request to delete a batch of jobs. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenants/bar". + + The parent of all of the jobs specified in ``names`` + must match this field. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + names (:class:`Sequence[str]`): + The names of the jobs to delete. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + A maximum of 200 jobs can be deleted in a batch. + + This corresponds to the ``names`` 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchDeleteJobsResponse` The result of [JobService.BatchDeleteJobs][google.cloud.talent.v4.JobService.BatchDeleteJobs]. It's used to + replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, names]) + 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 = job_service.BatchDeleteJobsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if names: + request.names.extend(names) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_delete_jobs, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + job_service.BatchDeleteJobsResponse, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + async def list_jobs(self, + request: Union[job_service.ListJobsRequest, dict] = None, + *, + parent: str = None, + filter: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListJobsAsyncPager: + r"""Lists jobs by filter. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_list_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.ListJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.ListJobsRequest, dict]): + The request object. List jobs request. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job 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. + filter (:class:`str`): + Required. The filter string specifies the jobs to be + enumerated. + + Supported operator: =, AND + + The fields eligible for filtering are: + + - ``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" + - requisitionId = "req-1" + - requisitionId = "req-1" AND status = "EXPIRED" + + This corresponds to the ``filter`` 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_v4.services.job_service.pagers.ListJobsAsyncPager: + List jobs response. + 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, filter]) + 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 = job_service.ListJobsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # 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_jobs, + 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.ListJobsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def search_jobs(self, + request: Union[job_service.SearchJobsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> job_service.SearchJobsResponse: + r"""Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + + This call constrains the + [visibility][google.cloud.talent.v4.Job.visibility] of jobs + present in the database, and only returns jobs that the caller + has permission to search against. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_search_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + response = await client.search_jobs(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.SearchJobsRequest, dict]): + The request object. The Request body of the `SearchJobs` + 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_v4.types.SearchJobsResponse: + Response for SearchJob method. + """ + # Create or coerce a protobuf request object. + request = job_service.SearchJobsRequest(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_jobs, + 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 search_jobs_for_alert(self, + request: Union[job_service.SearchJobsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> job_service.SearchJobsResponse: + r"""Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + + This API call is intended for the use case of targeting passive + job seekers (for example, job seekers who have signed up to + receive email alerts about potential job opportunities), it has + different algorithmic adjustments that are designed to + specifically target passive job seekers. + + This call constrains the + [visibility][google.cloud.talent.v4.Job.visibility] of jobs + present in the database, and only returns jobs the caller has + permission to search against. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_search_jobs_for_alert(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + response = await client.search_jobs_for_alert(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.SearchJobsRequest, dict]): + The request object. The Request body of the `SearchJobs` + 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_v4.types.SearchJobsResponse: + Response for SearchJob method. + """ + # Create or coerce a protobuf request object. + request = job_service.SearchJobsRequest(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_jobs_for_alert, + 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 __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__ = ( + "JobServiceAsyncClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/client.py new file mode 100644 index 00000000..ad995993 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/client.py @@ -0,0 +1,1630 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.talent_v4.services.job_service import pagers +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import histogram +from google.cloud.talent_v4.types import job +from google.cloud.talent_v4.types import job as gct_job +from google.cloud.talent_v4.types import job_service +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import JobServiceGrpcTransport +from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport + + +class JobServiceClientMeta(type): + """Metaclass for the JobService 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[JobServiceTransport]] + _transport_registry["grpc"] = JobServiceGrpcTransport + _transport_registry["grpc_asyncio"] = JobServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[JobServiceTransport]: + """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 JobServiceClient(metaclass=JobServiceClientMeta): + """A service handles job management, including job 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: + JobServiceClient: 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: + JobServiceClient: 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) -> JobServiceTransport: + """Returns the transport used by the client instance. + + Returns: + JobServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @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 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, JobServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the job 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, JobServiceTransport]): 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, JobServiceTransport): + # transport is a JobServiceTransport 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, + api_audience=client_options.api_audience, + ) + + def create_job(self, + request: Union[job_service.CreateJobRequest, dict] = None, + *, + parent: str = None, + job: gct_job.Job = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_job.Job: + r"""Creates a new job. + Typically, the job becomes searchable within 10 seconds, + but it may take up to 5 minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_create_job(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + job = talent_v4.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = client.create_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CreateJobRequest, dict]): + The request object. Create job request. + parent (str): + Required. The resource name of the tenant under which + the job 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. + job (google.cloud.talent_v4.types.Job): + Required. The Job to be created. + This corresponds to the ``job`` 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_v4.types.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4.Company], which is + the hiring entity responsible for the job. + + """ + # 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, job]) + 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 job_service.CreateJobRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.CreateJobRequest): + request = job_service.CreateJobRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if job is not None: + request.job = job + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_job] + + # 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 batch_create_jobs(self, + request: Union[job_service.BatchCreateJobsRequest, dict] = None, + *, + parent: str = None, + jobs: Sequence[job.Job] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Begins executing a batch create jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_batch_create_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + jobs = talent_v4.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4.BatchCreateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_create_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.BatchCreateJobsRequest, dict]): + The request object. Request to create a batch of jobs. + parent (str): + Required. The resource name of the tenant under which + the job 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. + jobs (Sequence[google.cloud.talent_v4.types.Job]): + Required. The jobs to be created. + A maximum of 200 jobs can be created in + a batch. + + This corresponds to the ``jobs`` 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchCreateJobsResponse` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4.JobService.BatchCreateJobs]. It's used to + replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, jobs]) + 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 job_service.BatchCreateJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.BatchCreateJobsRequest): + request = job_service.BatchCreateJobsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if jobs is not None: + request.jobs = jobs + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_create_jobs] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + job_service.BatchCreateJobsResponse, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + def get_job(self, + request: Union[job_service.GetJobRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> job.Job: + r"""Retrieves the specified job, whose status is OPEN or + recently EXPIRED within the last 90 days. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_get_job(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.GetJobRequest( + name="name_value", + ) + + # Make the request + response = client.get_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.GetJobRequest, dict]): + The request object. Get job request. + name (str): + Required. The resource name of the job to retrieve. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/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_v4.types.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4.Company], which is + the hiring entity responsible for the job. + + """ + # 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 job_service.GetJobRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.GetJobRequest): + request = job_service.GetJobRequest(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_job] + + # 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_job(self, + request: Union[job_service.UpdateJobRequest, dict] = None, + *, + job: gct_job.Job = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_job.Job: + r"""Updates specified job. + Typically, updated contents become visible in search + results within 10 seconds, but it may take up to 5 + minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_update_job(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + job = talent_v4.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4.UpdateJobRequest( + job=job, + ) + + # Make the request + response = client.update_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.UpdateJobRequest, dict]): + The request object. Update job request. + job (google.cloud.talent_v4.types.Job): + Required. The Job to be updated. + This corresponds to the ``job`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Strongly recommended for the best service experience. + + If + [update_mask][google.cloud.talent.v4.UpdateJobRequest.update_mask] + is provided, only the specified fields in + [job][google.cloud.talent.v4.UpdateJobRequest.job] are + updated. Otherwise all the fields are updated. + + A field mask to restrict the fields that are updated. + Only top level fields of + [Job][google.cloud.talent.v4.Job] are supported. + + This corresponds to the ``update_mask`` 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_v4.types.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4.Company], which is + the hiring entity responsible for the job. + + """ + # 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([job, update_mask]) + 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 job_service.UpdateJobRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.UpdateJobRequest): + request = job_service.UpdateJobRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if job is not None: + request.job = job + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_job] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("job.name", request.job.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def batch_update_jobs(self, + request: Union[job_service.BatchUpdateJobsRequest, dict] = None, + *, + parent: str = None, + jobs: Sequence[job.Job] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Begins executing a batch update jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_batch_update_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + jobs = talent_v4.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4.BatchUpdateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_update_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.BatchUpdateJobsRequest, dict]): + The request object. Request to update a batch of jobs. + parent (str): + Required. The resource name of the tenant under which + the job 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. + jobs (Sequence[google.cloud.talent_v4.types.Job]): + Required. The jobs to be updated. + A maximum of 200 jobs can be updated in + a batch. + + This corresponds to the ``jobs`` 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchUpdateJobsResponse` The result of [JobService.BatchUpdateJobs][google.cloud.talent.v4.JobService.BatchUpdateJobs]. It's used to + replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, jobs]) + 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 job_service.BatchUpdateJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.BatchUpdateJobsRequest): + request = job_service.BatchUpdateJobsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if jobs is not None: + request.jobs = jobs + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_update_jobs] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + job_service.BatchUpdateJobsResponse, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + def delete_job(self, + request: Union[job_service.DeleteJobRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes the specified job. + Typically, the job becomes unsearchable within 10 + seconds, but it may take up to 5 minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_delete_job(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.DeleteJobRequest( + name="name_value", + ) + + # Make the request + client.delete_job(request=request) + + Args: + request (Union[google.cloud.talent_v4.types.DeleteJobRequest, dict]): + The request object. Delete job request. + name (str): + Required. The resource name of the job to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/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 job_service.DeleteJobRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.DeleteJobRequest): + request = job_service.DeleteJobRequest(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_job] + + # 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 batch_delete_jobs(self, + request: Union[job_service.BatchDeleteJobsRequest, dict] = None, + *, + parent: str = None, + names: Sequence[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Begins executing a batch delete jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_batch_delete_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.BatchDeleteJobsRequest( + parent="parent_value", + ) + + # Make the request + operation = client.batch_delete_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.BatchDeleteJobsRequest, dict]): + The request object. Request to delete a batch of jobs. + parent (str): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenants/bar". + + The parent of all of the jobs specified in ``names`` + must match this field. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + names (Sequence[str]): + The names of the jobs to delete. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + A maximum of 200 jobs can be deleted in a batch. + + This corresponds to the ``names`` 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchDeleteJobsResponse` The result of [JobService.BatchDeleteJobs][google.cloud.talent.v4.JobService.BatchDeleteJobs]. It's used to + replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, names]) + 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 job_service.BatchDeleteJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.BatchDeleteJobsRequest): + request = job_service.BatchDeleteJobsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if names is not None: + request.names = names + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_delete_jobs] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + job_service.BatchDeleteJobsResponse, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + def list_jobs(self, + request: Union[job_service.ListJobsRequest, dict] = None, + *, + parent: str = None, + filter: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListJobsPager: + r"""Lists jobs by filter. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_list_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.ListJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.ListJobsRequest, dict]): + The request object. List jobs request. + parent (str): + Required. The resource name of the tenant under which + the job 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. + filter (str): + Required. The filter string specifies the jobs to be + enumerated. + + Supported operator: =, AND + + The fields eligible for filtering are: + + - ``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" + - requisitionId = "req-1" + - requisitionId = "req-1" AND status = "EXPIRED" + + This corresponds to the ``filter`` 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_v4.services.job_service.pagers.ListJobsPager: + List jobs response. + 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, filter]) + 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 job_service.ListJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.ListJobsRequest): + request = job_service.ListJobsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_jobs] + + # 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.ListJobsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def search_jobs(self, + request: Union[job_service.SearchJobsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> job_service.SearchJobsResponse: + r"""Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + + This call constrains the + [visibility][google.cloud.talent.v4.Job.visibility] of jobs + present in the database, and only returns jobs that the caller + has permission to search against. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_search_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + response = client.search_jobs(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.SearchJobsRequest, dict]): + The request object. The Request body of the `SearchJobs` + 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_v4.types.SearchJobsResponse: + Response for SearchJob method. + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a job_service.SearchJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.SearchJobsRequest): + request = job_service.SearchJobsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.search_jobs] + + # 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 search_jobs_for_alert(self, + request: Union[job_service.SearchJobsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> job_service.SearchJobsResponse: + r"""Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + + This API call is intended for the use case of targeting passive + job seekers (for example, job seekers who have signed up to + receive email alerts about potential job opportunities), it has + different algorithmic adjustments that are designed to + specifically target passive job seekers. + + This call constrains the + [visibility][google.cloud.talent.v4.Job.visibility] of jobs + present in the database, and only returns jobs the caller has + permission to search against. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_search_jobs_for_alert(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + response = client.search_jobs_for_alert(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.SearchJobsRequest, dict]): + The request object. The Request body of the `SearchJobs` + 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_v4.types.SearchJobsResponse: + Response for SearchJob method. + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a job_service.SearchJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.SearchJobsRequest): + request = job_service.SearchJobsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.search_jobs_for_alert] + + # 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 __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__ = ( + "JobServiceClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/pagers.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/pagers.py new file mode 100644 index 00000000..b0dbb50e --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/pagers.py @@ -0,0 +1,140 @@ +# -*- 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, Sequence, Tuple, Optional, Iterator + +from google.cloud.talent_v4.types import job +from google.cloud.talent_v4.types import job_service + + +class ListJobsPager: + """A pager for iterating through ``list_jobs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4.types.ListJobsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``jobs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListJobs`` requests and continue to iterate + through the ``jobs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4.types.ListJobsResponse` + 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[..., job_service.ListJobsResponse], + request: job_service.ListJobsRequest, + response: job_service.ListJobsResponse, + *, + 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_v4.types.ListJobsRequest): + The initial request object. + response (google.cloud.talent_v4.types.ListJobsResponse): + 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 = job_service.ListJobsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[job_service.ListJobsResponse]: + 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[job.Job]: + for page in self.pages: + yield from page.jobs + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListJobsAsyncPager: + """A pager for iterating through ``list_jobs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4.types.ListJobsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``jobs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListJobs`` requests and continue to iterate + through the ``jobs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4.types.ListJobsResponse` + 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[job_service.ListJobsResponse]], + request: job_service.ListJobsRequest, + response: job_service.ListJobsResponse, + *, + 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_v4.types.ListJobsRequest): + The initial request object. + response (google.cloud.talent_v4.types.ListJobsResponse): + 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 = job_service.ListJobsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[job_service.ListJobsResponse]: + 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[job.Job]: + async def async_generator(): + async for page in self.pages: + for response in page.jobs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/__init__.py new file mode 100644 index 00000000..05345304 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 JobServiceTransport +from .grpc import JobServiceGrpcTransport +from .grpc_asyncio import JobServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[JobServiceTransport]] +_transport_registry['grpc'] = JobServiceGrpcTransport +_transport_registry['grpc_asyncio'] = JobServiceGrpcAsyncIOTransport + +__all__ = ( + 'JobServiceTransport', + 'JobServiceGrpcTransport', + 'JobServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/base.py new file mode 100644 index 00000000..3458a8f0 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/base.py @@ -0,0 +1,312 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4.types import job +from google.cloud.talent_v4.types import job as gct_job +from google.cloud.talent_v4.types import job_service +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore + +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 JobServiceTransport(abc.ABC): + """Abstract transport class for JobService.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.create_job: gapic_v1.method.wrap_method( + self.create_job, + default_timeout=30.0, + client_info=client_info, + ), + self.batch_create_jobs: gapic_v1.method.wrap_method( + self.batch_create_jobs, + default_timeout=30.0, + client_info=client_info, + ), + self.get_job: gapic_v1.method.wrap_method( + self.get_job, + 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_job: gapic_v1.method.wrap_method( + self.update_job, + default_timeout=30.0, + client_info=client_info, + ), + self.batch_update_jobs: gapic_v1.method.wrap_method( + self.batch_update_jobs, + default_timeout=30.0, + client_info=client_info, + ), + self.delete_job: gapic_v1.method.wrap_method( + self.delete_job, + 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.batch_delete_jobs: gapic_v1.method.wrap_method( + self.batch_delete_jobs, + default_timeout=30.0, + client_info=client_info, + ), + self.list_jobs: gapic_v1.method.wrap_method( + self.list_jobs, + 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_jobs: gapic_v1.method.wrap_method( + self.search_jobs, + default_timeout=30.0, + client_info=client_info, + ), + self.search_jobs_for_alert: gapic_v1.method.wrap_method( + self.search_jobs_for_alert, + 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 operations_client(self): + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def create_job(self) -> Callable[ + [job_service.CreateJobRequest], + Union[ + gct_job.Job, + Awaitable[gct_job.Job] + ]]: + raise NotImplementedError() + + @property + def batch_create_jobs(self) -> Callable[ + [job_service.BatchCreateJobsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_job(self) -> Callable[ + [job_service.GetJobRequest], + Union[ + job.Job, + Awaitable[job.Job] + ]]: + raise NotImplementedError() + + @property + def update_job(self) -> Callable[ + [job_service.UpdateJobRequest], + Union[ + gct_job.Job, + Awaitable[gct_job.Job] + ]]: + raise NotImplementedError() + + @property + def batch_update_jobs(self) -> Callable[ + [job_service.BatchUpdateJobsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_job(self) -> Callable[ + [job_service.DeleteJobRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def batch_delete_jobs(self) -> Callable[ + [job_service.BatchDeleteJobsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_jobs(self) -> Callable[ + [job_service.ListJobsRequest], + Union[ + job_service.ListJobsResponse, + Awaitable[job_service.ListJobsResponse] + ]]: + raise NotImplementedError() + + @property + def search_jobs(self) -> Callable[ + [job_service.SearchJobsRequest], + Union[ + job_service.SearchJobsResponse, + Awaitable[job_service.SearchJobsResponse] + ]]: + raise NotImplementedError() + + @property + def search_jobs_for_alert(self) -> Callable[ + [job_service.SearchJobsRequest], + Union[ + job_service.SearchJobsResponse, + Awaitable[job_service.SearchJobsResponse] + ]]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ( + 'JobServiceTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc.py new file mode 100644 index 00000000..f6213994 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc.py @@ -0,0 +1,547 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4.types import job +from google.cloud.talent_v4.types import job as gct_job +from google.cloud.talent_v4.types import job_service +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import JobServiceTransport, DEFAULT_CLIENT_INFO + + +class JobServiceGrpcTransport(JobServiceTransport): + """gRPC backend transport for JobService. + + A service handles job management, including job 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, + api_audience: Optional[str] = None, + ) -> 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] = {} + self._operations_client: Optional[operations_v1.OperationsClient] = None + + 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, + api_audience=api_audience, + ) + + 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 operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Quick check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_job(self) -> Callable[ + [job_service.CreateJobRequest], + gct_job.Job]: + r"""Return a callable for the create job method over gRPC. + + Creates a new job. + Typically, the job becomes searchable within 10 seconds, + but it may take up to 5 minutes. + + Returns: + Callable[[~.CreateJobRequest], + ~.Job]: + 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_job' not in self._stubs: + self._stubs['create_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/CreateJob', + request_serializer=job_service.CreateJobRequest.serialize, + response_deserializer=gct_job.Job.deserialize, + ) + return self._stubs['create_job'] + + @property + def batch_create_jobs(self) -> Callable[ + [job_service.BatchCreateJobsRequest], + operations_pb2.Operation]: + r"""Return a callable for the batch create jobs method over gRPC. + + Begins executing a batch create jobs operation. + + Returns: + Callable[[~.BatchCreateJobsRequest], + ~.Operation]: + 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 'batch_create_jobs' not in self._stubs: + self._stubs['batch_create_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/BatchCreateJobs', + request_serializer=job_service.BatchCreateJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_create_jobs'] + + @property + def get_job(self) -> Callable[ + [job_service.GetJobRequest], + job.Job]: + r"""Return a callable for the get job method over gRPC. + + Retrieves the specified job, whose status is OPEN or + recently EXPIRED within the last 90 days. + + Returns: + Callable[[~.GetJobRequest], + ~.Job]: + 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_job' not in self._stubs: + self._stubs['get_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/GetJob', + request_serializer=job_service.GetJobRequest.serialize, + response_deserializer=job.Job.deserialize, + ) + return self._stubs['get_job'] + + @property + def update_job(self) -> Callable[ + [job_service.UpdateJobRequest], + gct_job.Job]: + r"""Return a callable for the update job method over gRPC. + + Updates specified job. + Typically, updated contents become visible in search + results within 10 seconds, but it may take up to 5 + minutes. + + Returns: + Callable[[~.UpdateJobRequest], + ~.Job]: + 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_job' not in self._stubs: + self._stubs['update_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/UpdateJob', + request_serializer=job_service.UpdateJobRequest.serialize, + response_deserializer=gct_job.Job.deserialize, + ) + return self._stubs['update_job'] + + @property + def batch_update_jobs(self) -> Callable[ + [job_service.BatchUpdateJobsRequest], + operations_pb2.Operation]: + r"""Return a callable for the batch update jobs method over gRPC. + + Begins executing a batch update jobs operation. + + Returns: + Callable[[~.BatchUpdateJobsRequest], + ~.Operation]: + 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 'batch_update_jobs' not in self._stubs: + self._stubs['batch_update_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/BatchUpdateJobs', + request_serializer=job_service.BatchUpdateJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_update_jobs'] + + @property + def delete_job(self) -> Callable[ + [job_service.DeleteJobRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete job method over gRPC. + + Deletes the specified job. + Typically, the job becomes unsearchable within 10 + seconds, but it may take up to 5 minutes. + + Returns: + Callable[[~.DeleteJobRequest], + ~.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_job' not in self._stubs: + self._stubs['delete_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/DeleteJob', + request_serializer=job_service.DeleteJobRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_job'] + + @property + def batch_delete_jobs(self) -> Callable[ + [job_service.BatchDeleteJobsRequest], + operations_pb2.Operation]: + r"""Return a callable for the batch delete jobs method over gRPC. + + Begins executing a batch delete jobs operation. + + Returns: + Callable[[~.BatchDeleteJobsRequest], + ~.Operation]: + 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 'batch_delete_jobs' not in self._stubs: + self._stubs['batch_delete_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/BatchDeleteJobs', + request_serializer=job_service.BatchDeleteJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_delete_jobs'] + + @property + def list_jobs(self) -> Callable[ + [job_service.ListJobsRequest], + job_service.ListJobsResponse]: + r"""Return a callable for the list jobs method over gRPC. + + Lists jobs by filter. + + Returns: + Callable[[~.ListJobsRequest], + ~.ListJobsResponse]: + 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_jobs' not in self._stubs: + self._stubs['list_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/ListJobs', + request_serializer=job_service.ListJobsRequest.serialize, + response_deserializer=job_service.ListJobsResponse.deserialize, + ) + return self._stubs['list_jobs'] + + @property + def search_jobs(self) -> Callable[ + [job_service.SearchJobsRequest], + job_service.SearchJobsResponse]: + r"""Return a callable for the search jobs method over gRPC. + + Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + + This call constrains the + [visibility][google.cloud.talent.v4.Job.visibility] of jobs + present in the database, and only returns jobs that the caller + has permission to search against. + + Returns: + Callable[[~.SearchJobsRequest], + ~.SearchJobsResponse]: + 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_jobs' not in self._stubs: + self._stubs['search_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/SearchJobs', + request_serializer=job_service.SearchJobsRequest.serialize, + response_deserializer=job_service.SearchJobsResponse.deserialize, + ) + return self._stubs['search_jobs'] + + @property + def search_jobs_for_alert(self) -> Callable[ + [job_service.SearchJobsRequest], + job_service.SearchJobsResponse]: + r"""Return a callable for the search jobs for alert method over gRPC. + + Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + + This API call is intended for the use case of targeting passive + job seekers (for example, job seekers who have signed up to + receive email alerts about potential job opportunities), it has + different algorithmic adjustments that are designed to + specifically target passive job seekers. + + This call constrains the + [visibility][google.cloud.talent.v4.Job.visibility] of jobs + present in the database, and only returns jobs the caller has + permission to search against. + + Returns: + Callable[[~.SearchJobsRequest], + ~.SearchJobsResponse]: + 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_jobs_for_alert' not in self._stubs: + self._stubs['search_jobs_for_alert'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/SearchJobsForAlert', + request_serializer=job_service.SearchJobsRequest.serialize, + response_deserializer=job_service.SearchJobsResponse.deserialize, + ) + return self._stubs['search_jobs_for_alert'] + + def close(self): + self.grpc_channel.close() + + @property + def kind(self) -> str: + return "grpc" + + +__all__ = ( + 'JobServiceGrpcTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py new file mode 100644 index 00000000..6762f591 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py @@ -0,0 +1,546 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4.types import job +from google.cloud.talent_v4.types import job as gct_job +from google.cloud.talent_v4.types import job_service +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import JobServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import JobServiceGrpcTransport + + +class JobServiceGrpcAsyncIOTransport(JobServiceTransport): + """gRPC AsyncIO backend transport for JobService. + + A service handles job management, including job 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, + api_audience: Optional[str] = None, + ) -> 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] = {} + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None + + 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, + api_audience=api_audience, + ) + + 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 operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Quick check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_job(self) -> Callable[ + [job_service.CreateJobRequest], + Awaitable[gct_job.Job]]: + r"""Return a callable for the create job method over gRPC. + + Creates a new job. + Typically, the job becomes searchable within 10 seconds, + but it may take up to 5 minutes. + + Returns: + Callable[[~.CreateJobRequest], + Awaitable[~.Job]]: + 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_job' not in self._stubs: + self._stubs['create_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/CreateJob', + request_serializer=job_service.CreateJobRequest.serialize, + response_deserializer=gct_job.Job.deserialize, + ) + return self._stubs['create_job'] + + @property + def batch_create_jobs(self) -> Callable[ + [job_service.BatchCreateJobsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the batch create jobs method over gRPC. + + Begins executing a batch create jobs operation. + + Returns: + Callable[[~.BatchCreateJobsRequest], + Awaitable[~.Operation]]: + 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 'batch_create_jobs' not in self._stubs: + self._stubs['batch_create_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/BatchCreateJobs', + request_serializer=job_service.BatchCreateJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_create_jobs'] + + @property + def get_job(self) -> Callable[ + [job_service.GetJobRequest], + Awaitable[job.Job]]: + r"""Return a callable for the get job method over gRPC. + + Retrieves the specified job, whose status is OPEN or + recently EXPIRED within the last 90 days. + + Returns: + Callable[[~.GetJobRequest], + Awaitable[~.Job]]: + 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_job' not in self._stubs: + self._stubs['get_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/GetJob', + request_serializer=job_service.GetJobRequest.serialize, + response_deserializer=job.Job.deserialize, + ) + return self._stubs['get_job'] + + @property + def update_job(self) -> Callable[ + [job_service.UpdateJobRequest], + Awaitable[gct_job.Job]]: + r"""Return a callable for the update job method over gRPC. + + Updates specified job. + Typically, updated contents become visible in search + results within 10 seconds, but it may take up to 5 + minutes. + + Returns: + Callable[[~.UpdateJobRequest], + Awaitable[~.Job]]: + 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_job' not in self._stubs: + self._stubs['update_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/UpdateJob', + request_serializer=job_service.UpdateJobRequest.serialize, + response_deserializer=gct_job.Job.deserialize, + ) + return self._stubs['update_job'] + + @property + def batch_update_jobs(self) -> Callable[ + [job_service.BatchUpdateJobsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the batch update jobs method over gRPC. + + Begins executing a batch update jobs operation. + + Returns: + Callable[[~.BatchUpdateJobsRequest], + Awaitable[~.Operation]]: + 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 'batch_update_jobs' not in self._stubs: + self._stubs['batch_update_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/BatchUpdateJobs', + request_serializer=job_service.BatchUpdateJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_update_jobs'] + + @property + def delete_job(self) -> Callable[ + [job_service.DeleteJobRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete job method over gRPC. + + Deletes the specified job. + Typically, the job becomes unsearchable within 10 + seconds, but it may take up to 5 minutes. + + Returns: + Callable[[~.DeleteJobRequest], + 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_job' not in self._stubs: + self._stubs['delete_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/DeleteJob', + request_serializer=job_service.DeleteJobRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_job'] + + @property + def batch_delete_jobs(self) -> Callable[ + [job_service.BatchDeleteJobsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the batch delete jobs method over gRPC. + + Begins executing a batch delete jobs operation. + + Returns: + Callable[[~.BatchDeleteJobsRequest], + Awaitable[~.Operation]]: + 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 'batch_delete_jobs' not in self._stubs: + self._stubs['batch_delete_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/BatchDeleteJobs', + request_serializer=job_service.BatchDeleteJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_delete_jobs'] + + @property + def list_jobs(self) -> Callable[ + [job_service.ListJobsRequest], + Awaitable[job_service.ListJobsResponse]]: + r"""Return a callable for the list jobs method over gRPC. + + Lists jobs by filter. + + Returns: + Callable[[~.ListJobsRequest], + Awaitable[~.ListJobsResponse]]: + 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_jobs' not in self._stubs: + self._stubs['list_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/ListJobs', + request_serializer=job_service.ListJobsRequest.serialize, + response_deserializer=job_service.ListJobsResponse.deserialize, + ) + return self._stubs['list_jobs'] + + @property + def search_jobs(self) -> Callable[ + [job_service.SearchJobsRequest], + Awaitable[job_service.SearchJobsResponse]]: + r"""Return a callable for the search jobs method over gRPC. + + Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + + This call constrains the + [visibility][google.cloud.talent.v4.Job.visibility] of jobs + present in the database, and only returns jobs that the caller + has permission to search against. + + Returns: + Callable[[~.SearchJobsRequest], + Awaitable[~.SearchJobsResponse]]: + 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_jobs' not in self._stubs: + self._stubs['search_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/SearchJobs', + request_serializer=job_service.SearchJobsRequest.serialize, + response_deserializer=job_service.SearchJobsResponse.deserialize, + ) + return self._stubs['search_jobs'] + + @property + def search_jobs_for_alert(self) -> Callable[ + [job_service.SearchJobsRequest], + Awaitable[job_service.SearchJobsResponse]]: + r"""Return a callable for the search jobs for alert method over gRPC. + + Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + + This API call is intended for the use case of targeting passive + job seekers (for example, job seekers who have signed up to + receive email alerts about potential job opportunities), it has + different algorithmic adjustments that are designed to + specifically target passive job seekers. + + This call constrains the + [visibility][google.cloud.talent.v4.Job.visibility] of jobs + present in the database, and only returns jobs the caller has + permission to search against. + + Returns: + Callable[[~.SearchJobsRequest], + Awaitable[~.SearchJobsResponse]]: + 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_jobs_for_alert' not in self._stubs: + self._stubs['search_jobs_for_alert'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.JobService/SearchJobsForAlert', + request_serializer=job_service.SearchJobsRequest.serialize, + response_deserializer=job_service.SearchJobsResponse.deserialize, + ) + return self._stubs['search_jobs_for_alert'] + + def close(self): + return self.grpc_channel.close() + + +__all__ = ( + 'JobServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/__init__.py new file mode 100644 index 00000000..03b84ddf --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import TenantServiceClient +from .async_client import TenantServiceAsyncClient + +__all__ = ( + 'TenantServiceClient', + 'TenantServiceAsyncClient', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/async_client.py new file mode 100644 index 00000000..48325618 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/async_client.py @@ -0,0 +1,797 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4.services.tenant_service import pagers +from google.cloud.talent_v4.types import tenant +from google.cloud.talent_v4.types import tenant as gct_tenant +from google.cloud.talent_v4.types import tenant_service +from google.protobuf import field_mask_pb2 # type: ignore +from .transports.base import TenantServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport +from .client import TenantServiceClient + + +class TenantServiceAsyncClient: + """A service that handles tenant management, including CRUD and + enumeration. + """ + + _client: TenantServiceClient + + DEFAULT_ENDPOINT = TenantServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = TenantServiceClient.DEFAULT_MTLS_ENDPOINT + + tenant_path = staticmethod(TenantServiceClient.tenant_path) + parse_tenant_path = staticmethod(TenantServiceClient.parse_tenant_path) + common_billing_account_path = staticmethod(TenantServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(TenantServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(TenantServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(TenantServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(TenantServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(TenantServiceClient.parse_common_organization_path) + common_project_path = staticmethod(TenantServiceClient.common_project_path) + parse_common_project_path = staticmethod(TenantServiceClient.parse_common_project_path) + common_location_path = staticmethod(TenantServiceClient.common_location_path) + parse_common_location_path = staticmethod(TenantServiceClient.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: + TenantServiceAsyncClient: The constructed client. + """ + return TenantServiceClient.from_service_account_info.__func__(TenantServiceAsyncClient, 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: + TenantServiceAsyncClient: The constructed client. + """ + return TenantServiceClient.from_service_account_file.__func__(TenantServiceAsyncClient, 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 TenantServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> TenantServiceTransport: + """Returns the transport used by the client instance. + + Returns: + TenantServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(TenantServiceClient).get_transport_class, type(TenantServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, TenantServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the tenant 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, ~.TenantServiceTransport]): 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 = TenantServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_tenant(self, + request: Union[tenant_service.CreateTenantRequest, dict] = None, + *, + parent: str = None, + tenant: gct_tenant.Tenant = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_tenant.Tenant: + r"""Creates a new tenant entity. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_create_tenant(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + tenant = talent_v4.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4.CreateTenantRequest( + parent="parent_value", + tenant=tenant, + ) + + # Make the request + response = await client.create_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CreateTenantRequest, dict]): + The request object. The Request of the CreateTenant + method. + parent (:class:`str`): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tenant (:class:`google.cloud.talent_v4.types.Tenant`): + Required. The tenant to be created. + This corresponds to the ``tenant`` 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_v4.types.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + jobs. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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, tenant]) + 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 = tenant_service.CreateTenantRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if tenant is not None: + request.tenant = tenant + + # 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_tenant, + 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_tenant(self, + request: Union[tenant_service.GetTenantRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tenant.Tenant: + r"""Retrieves specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_get_tenant(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.GetTenantRequest( + name="name_value", + ) + + # Make the request + response = await client.get_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.GetTenantRequest, dict]): + The request object. Request for getting a tenant by + name. + name (:class:`str`): + Required. The resource name of the tenant to be + retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenants/bar". + + 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_v4.types.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + jobs. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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 = tenant_service.GetTenantRequest(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_tenant, + 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_tenant(self, + request: Union[tenant_service.UpdateTenantRequest, dict] = None, + *, + tenant: gct_tenant.Tenant = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_tenant.Tenant: + r"""Updates specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_update_tenant(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + tenant = talent_v4.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4.UpdateTenantRequest( + tenant=tenant, + ) + + # Make the request + response = await client.update_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.UpdateTenantRequest, dict]): + The request object. Request for updating a specified + tenant. + tenant (:class:`google.cloud.talent_v4.types.Tenant`): + Required. The tenant resource to + replace the current resource in the + system. + + This corresponds to the ``tenant`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Strongly recommended for the best service experience. + + If + [update_mask][google.cloud.talent.v4.UpdateTenantRequest.update_mask] + is provided, only the specified fields in + [tenant][google.cloud.talent.v4.UpdateTenantRequest.tenant] + are updated. Otherwise all the fields are updated. + + A field mask to specify the tenant fields to be updated. + Only top level fields of + [Tenant][google.cloud.talent.v4.Tenant] are supported. + + This corresponds to the ``update_mask`` 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_v4.types.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + jobs. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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([tenant, update_mask]) + 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 = tenant_service.UpdateTenantRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if tenant is not None: + request.tenant = tenant + if update_mask is not None: + request.update_mask = update_mask + + # 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_tenant, + 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(( + ("tenant.name", request.tenant.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_tenant(self, + request: Union[tenant_service.DeleteTenantRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_delete_tenant(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.DeleteTenantRequest( + name="name_value", + ) + + # Make the request + await client.delete_tenant(request=request) + + Args: + request (Union[google.cloud.talent_v4.types.DeleteTenantRequest, dict]): + The request object. Request to delete a tenant. + name (:class:`str`): + Required. The resource name of the tenant to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenants/bar". + + 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 = tenant_service.DeleteTenantRequest(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_tenant, + 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_tenants(self, + request: Union[tenant_service.ListTenantsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTenantsAsyncPager: + r"""Lists all tenants associated with the project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + async def sample_list_tenants(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.ListTenantsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tenants(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.ListTenantsRequest, dict]): + The request object. List tenants for which the client + has ACL visibility. + parent (:class:`str`): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + + 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_v4.services.tenant_service.pagers.ListTenantsAsyncPager: + The List tenants 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 = tenant_service.ListTenantsRequest(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_tenants, + 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.ListTenantsAsyncPager( + 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__ = ( + "TenantServiceAsyncClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/client.py new file mode 100644 index 00000000..da9b745f --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/client.py @@ -0,0 +1,976 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4.services.tenant_service import pagers +from google.cloud.talent_v4.types import tenant +from google.cloud.talent_v4.types import tenant as gct_tenant +from google.cloud.talent_v4.types import tenant_service +from google.protobuf import field_mask_pb2 # type: ignore +from .transports.base import TenantServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import TenantServiceGrpcTransport +from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport + + +class TenantServiceClientMeta(type): + """Metaclass for the TenantService 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[TenantServiceTransport]] + _transport_registry["grpc"] = TenantServiceGrpcTransport + _transport_registry["grpc_asyncio"] = TenantServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[TenantServiceTransport]: + """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 TenantServiceClient(metaclass=TenantServiceClientMeta): + """A service that handles tenant 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: + TenantServiceClient: 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: + TenantServiceClient: 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) -> TenantServiceTransport: + """Returns the transport used by the client instance. + + Returns: + TenantServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @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, TenantServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the tenant 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, TenantServiceTransport]): 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, TenantServiceTransport): + # transport is a TenantServiceTransport 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, + api_audience=client_options.api_audience, + ) + + def create_tenant(self, + request: Union[tenant_service.CreateTenantRequest, dict] = None, + *, + parent: str = None, + tenant: gct_tenant.Tenant = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_tenant.Tenant: + r"""Creates a new tenant entity. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_create_tenant(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + tenant = talent_v4.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4.CreateTenantRequest( + parent="parent_value", + tenant=tenant, + ) + + # Make the request + response = client.create_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.CreateTenantRequest, dict]): + The request object. The Request of the CreateTenant + method. + parent (str): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tenant (google.cloud.talent_v4.types.Tenant): + Required. The tenant to be created. + This corresponds to the ``tenant`` 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_v4.types.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + jobs. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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, tenant]) + 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 tenant_service.CreateTenantRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.CreateTenantRequest): + request = tenant_service.CreateTenantRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if tenant is not None: + request.tenant = tenant + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_tenant] + + # 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_tenant(self, + request: Union[tenant_service.GetTenantRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tenant.Tenant: + r"""Retrieves specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_get_tenant(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4.GetTenantRequest( + name="name_value", + ) + + # Make the request + response = client.get_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.GetTenantRequest, dict]): + The request object. Request for getting a tenant by + name. + name (str): + Required. The resource name of the tenant to be + retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenants/bar". + + 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_v4.types.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + jobs. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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 tenant_service.GetTenantRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.GetTenantRequest): + request = tenant_service.GetTenantRequest(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_tenant] + + # 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_tenant(self, + request: Union[tenant_service.UpdateTenantRequest, dict] = None, + *, + tenant: gct_tenant.Tenant = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_tenant.Tenant: + r"""Updates specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_update_tenant(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + tenant = talent_v4.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4.UpdateTenantRequest( + tenant=tenant, + ) + + # Make the request + response = client.update_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.UpdateTenantRequest, dict]): + The request object. Request for updating a specified + tenant. + tenant (google.cloud.talent_v4.types.Tenant): + Required. The tenant resource to + replace the current resource in the + system. + + This corresponds to the ``tenant`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Strongly recommended for the best service experience. + + If + [update_mask][google.cloud.talent.v4.UpdateTenantRequest.update_mask] + is provided, only the specified fields in + [tenant][google.cloud.talent.v4.UpdateTenantRequest.tenant] + are updated. Otherwise all the fields are updated. + + A field mask to specify the tenant fields to be updated. + Only top level fields of + [Tenant][google.cloud.talent.v4.Tenant] are supported. + + This corresponds to the ``update_mask`` 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_v4.types.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + jobs. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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([tenant, update_mask]) + 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 tenant_service.UpdateTenantRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.UpdateTenantRequest): + request = tenant_service.UpdateTenantRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if tenant is not None: + request.tenant = tenant + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_tenant] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("tenant.name", request.tenant.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_tenant(self, + request: Union[tenant_service.DeleteTenantRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_delete_tenant(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4.DeleteTenantRequest( + name="name_value", + ) + + # Make the request + client.delete_tenant(request=request) + + Args: + request (Union[google.cloud.talent_v4.types.DeleteTenantRequest, dict]): + The request object. Request to delete a tenant. + name (str): + Required. The resource name of the tenant to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenants/bar". + + 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 tenant_service.DeleteTenantRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.DeleteTenantRequest): + request = tenant_service.DeleteTenantRequest(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_tenant] + + # 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_tenants(self, + request: Union[tenant_service.ListTenantsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTenantsPager: + r"""Lists all tenants associated with the project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4 + + def sample_list_tenants(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4.ListTenantsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tenants(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4.types.ListTenantsRequest, dict]): + The request object. List tenants for which the client + has ACL visibility. + parent (str): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + + 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_v4.services.tenant_service.pagers.ListTenantsPager: + The List tenants 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 tenant_service.ListTenantsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.ListTenantsRequest): + request = tenant_service.ListTenantsRequest(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_tenants] + + # 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.ListTenantsPager( + 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__ = ( + "TenantServiceClient", +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/pagers.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/pagers.py new file mode 100644 index 00000000..f8a44bfc --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/pagers.py @@ -0,0 +1,140 @@ +# -*- 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, Sequence, Tuple, Optional, Iterator + +from google.cloud.talent_v4.types import tenant +from google.cloud.talent_v4.types import tenant_service + + +class ListTenantsPager: + """A pager for iterating through ``list_tenants`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4.types.ListTenantsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``tenants`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListTenants`` requests and continue to iterate + through the ``tenants`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4.types.ListTenantsResponse` + 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[..., tenant_service.ListTenantsResponse], + request: tenant_service.ListTenantsRequest, + response: tenant_service.ListTenantsResponse, + *, + 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_v4.types.ListTenantsRequest): + The initial request object. + response (google.cloud.talent_v4.types.ListTenantsResponse): + 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 = tenant_service.ListTenantsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[tenant_service.ListTenantsResponse]: + 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[tenant.Tenant]: + for page in self.pages: + yield from page.tenants + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListTenantsAsyncPager: + """A pager for iterating through ``list_tenants`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4.types.ListTenantsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``tenants`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListTenants`` requests and continue to iterate + through the ``tenants`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4.types.ListTenantsResponse` + 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[tenant_service.ListTenantsResponse]], + request: tenant_service.ListTenantsRequest, + response: tenant_service.ListTenantsResponse, + *, + 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_v4.types.ListTenantsRequest): + The initial request object. + response (google.cloud.talent_v4.types.ListTenantsResponse): + 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 = tenant_service.ListTenantsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[tenant_service.ListTenantsResponse]: + 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[tenant.Tenant]: + async def async_generator(): + async for page in self.pages: + for response in page.tenants: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/__init__.py new file mode 100644 index 00000000..59edc02c --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 TenantServiceTransport +from .grpc import TenantServiceGrpcTransport +from .grpc_asyncio import TenantServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[TenantServiceTransport]] +_transport_registry['grpc'] = TenantServiceGrpcTransport +_transport_registry['grpc_asyncio'] = TenantServiceGrpcAsyncIOTransport + +__all__ = ( + 'TenantServiceTransport', + 'TenantServiceGrpcTransport', + 'TenantServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/base.py new file mode 100644 index 00000000..3e72116d --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/base.py @@ -0,0 +1,235 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4.types import tenant +from google.cloud.talent_v4.types import tenant as gct_tenant +from google.cloud.talent_v4.types import tenant_service +from google.protobuf import empty_pb2 # type: ignore + +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 TenantServiceTransport(abc.ABC): + """Abstract transport class for TenantService.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.create_tenant: gapic_v1.method.wrap_method( + self.create_tenant, + default_timeout=30.0, + client_info=client_info, + ), + self.get_tenant: gapic_v1.method.wrap_method( + self.get_tenant, + 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_tenant: gapic_v1.method.wrap_method( + self.update_tenant, + default_timeout=30.0, + client_info=client_info, + ), + self.delete_tenant: gapic_v1.method.wrap_method( + self.delete_tenant, + 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_tenants: gapic_v1.method.wrap_method( + self.list_tenants, + 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_tenant(self) -> Callable[ + [tenant_service.CreateTenantRequest], + Union[ + gct_tenant.Tenant, + Awaitable[gct_tenant.Tenant] + ]]: + raise NotImplementedError() + + @property + def get_tenant(self) -> Callable[ + [tenant_service.GetTenantRequest], + Union[ + tenant.Tenant, + Awaitable[tenant.Tenant] + ]]: + raise NotImplementedError() + + @property + def update_tenant(self) -> Callable[ + [tenant_service.UpdateTenantRequest], + Union[ + gct_tenant.Tenant, + Awaitable[gct_tenant.Tenant] + ]]: + raise NotImplementedError() + + @property + def delete_tenant(self) -> Callable[ + [tenant_service.DeleteTenantRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def list_tenants(self) -> Callable[ + [tenant_service.ListTenantsRequest], + Union[ + tenant_service.ListTenantsResponse, + Awaitable[tenant_service.ListTenantsResponse] + ]]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ( + 'TenantServiceTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc.py new file mode 100644 index 00000000..616b21b3 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc.py @@ -0,0 +1,372 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4.types import tenant +from google.cloud.talent_v4.types import tenant as gct_tenant +from google.cloud.talent_v4.types import tenant_service +from google.protobuf import empty_pb2 # type: ignore +from .base import TenantServiceTransport, DEFAULT_CLIENT_INFO + + +class TenantServiceGrpcTransport(TenantServiceTransport): + """gRPC backend transport for TenantService. + + A service that handles tenant 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_tenant(self) -> Callable[ + [tenant_service.CreateTenantRequest], + gct_tenant.Tenant]: + r"""Return a callable for the create tenant method over gRPC. + + Creates a new tenant entity. + + Returns: + Callable[[~.CreateTenantRequest], + ~.Tenant]: + 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_tenant' not in self._stubs: + self._stubs['create_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/CreateTenant', + request_serializer=tenant_service.CreateTenantRequest.serialize, + response_deserializer=gct_tenant.Tenant.deserialize, + ) + return self._stubs['create_tenant'] + + @property + def get_tenant(self) -> Callable[ + [tenant_service.GetTenantRequest], + tenant.Tenant]: + r"""Return a callable for the get tenant method over gRPC. + + Retrieves specified tenant. + + Returns: + Callable[[~.GetTenantRequest], + ~.Tenant]: + 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_tenant' not in self._stubs: + self._stubs['get_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/GetTenant', + request_serializer=tenant_service.GetTenantRequest.serialize, + response_deserializer=tenant.Tenant.deserialize, + ) + return self._stubs['get_tenant'] + + @property + def update_tenant(self) -> Callable[ + [tenant_service.UpdateTenantRequest], + gct_tenant.Tenant]: + r"""Return a callable for the update tenant method over gRPC. + + Updates specified tenant. + + Returns: + Callable[[~.UpdateTenantRequest], + ~.Tenant]: + 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_tenant' not in self._stubs: + self._stubs['update_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/UpdateTenant', + request_serializer=tenant_service.UpdateTenantRequest.serialize, + response_deserializer=gct_tenant.Tenant.deserialize, + ) + return self._stubs['update_tenant'] + + @property + def delete_tenant(self) -> Callable[ + [tenant_service.DeleteTenantRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete tenant method over gRPC. + + Deletes specified tenant. + + Returns: + Callable[[~.DeleteTenantRequest], + ~.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_tenant' not in self._stubs: + self._stubs['delete_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/DeleteTenant', + request_serializer=tenant_service.DeleteTenantRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_tenant'] + + @property + def list_tenants(self) -> Callable[ + [tenant_service.ListTenantsRequest], + tenant_service.ListTenantsResponse]: + r"""Return a callable for the list tenants method over gRPC. + + Lists all tenants associated with the project. + + Returns: + Callable[[~.ListTenantsRequest], + ~.ListTenantsResponse]: + 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_tenants' not in self._stubs: + self._stubs['list_tenants'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/ListTenants', + request_serializer=tenant_service.ListTenantsRequest.serialize, + response_deserializer=tenant_service.ListTenantsResponse.deserialize, + ) + return self._stubs['list_tenants'] + + def close(self): + self.grpc_channel.close() + + @property + def kind(self) -> str: + return "grpc" + + +__all__ = ( + 'TenantServiceGrpcTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py new file mode 100644 index 00000000..cc59c86d --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py @@ -0,0 +1,371 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4.types import tenant +from google.cloud.talent_v4.types import tenant as gct_tenant +from google.cloud.talent_v4.types import tenant_service +from google.protobuf import empty_pb2 # type: ignore +from .base import TenantServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import TenantServiceGrpcTransport + + +class TenantServiceGrpcAsyncIOTransport(TenantServiceTransport): + """gRPC AsyncIO backend transport for TenantService. + + A service that handles tenant 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_tenant(self) -> Callable[ + [tenant_service.CreateTenantRequest], + Awaitable[gct_tenant.Tenant]]: + r"""Return a callable for the create tenant method over gRPC. + + Creates a new tenant entity. + + Returns: + Callable[[~.CreateTenantRequest], + Awaitable[~.Tenant]]: + 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_tenant' not in self._stubs: + self._stubs['create_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/CreateTenant', + request_serializer=tenant_service.CreateTenantRequest.serialize, + response_deserializer=gct_tenant.Tenant.deserialize, + ) + return self._stubs['create_tenant'] + + @property + def get_tenant(self) -> Callable[ + [tenant_service.GetTenantRequest], + Awaitable[tenant.Tenant]]: + r"""Return a callable for the get tenant method over gRPC. + + Retrieves specified tenant. + + Returns: + Callable[[~.GetTenantRequest], + Awaitable[~.Tenant]]: + 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_tenant' not in self._stubs: + self._stubs['get_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/GetTenant', + request_serializer=tenant_service.GetTenantRequest.serialize, + response_deserializer=tenant.Tenant.deserialize, + ) + return self._stubs['get_tenant'] + + @property + def update_tenant(self) -> Callable[ + [tenant_service.UpdateTenantRequest], + Awaitable[gct_tenant.Tenant]]: + r"""Return a callable for the update tenant method over gRPC. + + Updates specified tenant. + + Returns: + Callable[[~.UpdateTenantRequest], + Awaitable[~.Tenant]]: + 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_tenant' not in self._stubs: + self._stubs['update_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/UpdateTenant', + request_serializer=tenant_service.UpdateTenantRequest.serialize, + response_deserializer=gct_tenant.Tenant.deserialize, + ) + return self._stubs['update_tenant'] + + @property + def delete_tenant(self) -> Callable[ + [tenant_service.DeleteTenantRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete tenant method over gRPC. + + Deletes specified tenant. + + Returns: + Callable[[~.DeleteTenantRequest], + 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_tenant' not in self._stubs: + self._stubs['delete_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/DeleteTenant', + request_serializer=tenant_service.DeleteTenantRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_tenant'] + + @property + def list_tenants(self) -> Callable[ + [tenant_service.ListTenantsRequest], + Awaitable[tenant_service.ListTenantsResponse]]: + r"""Return a callable for the list tenants method over gRPC. + + Lists all tenants associated with the project. + + Returns: + Callable[[~.ListTenantsRequest], + Awaitable[~.ListTenantsResponse]]: + 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_tenants' not in self._stubs: + self._stubs['list_tenants'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4.TenantService/ListTenants', + request_serializer=tenant_service.ListTenantsRequest.serialize, + response_deserializer=tenant_service.ListTenantsResponse.deserialize, + ) + return self._stubs['list_tenants'] + + def close(self): + return self.grpc_channel.close() + + +__all__ = ( + 'TenantServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/__init__.py new file mode 100644 index 00000000..e655d337 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/__init__.py @@ -0,0 +1,164 @@ +# -*- 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 .common import ( + BatchOperationMetadata, + CompensationInfo, + CustomAttribute, + DeviceInfo, + Location, + RequestMetadata, + ResponseMetadata, + SpellingCorrection, + TimestampRange, + CommuteMethod, + CompanySize, + DegreeType, + EmploymentType, + HtmlSanitization, + JobBenefit, + JobCategory, + JobLevel, + PostingRegion, + Visibility, +) +from .company import ( + Company, +) +from .company_service import ( + CreateCompanyRequest, + DeleteCompanyRequest, + GetCompanyRequest, + ListCompaniesRequest, + ListCompaniesResponse, + UpdateCompanyRequest, +) +from .completion_service import ( + CompleteQueryRequest, + CompleteQueryResponse, +) +from .event import ( + ClientEvent, + JobEvent, +) +from .event_service import ( + CreateClientEventRequest, +) +from .filters import ( + CommuteFilter, + CompensationFilter, + JobQuery, + LocationFilter, +) +from .histogram import ( + HistogramQuery, + HistogramQueryResult, +) +from .job import ( + Job, +) +from .job_service import ( + BatchCreateJobsRequest, + BatchCreateJobsResponse, + BatchDeleteJobsRequest, + BatchDeleteJobsResponse, + BatchUpdateJobsRequest, + BatchUpdateJobsResponse, + CreateJobRequest, + DeleteJobRequest, + GetJobRequest, + JobResult, + ListJobsRequest, + ListJobsResponse, + SearchJobsRequest, + SearchJobsResponse, + UpdateJobRequest, + JobView, +) +from .tenant import ( + Tenant, +) +from .tenant_service import ( + CreateTenantRequest, + DeleteTenantRequest, + GetTenantRequest, + ListTenantsRequest, + ListTenantsResponse, + UpdateTenantRequest, +) + +__all__ = ( + 'BatchOperationMetadata', + 'CompensationInfo', + 'CustomAttribute', + 'DeviceInfo', + 'Location', + 'RequestMetadata', + 'ResponseMetadata', + 'SpellingCorrection', + 'TimestampRange', + 'CommuteMethod', + 'CompanySize', + 'DegreeType', + 'EmploymentType', + 'HtmlSanitization', + 'JobBenefit', + 'JobCategory', + 'JobLevel', + 'PostingRegion', + 'Visibility', + 'Company', + 'CreateCompanyRequest', + 'DeleteCompanyRequest', + 'GetCompanyRequest', + 'ListCompaniesRequest', + 'ListCompaniesResponse', + 'UpdateCompanyRequest', + 'CompleteQueryRequest', + 'CompleteQueryResponse', + 'ClientEvent', + 'JobEvent', + 'CreateClientEventRequest', + 'CommuteFilter', + 'CompensationFilter', + 'JobQuery', + 'LocationFilter', + 'HistogramQuery', + 'HistogramQueryResult', + 'Job', + 'BatchCreateJobsRequest', + 'BatchCreateJobsResponse', + 'BatchDeleteJobsRequest', + 'BatchDeleteJobsResponse', + 'BatchUpdateJobsRequest', + 'BatchUpdateJobsResponse', + 'CreateJobRequest', + 'DeleteJobRequest', + 'GetJobRequest', + 'JobResult', + 'ListJobsRequest', + 'ListJobsResponse', + 'SearchJobsRequest', + 'SearchJobsResponse', + 'UpdateJobRequest', + 'JobView', + 'Tenant', + 'CreateTenantRequest', + 'DeleteTenantRequest', + 'GetTenantRequest', + 'ListTenantsRequest', + 'ListTenantsResponse', + 'UpdateTenantRequest', +) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/common.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/common.py new file mode 100644 index 00000000..d91639c9 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/common.py @@ -0,0 +1,849 @@ +# -*- 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 proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_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 + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'CompanySize', + 'JobBenefit', + 'DegreeType', + 'EmploymentType', + 'JobLevel', + 'JobCategory', + 'PostingRegion', + 'Visibility', + 'HtmlSanitization', + 'CommuteMethod', + 'TimestampRange', + 'Location', + 'RequestMetadata', + 'ResponseMetadata', + 'DeviceInfo', + 'CustomAttribute', + 'SpellingCorrection', + 'CompensationInfo', + 'BatchOperationMetadata', + }, +) + + +class CompanySize(proto.Enum): + r"""An enum that represents the size of the company.""" + COMPANY_SIZE_UNSPECIFIED = 0 + MINI = 1 + SMALL = 2 + SMEDIUM = 3 + MEDIUM = 4 + BIG = 5 + BIGGER = 6 + GIANT = 7 + + +class JobBenefit(proto.Enum): + r"""An enum that represents employee benefits included with the + job. + """ + JOB_BENEFIT_UNSPECIFIED = 0 + CHILD_CARE = 1 + DENTAL = 2 + DOMESTIC_PARTNER = 3 + FLEXIBLE_HOURS = 4 + MEDICAL = 5 + LIFE_INSURANCE = 6 + PARENTAL_LEAVE = 7 + RETIREMENT_PLAN = 8 + SICK_DAYS = 9 + VACATION = 10 + VISION = 11 + + +class DegreeType(proto.Enum): + r"""Educational degree level defined in International Standard + Classification of Education (ISCED). + """ + DEGREE_TYPE_UNSPECIFIED = 0 + PRIMARY_EDUCATION = 1 + LOWER_SECONDARY_EDUCATION = 2 + UPPER_SECONDARY_EDUCATION = 3 + ADULT_REMEDIAL_EDUCATION = 4 + ASSOCIATES_OR_EQUIVALENT = 5 + BACHELORS_OR_EQUIVALENT = 6 + MASTERS_OR_EQUIVALENT = 7 + DOCTORAL_OR_EQUIVALENT = 8 + + +class EmploymentType(proto.Enum): + r"""An enum that represents the employment type of a job.""" + EMPLOYMENT_TYPE_UNSPECIFIED = 0 + FULL_TIME = 1 + PART_TIME = 2 + CONTRACTOR = 3 + CONTRACT_TO_HIRE = 4 + TEMPORARY = 5 + INTERN = 6 + VOLUNTEER = 7 + PER_DIEM = 8 + FLY_IN_FLY_OUT = 9 + OTHER_EMPLOYMENT_TYPE = 10 + + +class JobLevel(proto.Enum): + r"""An enum that represents the required experience level + required for the job. + """ + JOB_LEVEL_UNSPECIFIED = 0 + ENTRY_LEVEL = 1 + EXPERIENCED = 2 + MANAGER = 3 + DIRECTOR = 4 + EXECUTIVE = 5 + + +class JobCategory(proto.Enum): + r"""An enum that represents the categorization or primary focus + of specific role. This value is different than the "industry" + associated with a role, which is related to the categorization + of the company listing the job. + """ + JOB_CATEGORY_UNSPECIFIED = 0 + ACCOUNTING_AND_FINANCE = 1 + ADMINISTRATIVE_AND_OFFICE = 2 + ADVERTISING_AND_MARKETING = 3 + ANIMAL_CARE = 4 + ART_FASHION_AND_DESIGN = 5 + BUSINESS_OPERATIONS = 6 + CLEANING_AND_FACILITIES = 7 + COMPUTER_AND_IT = 8 + CONSTRUCTION = 9 + CUSTOMER_SERVICE = 10 + EDUCATION = 11 + ENTERTAINMENT_AND_TRAVEL = 12 + FARMING_AND_OUTDOORS = 13 + HEALTHCARE = 14 + HUMAN_RESOURCES = 15 + INSTALLATION_MAINTENANCE_AND_REPAIR = 16 + LEGAL = 17 + MANAGEMENT = 18 + MANUFACTURING_AND_WAREHOUSE = 19 + MEDIA_COMMUNICATIONS_AND_WRITING = 20 + OIL_GAS_AND_MINING = 21 + PERSONAL_CARE_AND_SERVICES = 22 + PROTECTIVE_SERVICES = 23 + REAL_ESTATE = 24 + RESTAURANT_AND_HOSPITALITY = 25 + SALES_AND_RETAIL = 26 + SCIENCE_AND_ENGINEERING = 27 + SOCIAL_SERVICES_AND_NON_PROFIT = 28 + SPORTS_FITNESS_AND_RECREATION = 29 + TRANSPORTATION_AND_LOGISTICS = 30 + + +class PostingRegion(proto.Enum): + r"""An enum that represents the job posting region. In most + cases, job postings don't need to specify a region. If a region + is given, jobs are eligible for searches in the specified + region. + """ + POSTING_REGION_UNSPECIFIED = 0 + ADMINISTRATIVE_AREA = 1 + NATION = 2 + TELECOMMUTE = 3 + + +class Visibility(proto.Enum): + r"""Deprecated. All resources are only visible to the owner. + An enum that represents who has view access to the resource. + """ + _pb_options = {'deprecated': True} + VISIBILITY_UNSPECIFIED = 0 + ACCOUNT_ONLY = 1 + SHARED_WITH_GOOGLE = 2 + SHARED_WITH_PUBLIC = 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 + determine whether and how sanitization is performed on these + fields. + """ + HTML_SANITIZATION_UNSPECIFIED = 0 + HTML_SANITIZATION_DISABLED = 1 + SIMPLE_FORMATTING_ONLY = 2 + + +class CommuteMethod(proto.Enum): + r"""Method for commute. Walking, biking and wheelchair accessible + transit is still in the Preview stage. + """ + COMMUTE_METHOD_UNSPECIFIED = 0 + DRIVING = 1 + TRANSIT = 2 + WALKING = 3 + CYCLING = 4 + TRANSIT_ACCESSIBLE = 5 + + +class TimestampRange(proto.Message): + r"""Message representing a period of time between two timestamps. + + Attributes: + start_time (google.protobuf.timestamp_pb2.Timestamp): + Begin of the period (inclusive). + end_time (google.protobuf.timestamp_pb2.Timestamp): + End of the period (exclusive). + """ + + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + + +class Location(proto.Message): + r"""A resource that represents a location with full geographic + information. + + Attributes: + location_type (google.cloud.talent_v4.types.Location.LocationType): + The type of a location, which corresponds to the address + lines field of + [google.type.PostalAddress][google.type.PostalAddress]. For + example, "Downtown, Atlanta, GA, USA" has a type of + [LocationType.NEIGHBORHOOD][google.cloud.talent.v4.Location.LocationType.NEIGHBORHOOD], + and "Kansas City, KS, USA" has a type of + [LocationType.LOCALITY][google.cloud.talent.v4.Location.LocationType.LOCALITY]. + postal_address (google.type.postal_address_pb2.PostalAddress): + Postal address of the location that includes + human readable information, such as postal + delivery and payments addresses. Given a postal + address, a postal service can deliver items to a + premises, P.O. Box, or other delivery location. + lat_lng (google.type.latlng_pb2.LatLng): + An object representing a latitude/longitude + pair. + radius_miles (float): + Radius in miles of the job location. This value is derived + from the location bounding box in which a circle with the + specified radius centered from + [google.type.LatLng][google.type.LatLng] covers the area + associated with the job location. For example, currently, + "Mountain View, CA, USA" has a radius of 6.17 miles. + """ + class LocationType(proto.Enum): + r"""An enum which represents the type of a location.""" + LOCATION_TYPE_UNSPECIFIED = 0 + COUNTRY = 1 + ADMINISTRATIVE_AREA = 2 + SUB_ADMINISTRATIVE_AREA = 3 + LOCALITY = 4 + POSTAL_CODE = 5 + SUB_LOCALITY = 6 + SUB_LOCALITY_1 = 7 + SUB_LOCALITY_2 = 8 + NEIGHBORHOOD = 9 + STREET_ADDRESS = 10 + + location_type = proto.Field( + proto.ENUM, + number=1, + enum=LocationType, + ) + postal_address = proto.Field( + proto.MESSAGE, + number=2, + message=postal_address_pb2.PostalAddress, + ) + lat_lng = proto.Field( + proto.MESSAGE, + number=3, + message=latlng_pb2.LatLng, + ) + radius_miles = proto.Field( + proto.DOUBLE, + number=4, + ) + + +class RequestMetadata(proto.Message): + r"""Meta information related to the job searcher or entity + conducting the job search. This information is used to improve + the performance of the service. + + Attributes: + domain (str): + Required if + [allow_missing_ids][google.cloud.talent.v4.RequestMetadata.allow_missing_ids] + is unset or ``false``. + + The client-defined scope or source of the service call, + which typically is the domain on which the service has been + implemented and is currently being run. + + For example, if the service is being run by client Foo, + Inc., on job board www.foo.com and career site www.bar.com, + then this field is set to "foo.com" for use on the job + board, and "bar.com" for use on the career site. + + Note that any improvements to the model for a particular + tenant site rely on this field being set correctly to a + unique domain. + + The maximum number of allowed characters is 255. + session_id (str): + Required if + [allow_missing_ids][google.cloud.talent.v4.RequestMetadata.allow_missing_ids] + is unset or ``false``. + + A unique session identification string. A session is defined + as the duration of an end user's interaction with the + service over a certain period. Obfuscate this field for + privacy concerns before providing it to the service. + + Note that any improvements to the model for a particular + tenant site rely on this field being set correctly to a + unique session ID. + + The maximum number of allowed characters is 255. + user_id (str): + Required if + [allow_missing_ids][google.cloud.talent.v4.RequestMetadata.allow_missing_ids] + is unset or ``false``. + + A unique user identification string, as determined by the + client. To have the strongest positive impact on search + quality make sure the client-level is unique. Obfuscate this + field for privacy concerns before providing it to the + service. + + Note that any improvements to the model for a particular + tenant site rely on this field being set correctly to a + unique user ID. + + The maximum number of allowed characters is 255. + allow_missing_ids (bool): + Only set when any of + [domain][google.cloud.talent.v4.RequestMetadata.domain], + [session_id][google.cloud.talent.v4.RequestMetadata.session_id] + and + [user_id][google.cloud.talent.v4.RequestMetadata.user_id] + isn't available for some reason. It is highly recommended + not to set this field and provide accurate + [domain][google.cloud.talent.v4.RequestMetadata.domain], + [session_id][google.cloud.talent.v4.RequestMetadata.session_id] + and + [user_id][google.cloud.talent.v4.RequestMetadata.user_id] + for the best service experience. + device_info (google.cloud.talent_v4.types.DeviceInfo): + The type of device used by the job seeker at + the time of the call to the service. + """ + + domain = proto.Field( + proto.STRING, + number=1, + ) + session_id = proto.Field( + proto.STRING, + number=2, + ) + user_id = proto.Field( + proto.STRING, + number=3, + ) + allow_missing_ids = proto.Field( + proto.BOOL, + number=4, + ) + device_info = proto.Field( + proto.MESSAGE, + number=5, + message='DeviceInfo', + ) + + +class ResponseMetadata(proto.Message): + r"""Additional information returned to client, such as debugging + information. + + Attributes: + request_id (str): + A unique id associated with this call. + This id is logged for tracking purposes. + """ + + request_id = proto.Field( + proto.STRING, + number=1, + ) + + +class DeviceInfo(proto.Message): + r"""Device information collected from the job seeker, candidate, + or other entity conducting the job search. Providing this + information improves the quality of the search results across + devices. + + Attributes: + device_type (google.cloud.talent_v4.types.DeviceInfo.DeviceType): + Type of the device. + id (str): + A device-specific ID. The ID must be a unique + identifier that distinguishes the device from + other devices. + """ + class DeviceType(proto.Enum): + r"""An enumeration describing an API access portal and exposure + mechanism. + """ + DEVICE_TYPE_UNSPECIFIED = 0 + WEB = 1 + MOBILE_WEB = 2 + ANDROID = 3 + IOS = 4 + BOT = 5 + OTHER = 6 + + device_type = proto.Field( + proto.ENUM, + number=1, + enum=DeviceType, + ) + id = proto.Field( + proto.STRING, + number=2, + ) + + +class CustomAttribute(proto.Message): + r"""Custom attribute values that are either filterable or + non-filterable. + + Attributes: + string_values (Sequence[str]): + Exactly one of + [string_values][google.cloud.talent.v4.CustomAttribute.string_values] + or + [long_values][google.cloud.talent.v4.CustomAttribute.long_values] + must be specified. + + This field is used to perform a string match + (``CASE_SENSITIVE_MATCH`` or ``CASE_INSENSITIVE_MATCH``) + search. For filterable ``string_value``\ s, a maximum total + number of 200 values is allowed, with each ``string_value`` + has a byte size of no more than 500B. For unfilterable + ``string_values``, the maximum total byte size of + unfilterable ``string_values`` is 50KB. + + Empty string isn't allowed. + long_values (Sequence[int]): + Exactly one of + [string_values][google.cloud.talent.v4.CustomAttribute.string_values] + or + [long_values][google.cloud.talent.v4.CustomAttribute.long_values] + must be specified. + + This field is used to perform number range search. (``EQ``, + ``GT``, ``GE``, ``LE``, ``LT``) over filterable + ``long_value``. + + Currently at most 1 + [long_values][google.cloud.talent.v4.CustomAttribute.long_values] + is supported. + filterable (bool): + If the ``filterable`` flag is true, the custom field values + may be used for custom attribute filters + [JobQuery.custom_attribute_filter][google.cloud.talent.v4.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. + """ + + string_values = proto.RepeatedField( + proto.STRING, + number=1, + ) + long_values = proto.RepeatedField( + proto.INT64, + number=2, + ) + filterable = proto.Field( + proto.BOOL, + number=3, + ) + keyword_searchable = proto.Field( + proto.BOOL, + number=4, + ) + + +class SpellingCorrection(proto.Message): + r"""Spell check result. + + Attributes: + corrected (bool): + Indicates if the query was corrected by the + spell checker. + corrected_text (str): + Correction output consisting of the corrected + keyword string. + corrected_html (str): + Corrected output with html tags to highlight + the corrected words. Corrected words are called + out with the "..." html tags. + For example, the user input query is "software + enginear", where the second word, "enginear," is + incorrect. It should be "engineer". When + spelling correction is enabled, this value is + "software engineer". + """ + + corrected = proto.Field( + proto.BOOL, + number=1, + ) + corrected_text = proto.Field( + proto.STRING, + number=2, + ) + corrected_html = proto.Field( + proto.STRING, + number=3, + ) + + +class CompensationInfo(proto.Message): + r"""Job compensation details. + + Attributes: + entries (Sequence[google.cloud.talent_v4.types.CompensationInfo.CompensationEntry]): + Job compensation information. + + At most one entry can be of type + [CompensationInfo.CompensationType.BASE][google.cloud.talent.v4.CompensationInfo.CompensationType.BASE], + which is referred as **base compensation entry** for the + job. + annualized_base_compensation_range (google.cloud.talent_v4.types.CompensationInfo.CompensationRange): + Output only. Annualized base compensation range. Computed as + base compensation entry's + [CompensationEntry.amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] + times + [CompensationEntry.expected_units_per_year][google.cloud.talent.v4.CompensationInfo.CompensationEntry.expected_units_per_year]. + + See + [CompensationEntry][google.cloud.talent.v4.CompensationInfo.CompensationEntry] + for explanation on compensation annualization. + annualized_total_compensation_range (google.cloud.talent_v4.types.CompensationInfo.CompensationRange): + Output only. Annualized total compensation range. Computed + as all compensation entries' + [CompensationEntry.amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] + times + [CompensationEntry.expected_units_per_year][google.cloud.talent.v4.CompensationInfo.CompensationEntry.expected_units_per_year]. + + See + [CompensationEntry][google.cloud.talent.v4.CompensationInfo.CompensationEntry] + for explanation on compensation annualization. + """ + class CompensationType(proto.Enum): + r"""The type of compensation. + + For compensation amounts specified in non-monetary amounts, describe + the compensation scheme in the + [CompensationEntry.description][google.cloud.talent.v4.CompensationInfo.CompensationEntry.description]. + + For example, tipping format is described in + [CompensationEntry.description][google.cloud.talent.v4.CompensationInfo.CompensationEntry.description] + (for example, "expect 15-20% tips based on customer bill.") and an + estimate of the tips provided in + [CompensationEntry.amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] + or + [CompensationEntry.range][google.cloud.talent.v4.CompensationInfo.CompensationEntry.range] + ($10 per hour). + + For example, equity is described in + [CompensationEntry.description][google.cloud.talent.v4.CompensationInfo.CompensationEntry.description] + (for example, "1% - 2% equity vesting over 4 years, 1 year cliff") + and value estimated in + [CompensationEntry.amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] + or + [CompensationEntry.range][google.cloud.talent.v4.CompensationInfo.CompensationEntry.range]. + If no value estimate is possible, units are + [CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED][google.cloud.talent.v4.CompensationInfo.CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED] + and then further clarified in + [CompensationEntry.description][google.cloud.talent.v4.CompensationInfo.CompensationEntry.description] + field. + """ + COMPENSATION_TYPE_UNSPECIFIED = 0 + BASE = 1 + BONUS = 2 + SIGNING_BONUS = 3 + EQUITY = 4 + PROFIT_SHARING = 5 + COMMISSIONS = 6 + TIPS = 7 + OTHER_COMPENSATION_TYPE = 8 + + class CompensationUnit(proto.Enum): + r"""Pay frequency.""" + COMPENSATION_UNIT_UNSPECIFIED = 0 + HOURLY = 1 + DAILY = 2 + WEEKLY = 3 + MONTHLY = 4 + YEARLY = 5 + ONE_TIME = 6 + OTHER_COMPENSATION_UNIT = 7 + + class CompensationEntry(proto.Message): + r"""A compensation entry that represents one component of compensation, + such as base pay, bonus, or other compensation type. + + Annualization: One compensation entry can be annualized if + + - it contains valid + [amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] + or + [range][google.cloud.talent.v4.CompensationInfo.CompensationEntry.range]. + - and its + [expected_units_per_year][google.cloud.talent.v4.CompensationInfo.CompensationEntry.expected_units_per_year] + is set or can be derived. Its annualized range is determined as + ([amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] + or + [range][google.cloud.talent.v4.CompensationInfo.CompensationEntry.range]) + times + [expected_units_per_year][google.cloud.talent.v4.CompensationInfo.CompensationEntry.expected_units_per_year]. + + 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: + type_ (google.cloud.talent_v4.types.CompensationInfo.CompensationType): + Compensation type. + + Default is + [CompensationType.COMPENSATION_TYPE_UNSPECIFIED][google.cloud.talent.v4.CompensationInfo.CompensationType.COMPENSATION_TYPE_UNSPECIFIED]. + unit (google.cloud.talent_v4.types.CompensationInfo.CompensationUnit): + Frequency of the specified amount. + + Default is + [CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED][google.cloud.talent.v4.CompensationInfo.CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED]. + amount (google.type.money_pb2.Money): + Compensation amount. + + This field is a member of `oneof`_ ``compensation_amount``. + range_ (google.cloud.talent_v4.types.CompensationInfo.CompensationRange): + Compensation range. + + This field is a member of `oneof`_ ``compensation_amount``. + description (str): + Compensation description. For example, could + indicate equity terms or provide additional + context to an estimated bonus. + expected_units_per_year (google.protobuf.wrappers_pb2.DoubleValue): + Expected number of units paid each year. If not specified, + when + [Job.employment_types][google.cloud.talent.v4.Job.employment_types] + is FULLTIME, a default value is inferred based on + [unit][google.cloud.talent.v4.CompensationInfo.CompensationEntry.unit]. + Default values: + + - HOURLY: 2080 + - DAILY: 260 + - WEEKLY: 52 + - MONTHLY: 12 + - ANNUAL: 1 + """ + + type_ = proto.Field( + proto.ENUM, + number=1, + enum='CompensationInfo.CompensationType', + ) + unit = proto.Field( + proto.ENUM, + number=2, + enum='CompensationInfo.CompensationUnit', + ) + amount = proto.Field( + proto.MESSAGE, + number=3, + oneof='compensation_amount', + message=money_pb2.Money, + ) + range_ = proto.Field( + proto.MESSAGE, + number=4, + oneof='compensation_amount', + message='CompensationInfo.CompensationRange', + ) + description = proto.Field( + proto.STRING, + number=5, + ) + expected_units_per_year = proto.Field( + proto.MESSAGE, + number=6, + message=wrappers_pb2.DoubleValue, + ) + + class CompensationRange(proto.Message): + r"""Compensation range. + + Attributes: + max_compensation (google.type.money_pb2.Money): + The maximum amount of compensation. If left empty, the value + is set to a maximal compensation value and the currency code + is set to match the [currency + code][google.type.Money.currency_code] of min_compensation. + min_compensation (google.type.money_pb2.Money): + The minimum amount of compensation. If left empty, the value + is set to zero and the currency code is set to match the + [currency code][google.type.Money.currency_code] of + max_compensation. + """ + + max_compensation = proto.Field( + proto.MESSAGE, + number=2, + message=money_pb2.Money, + ) + min_compensation = proto.Field( + proto.MESSAGE, + number=1, + message=money_pb2.Money, + ) + + entries = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=CompensationEntry, + ) + annualized_base_compensation_range = proto.Field( + proto.MESSAGE, + number=2, + message=CompensationRange, + ) + annualized_total_compensation_range = proto.Field( + proto.MESSAGE, + number=3, + message=CompensationRange, + ) + + +class BatchOperationMetadata(proto.Message): + r"""Metadata used for long running operations returned by CTS batch + APIs. It's used to replace + [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]. + + Attributes: + state (google.cloud.talent_v4.types.BatchOperationMetadata.State): + The state of a long running operation. + state_description (str): + More detailed information about operation + state. + success_count (int): + Count of successful item(s) inside an + operation. + failure_count (int): + Count of failed item(s) inside an operation. + total_count (int): + Count of total item(s) inside an operation. + create_time (google.protobuf.timestamp_pb2.Timestamp): + The time when the batch operation is created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + The time when the batch operation status is updated. The + metadata and the + [update_time][google.cloud.talent.v4.BatchOperationMetadata.update_time] + is refreshed every minute otherwise cached data is returned. + end_time (google.protobuf.timestamp_pb2.Timestamp): + The time when the batch operation is finished and + [google.longrunning.Operation.done][google.longrunning.Operation.done] + is set to ``true``. + """ + class State(proto.Enum): + r"""""" + STATE_UNSPECIFIED = 0 + INITIALIZING = 1 + PROCESSING = 2 + SUCCEEDED = 3 + FAILED = 4 + CANCELLING = 5 + CANCELLED = 6 + + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_description = proto.Field( + proto.STRING, + number=2, + ) + success_count = proto.Field( + proto.INT32, + number=3, + ) + failure_count = proto.Field( + proto.INT32, + number=4, + ) + total_count = proto.Field( + proto.INT32, + number=5, + ) + create_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/company.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/company.py new file mode 100644 index 00000000..c4d82317 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/company.py @@ -0,0 +1,175 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4.types import common + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'Company', + }, +) + + +class Company(proto.Message): + r"""A Company resource represents a company in the service. A + company is the entity that owns job postings, that is, the + hiring entity responsible for employing applicants for the job + position. + + Attributes: + name (str): + Required during company update. + + The resource name for a company. This is generated by the + service when a company is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/baz". + display_name (str): + Required. The display name of the company, + for example, "Google LLC". + external_id (str): + Required. Client side company identifier, + used to uniquely identify the company. + + The maximum number of allowed characters is 255. + size (google.cloud.talent_v4.types.CompanySize): + The employer's company size. + headquarters_address (str): + The street address of the company's main headquarters, which + may be different from the job location. The service attempts + to geolocate the provided address, and populates a more + specific location wherever possible in + [DerivedInfo.headquarters_location][google.cloud.talent.v4.Company.DerivedInfo.headquarters_location]. + hiring_agency (bool): + Set to true if it is the hiring agency that + post jobs for other employers. + + Defaults to false if not provided. + eeo_text (str): + Equal Employment Opportunity legal disclaimer + text to be associated with all jobs, and + typically to be displayed in all roles. + + The maximum number of allowed characters is 500. + website_uri (str): + The URI representing the company's primary + web site or home page, for example, + "https://www.google.com". + The maximum number of allowed characters is 255. + career_site_uri (str): + The URI to employer's career site or careers + page on the employer's web site, for example, + "https://careers.google.com". + image_uri (str): + A URI that hosts the employer's company logo. + keyword_searchable_job_custom_attributes (Sequence[str]): + A list of keys of filterable + [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes], + whose corresponding ``string_values`` are used in keyword + searches. Jobs with ``string_values`` under these specified + field keys are returned if any of the values match the + search keyword. Custom field values with parenthesis, + brackets and special symbols are not searchable as-is, and + those keyword queries must be surrounded by quotes. + derived_info (google.cloud.talent_v4.types.Company.DerivedInfo): + Output only. Derived details about the + company. + suspended (bool): + Output only. Indicates whether a company is + flagged to be suspended from public availability + by the service when job content appears + suspicious, abusive, or spammy. + """ + + class DerivedInfo(proto.Message): + r"""Derived details about the company. + + Attributes: + headquarters_location (google.cloud.talent_v4.types.Location): + A structured headquarters location of the company, resolved + from + [Company.headquarters_address][google.cloud.talent.v4.Company.headquarters_address] + if provided. + """ + + headquarters_location = proto.Field( + proto.MESSAGE, + number=1, + message=common.Location, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + external_id = proto.Field( + proto.STRING, + number=3, + ) + size = proto.Field( + proto.ENUM, + number=4, + enum=common.CompanySize, + ) + headquarters_address = proto.Field( + proto.STRING, + number=5, + ) + hiring_agency = proto.Field( + proto.BOOL, + number=6, + ) + eeo_text = proto.Field( + proto.STRING, + number=7, + ) + website_uri = proto.Field( + proto.STRING, + number=8, + ) + career_site_uri = proto.Field( + proto.STRING, + number=9, + ) + image_uri = proto.Field( + proto.STRING, + number=10, + ) + keyword_searchable_job_custom_attributes = proto.RepeatedField( + proto.STRING, + number=11, + ) + derived_info = proto.Field( + proto.MESSAGE, + number=12, + message=DerivedInfo, + ) + suspended = proto.Field( + proto.BOOL, + number=13, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/company_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/company_service.py new file mode 100644 index 00000000..33423b9d --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/company_service.py @@ -0,0 +1,210 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import company as gct_company +from google.protobuf import field_mask_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'CreateCompanyRequest', + 'GetCompanyRequest', + 'UpdateCompanyRequest', + 'DeleteCompanyRequest', + 'ListCompaniesRequest', + 'ListCompaniesResponse', + }, +) + + +class CreateCompanyRequest(proto.Message): + r"""The Request of the CreateCompany method. + + Attributes: + parent (str): + Required. Resource name of the tenant under which the + company is created. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + company (google.cloud.talent_v4.types.Company): + Required. The company to be created. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + company = proto.Field( + proto.MESSAGE, + number=2, + message=gct_company.Company, + ) + + +class GetCompanyRequest(proto.Message): + r"""Request for getting a company by name. + + Attributes: + name (str): + Required. The resource name of the company to be retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, + "projects/api-test-project/tenants/foo/companies/bar". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateCompanyRequest(proto.Message): + r"""Request for updating a specified company. + + Attributes: + company (google.cloud.talent_v4.types.Company): + Required. The company 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.v4.UpdateCompanyRequest.update_mask] + is provided, only the specified fields in + [company][google.cloud.talent.v4.UpdateCompanyRequest.company] + are updated. Otherwise all the fields are updated. + + A field mask to specify the company fields to be updated. + Only top level fields of + [Company][google.cloud.talent.v4.Company] are supported. + """ + + company = proto.Field( + proto.MESSAGE, + number=1, + message=gct_company.Company, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteCompanyRequest(proto.Message): + r"""Request to delete a company. + + Attributes: + name (str): + Required. The resource name of the company to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/baz". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCompaniesRequest(proto.Message): + r"""List companies for which the client has ACL visibility. + + Attributes: + parent (str): + Required. Resource name of the tenant under which the + company is created. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + page_token (str): + The starting indicator from which to return + results. + page_size (int): + The maximum number of companies to be + returned, at most 100. Default is 100 if a + non-positive number is provided. + require_open_jobs (bool): + Set to true if the companies requested must have open jobs. + + Defaults to false. + + If true, at most + [page_size][google.cloud.talent.v4.ListCompaniesRequest.page_size] + of companies are fetched, among which only those with open + jobs are returned. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_token = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + require_open_jobs = proto.Field( + proto.BOOL, + number=4, + ) + + +class ListCompaniesResponse(proto.Message): + r"""The List companies response object. + + Attributes: + companies (Sequence[google.cloud.talent_v4.types.Company]): + Companies for the current client. + next_page_token (str): + A token to retrieve the next page of results. + metadata (google.cloud.talent_v4.types.ResponseMetadata): + Additional information for the API + invocation, such as the request tracking id. + """ + + @property + def raw_page(self): + return self + + companies = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_company.Company, + ) + 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/owl-bot-staging/v4/google/cloud/talent_v4/types/completion_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/completion_service.py new file mode 100644 index 00000000..b1fa141d --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/completion_service.py @@ -0,0 +1,163 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4.types import common + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'CompleteQueryRequest', + 'CompleteQueryResponse', + }, +) + + +class CompleteQueryRequest(proto.Message): + r"""Auto-complete parameters. + + Attributes: + tenant (str): + Required. Resource name of tenant the completion is + performed within. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + query (str): + Required. The query used to generate + suggestions. + The maximum number of allowed characters is 255. + language_codes (Sequence[str]): + The list of languages of the query. This is the BCP-47 + language code, such as "en-US" or "sr-Latn". For more + information, see `Tags for Identifying + Languages `__. + + The maximum number of allowed characters is 255. + page_size (int): + Required. Completion result count. + The maximum allowed page size is 10. + company (str): + If provided, restricts completion to specified company. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/baz". + scope (google.cloud.talent_v4.types.CompleteQueryRequest.CompletionScope): + The scope of the completion. The defaults is + [CompletionScope.PUBLIC][google.cloud.talent.v4.CompleteQueryRequest.CompletionScope.PUBLIC]. + type_ (google.cloud.talent_v4.types.CompleteQueryRequest.CompletionType): + The completion topic. The default is + [CompletionType.COMBINED][google.cloud.talent.v4.CompleteQueryRequest.CompletionType.COMBINED]. + """ + class CompletionScope(proto.Enum): + r"""Enum to specify the scope of completion.""" + COMPLETION_SCOPE_UNSPECIFIED = 0 + TENANT = 1 + PUBLIC = 2 + + class CompletionType(proto.Enum): + r"""Enum to specify auto-completion topics.""" + COMPLETION_TYPE_UNSPECIFIED = 0 + JOB_TITLE = 1 + COMPANY_NAME = 2 + COMBINED = 3 + + tenant = proto.Field( + proto.STRING, + number=1, + ) + query = proto.Field( + proto.STRING, + number=2, + ) + language_codes = proto.RepeatedField( + proto.STRING, + number=3, + ) + page_size = proto.Field( + proto.INT32, + number=4, + ) + company = proto.Field( + proto.STRING, + number=5, + ) + scope = proto.Field( + proto.ENUM, + number=6, + enum=CompletionScope, + ) + type_ = proto.Field( + proto.ENUM, + number=7, + enum=CompletionType, + ) + + +class CompleteQueryResponse(proto.Message): + r"""Response of auto-complete query. + + Attributes: + completion_results (Sequence[google.cloud.talent_v4.types.CompleteQueryResponse.CompletionResult]): + Results of the matching job/company + candidates. + metadata (google.cloud.talent_v4.types.ResponseMetadata): + Additional information for the API + invocation, such as the request tracking id. + """ + + class CompletionResult(proto.Message): + r"""Resource that represents completion results. + + Attributes: + suggestion (str): + The suggestion for the query. + type_ (google.cloud.talent_v4.types.CompleteQueryRequest.CompletionType): + The completion topic. + image_uri (str): + The URI of the company image for + [COMPANY_NAME][google.cloud.talent.v4.CompleteQueryRequest.CompletionType.COMPANY_NAME]. + """ + + suggestion = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum='CompleteQueryRequest.CompletionType', + ) + image_uri = proto.Field( + proto.STRING, + number=3, + ) + + completion_results = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=CompletionResult, + ) + metadata = proto.Field( + proto.MESSAGE, + number=2, + message=common.ResponseMetadata, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/event.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/event.py new file mode 100644 index 00000000..a868c0cd --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/event.py @@ -0,0 +1,143 @@ +# -*- 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 proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'ClientEvent', + 'JobEvent', + }, +) + + +class ClientEvent(proto.Message): + r"""An event issued when an end user interacts with the + application that implements Cloud Talent Solution. Providing + this information improves the quality of results for the API + clients, enabling the service to perform optimally. The number + of events sent must be consistent with other calls, such as job + searches, issued to the service by the client. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + request_id (str): + Strongly recommended for the best service experience. + + A unique ID generated in the API responses. It can be found + in + [ResponseMetadata.request_id][google.cloud.talent.v4.ResponseMetadata.request_id]. + event_id (str): + Required. A unique identifier, generated by + the client application. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Required. The timestamp of the event. + job_event (google.cloud.talent_v4.types.JobEvent): + An event issued when a job seeker 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 + or other users, for example, feedback on why a + job was bookmarked. + """ + + request_id = proto.Field( + proto.STRING, + number=1, + ) + event_id = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + job_event = proto.Field( + proto.MESSAGE, + number=5, + oneof='event', + message='JobEvent', + ) + event_notes = proto.Field( + proto.STRING, + number=9, + ) + + +class JobEvent(proto.Message): + r"""An event issued when a job seeker interacts with the + application that implements Cloud Talent Solution. + + Attributes: + type_ (google.cloud.talent_v4.types.JobEvent.JobEventType): + Required. The type of the event (see + [JobEventType][google.cloud.talent.v4.JobEvent.JobEventType]). + jobs (Sequence[str]): + Required. The [job name(s)][google.cloud.talent.v4.Job.name] + associated with this event. For example, if this is an + [impression][google.cloud.talent.v4.JobEvent.JobEventType.IMPRESSION] + event, this field contains the identifiers of all jobs shown + to the job seeker. If this was a + [view][google.cloud.talent.v4.JobEvent.JobEventType.VIEW] + event, this field contains the identifier of the viewed job. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}", + for example, "projects/foo/tenants/bar/jobs/baz". + """ + class JobEventType(proto.Enum): + r"""An enumeration of an event attributed to the behavior of the + end user, such as a job seeker. + """ + JOB_EVENT_TYPE_UNSPECIFIED = 0 + IMPRESSION = 1 + VIEW = 2 + VIEW_REDIRECT = 3 + APPLICATION_START = 4 + APPLICATION_FINISH = 5 + APPLICATION_QUICK_SUBMISSION = 6 + APPLICATION_REDIRECT = 7 + APPLICATION_START_FROM_SEARCH = 8 + APPLICATION_REDIRECT_FROM_SEARCH = 9 + APPLICATION_COMPANY_SUBMIT = 10 + BOOKMARK = 11 + NOTIFICATION = 12 + HIRED = 13 + SENT_CV = 14 + INTERVIEW_GRANTED = 15 + + type_ = proto.Field( + proto.ENUM, + number=1, + enum=JobEventType, + ) + jobs = proto.RepeatedField( + proto.STRING, + number=2, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/event_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/event_service.py new file mode 100644 index 00000000..27446466 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/event_service.py @@ -0,0 +1,56 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4.types import event + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'CreateClientEventRequest', + }, +) + + +class CreateClientEventRequest(proto.Message): + r"""The report event request. + + Attributes: + parent (str): + Required. Resource name of the tenant under which the event + is created. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + client_event (google.cloud.talent_v4.types.ClientEvent): + Required. Events issued when end user + interacts with customer's application that uses + Cloud Talent Solution. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + client_event = proto.Field( + proto.MESSAGE, + number=2, + message=event.ClientEvent, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/filters.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/filters.py new file mode 100644 index 00000000..5fc3caae --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/filters.py @@ -0,0 +1,499 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4.types import common +from google.protobuf import duration_pb2 # type: ignore +from google.type import latlng_pb2 # type: ignore +from google.type import timeofday_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'JobQuery', + 'LocationFilter', + 'CompensationFilter', + 'CommuteFilter', + }, +) + + +class JobQuery(proto.Message): + r"""The query required to perform a search query. + + Attributes: + query (str): + The query string that matches against the job + title, description, and location fields. + + The maximum number of allowed characters is 255. + query_language_code (str): + The language code of + [query][google.cloud.talent.v4.JobQuery.query]. For example, + "en-US". This field helps to better interpret the query. + + If a value isn't specified, the query language code is + automatically detected, which may not be accurate. + + Language code should be in BCP-47 format, such as "en-US" or + "sr-Latn". For more information, see `Tags for Identifying + Languages `__. + companies (Sequence[str]): + This filter specifies the company entities to search + against. + + If a value isn't specified, jobs are searched for against + all companies. + + If multiple values are specified, jobs are searched against + the companies specified. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". + For example, "projects/foo/tenants/bar/companies/baz". + + At most 20 company filters are allowed. + location_filters (Sequence[google.cloud.talent_v4.types.LocationFilter]): + The location filter specifies geo-regions containing the + jobs to search against. See + [LocationFilter][google.cloud.talent.v4.LocationFilter] for + more information. + + If a location value isn't specified, jobs fitting the other + search criteria are retrieved regardless of where they're + located. + + If multiple values are specified, jobs are retrieved from + any of the specified locations. If different values are + specified for the + [LocationFilter.distance_in_miles][google.cloud.talent.v4.LocationFilter.distance_in_miles] + parameter, the maximum provided distance is used for all + locations. + + At most 5 location filters are allowed. + job_categories (Sequence[google.cloud.talent_v4.types.JobCategory]): + The category filter specifies the categories of jobs to + search against. See + [JobCategory][google.cloud.talent.v4.JobCategory] for more + information. + + If a value isn't specified, jobs from any category are + searched against. + + If multiple values are specified, jobs from any of the + specified categories are searched against. + commute_filter (google.cloud.talent_v4.types.CommuteFilter): + Allows filtering jobs by commute time with different travel + methods (for example, driving or public transit). + + Note: This only works when you specify a + [CommuteMethod][google.cloud.talent.v4.CommuteMethod]. In + this case, + [location_filters][google.cloud.talent.v4.JobQuery.location_filters] + is ignored. + + Currently we don't support sorting by commute time. + company_display_names (Sequence[str]): + This filter specifies the company + [Company.display_name][google.cloud.talent.v4.Company.display_name] + 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. + + If multiple values are specified, jobs within the search + results may be associated with any of the specified + companies. + + At most 20 company display name filters are allowed. + compensation_filter (google.cloud.talent_v4.types.CompensationFilter): + This search filter is applied only to + [Job.compensation_info][google.cloud.talent.v4.Job.compensation_info]. + For example, if the filter is specified as "Hourly job with + per-hour compensation > $15", only jobs meeting these + criteria are searched. If a filter isn't defined, all open + jobs are searched. + custom_attribute_filter (str): + This filter specifies a structured syntax to match against + the + [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes] + marked as ``filterable``. + + The syntax for this expression is a subset of SQL syntax. + + Supported operators are: ``=``, ``!=``, ``<``, ``<=``, + ``>``, and ``>=`` where the left of the operator is a custom + field key and the right of the operator is a number or a + quoted string. You must escape backslash (\) and quote (") + characters. + + Supported functions are ``LOWER([field_name])`` to perform a + case insensitive match and ``EMPTY([field_name])`` 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"), a maximum of 100 comparisons or functions are + allowed in the expression. The expression must be < 10000 + bytes in length. + + Sample Query: + ``(LOWER(driving_license)="class \"a\"" OR EMPTY(driving_license)) AND driving_years > 10`` + 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". + Defaults to false: a spell check is performed. + employment_types (Sequence[google.cloud.talent_v4.types.EmploymentType]): + The employment type filter specifies the employment type of + jobs to search against, such as + [EmploymentType.FULL_TIME][google.cloud.talent.v4.EmploymentType.FULL_TIME]. + + If a value isn't specified, jobs in the search results + includes any employment type. + + If multiple values are specified, jobs in the search results + include any of the specified employment types. + language_codes (Sequence[str]): + This filter specifies the locale of jobs to search against, + for example, "en-US". + + If a value isn't specified, the search results can contain + jobs in any locale. + + Language codes should be in BCP-47 format, such as "en-US" + or "sr-Latn". For more information, see `Tags for + Identifying + Languages `__. + + At most 10 language code filters are allowed. + publish_time_range (google.cloud.talent_v4.types.TimestampRange): + Jobs published within a range specified by + this filter are searched against. + excluded_jobs (Sequence[str]): + This filter specifies a list of job names to + be excluded during search. + At most 400 excluded job names are allowed. + """ + + query = proto.Field( + proto.STRING, + number=1, + ) + query_language_code = proto.Field( + proto.STRING, + number=14, + ) + companies = proto.RepeatedField( + proto.STRING, + number=2, + ) + location_filters = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='LocationFilter', + ) + job_categories = proto.RepeatedField( + proto.ENUM, + number=4, + enum=common.JobCategory, + ) + commute_filter = proto.Field( + proto.MESSAGE, + number=5, + message='CommuteFilter', + ) + company_display_names = proto.RepeatedField( + proto.STRING, + number=6, + ) + compensation_filter = proto.Field( + proto.MESSAGE, + number=7, + message='CompensationFilter', + ) + custom_attribute_filter = proto.Field( + proto.STRING, + number=8, + ) + disable_spell_check = proto.Field( + proto.BOOL, + number=9, + ) + employment_types = proto.RepeatedField( + proto.ENUM, + number=10, + enum=common.EmploymentType, + ) + language_codes = proto.RepeatedField( + proto.STRING, + number=11, + ) + publish_time_range = proto.Field( + proto.MESSAGE, + number=12, + message=common.TimestampRange, + ) + excluded_jobs = proto.RepeatedField( + proto.STRING, + number=13, + ) + + +class LocationFilter(proto.Message): + r"""Geographic region of the search. + + Attributes: + address (str): + The address name, such as "Mountain View" or + "Bay Area". + region_code (str): + 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://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 + provided. + distance_in_miles (float): + The distance_in_miles is applied when the location being + searched for is identified as a city or smaller. This field + is ignored if the location being searched for is a state or + larger. + telecommute_preference (google.cloud.talent_v4.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). + [Job.posting_region][google.cloud.talent.v4.Job.posting_region] + indicates if a job permits telecommuting. If this field is + set to + [TelecommutePreference.TELECOMMUTE_ALLOWED][google.cloud.talent.v4.LocationFilter.TelecommutePreference.TELECOMMUTE_ALLOWED], + telecommuting jobs are searched, and + [address][google.cloud.talent.v4.LocationFilter.address] and + [lat_lng][google.cloud.talent.v4.LocationFilter.lat_lng] are + ignored. If not set or set to + [TelecommutePreference.TELECOMMUTE_EXCLUDED][google.cloud.talent.v4.LocationFilter.TelecommutePreference.TELECOMMUTE_EXCLUDED], + the telecommute status of the jobs is ignored. Jobs that + have + [PostingRegion.TELECOMMUTE][google.cloud.talent.v4.PostingRegion.TELECOMMUTE] + and have additional + [Job.addresses][google.cloud.talent.v4.Job.addresses] may + still be matched based on other location filters using + [address][google.cloud.talent.v4.LocationFilter.address] or + [latlng][]. + + This filter can be used by itself to search exclusively for + telecommuting jobs, or it can be combined with another + location filter to search for a combination of job + locations, such as "Mountain View" or "telecommuting" jobs. + However, when used in combination with other location + filters, telecommuting jobs can be treated as less relevant + than other jobs in the search response. + + This field is only used for job search requests. + """ + class TelecommutePreference(proto.Enum): + r"""Specify whether to include telecommute jobs.""" + TELECOMMUTE_PREFERENCE_UNSPECIFIED = 0 + TELECOMMUTE_EXCLUDED = 1 + TELECOMMUTE_ALLOWED = 2 + TELECOMMUTE_JOBS_EXCLUDED = 3 + + address = proto.Field( + proto.STRING, + number=1, + ) + region_code = proto.Field( + proto.STRING, + number=2, + ) + lat_lng = proto.Field( + proto.MESSAGE, + number=3, + message=latlng_pb2.LatLng, + ) + distance_in_miles = proto.Field( + proto.DOUBLE, + number=4, + ) + telecommute_preference = proto.Field( + proto.ENUM, + number=5, + enum=TelecommutePreference, + ) + + +class CompensationFilter(proto.Message): + r"""Filter on job compensation type and amount. + + Attributes: + type_ (google.cloud.talent_v4.types.CompensationFilter.FilterType): + Required. Type of filter. + units (Sequence[google.cloud.talent_v4.types.CompensationInfo.CompensationUnit]): + Required. Specify desired ``base compensation entry's`` + [CompensationInfo.CompensationUnit][google.cloud.talent.v4.CompensationInfo.CompensationUnit]. + range_ (google.cloud.talent_v4.types.CompensationInfo.CompensationRange): + Compensation range. + include_jobs_with_unspecified_compensation_range (bool): + If set to true, jobs with unspecified + compensation range fields are included. + """ + class FilterType(proto.Enum): + r"""Specify the type of filtering.""" + FILTER_TYPE_UNSPECIFIED = 0 + UNIT_ONLY = 1 + UNIT_AND_AMOUNT = 2 + ANNUALIZED_BASE_AMOUNT = 3 + ANNUALIZED_TOTAL_AMOUNT = 4 + + type_ = proto.Field( + proto.ENUM, + number=1, + enum=FilterType, + ) + units = proto.RepeatedField( + proto.ENUM, + number=2, + enum=common.CompensationInfo.CompensationUnit, + ) + range_ = proto.Field( + proto.MESSAGE, + number=3, + message=common.CompensationInfo.CompensationRange, + ) + include_jobs_with_unspecified_compensation_range = proto.Field( + proto.BOOL, + number=4, + ) + + +class CommuteFilter(proto.Message): + r"""Parameters needed for commute search. + + 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: + commute_method (google.cloud.talent_v4.types.CommuteMethod): + Required. The method of transportation to + calculate the commute time for. + start_coordinates (google.type.latlng_pb2.LatLng): + Required. The latitude and longitude of the + location to calculate the commute time from. + travel_duration (google.protobuf.duration_pb2.Duration): + Required. The maximum travel time in seconds. The maximum + allowed value is ``3600s`` (one hour). Format is ``123s``. + allow_imprecise_addresses (bool): + If ``true``, jobs without street level addresses may also be + returned. For city level addresses, the city center is used. + For state and coarser level addresses, text matching is + used. If this field is set to ``false`` or isn't specified, + only jobs that include street level addresses will be + returned by commute search. + road_traffic (google.cloud.talent_v4.types.CommuteFilter.RoadTraffic): + Specifies the traffic density to use when + calculating commute time. + + This field is a member of `oneof`_ ``traffic_option``. + departure_time (google.type.timeofday_pb2.TimeOfDay): + The departure time used to calculate traffic impact, + represented as + [google.type.TimeOfDay][google.type.TimeOfDay] in local time + zone. + + Currently traffic model is restricted to hour level + resolution. + + This field is a member of `oneof`_ ``traffic_option``. + """ + class RoadTraffic(proto.Enum): + r"""The traffic density to use when calculating commute time.""" + ROAD_TRAFFIC_UNSPECIFIED = 0 + TRAFFIC_FREE = 1 + BUSY_HOUR = 2 + + commute_method = proto.Field( + proto.ENUM, + number=1, + enum=common.CommuteMethod, + ) + start_coordinates = proto.Field( + proto.MESSAGE, + number=2, + message=latlng_pb2.LatLng, + ) + travel_duration = proto.Field( + proto.MESSAGE, + number=3, + message=duration_pb2.Duration, + ) + allow_imprecise_addresses = proto.Field( + proto.BOOL, + number=4, + ) + road_traffic = proto.Field( + proto.ENUM, + number=5, + oneof='traffic_option', + enum=RoadTraffic, + ) + departure_time = proto.Field( + proto.MESSAGE, + number=6, + oneof='traffic_option', + message=timeofday_pb2.TimeOfDay, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/histogram.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/histogram.py new file mode 100644 index 00000000..3265766b --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/histogram.py @@ -0,0 +1,82 @@ +# -*- 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 proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'HistogramQuery', + 'HistogramQueryResult', + }, +) + + +class HistogramQuery(proto.Message): + r"""The histogram request. + + Attributes: + histogram_query (str): + An expression specifies a histogram request against matching + jobs for searches. + + See + [SearchJobsRequest.histogram_queries][google.cloud.talent.v4.SearchJobsRequest.histogram_queries] + for details about syntax. + """ + + histogram_query = proto.Field( + proto.STRING, + number=1, + ) + + +class HistogramQueryResult(proto.Message): + r"""Histogram result that matches + [HistogramQuery][google.cloud.talent.v4.HistogramQuery] specified in + searches. + + Attributes: + histogram_query (str): + Requested histogram expression. + histogram (Mapping[str, int]): + A map from the values of the facet associated with distinct + values to the number of matching entries with corresponding + value. + + The key format is: + + - (for string histogram) string values stored in the field. + - (for named numeric bucket) name specified in ``bucket()`` + function, like for ``bucket(0, MAX, "non-negative")``, + the key will be ``non-negative``. + - (for anonymous numeric bucket) range formatted as + ``-``, for example, ``0-1000``, ``MIN-0``, and + ``0-MAX``. + """ + + histogram_query = proto.Field( + proto.STRING, + number=1, + ) + histogram = proto.MapField( + proto.STRING, + proto.INT64, + number=2, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/job.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/job.py new file mode 100644 index 00000000..501088e6 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/job.py @@ -0,0 +1,569 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4.types import common +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'Job', + }, +) + + +class Job(proto.Message): + r"""A Job resource represents a job posting (also referred to as a "job + listing" or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4.Company], which is the hiring + entity responsible for the job. + + Attributes: + name (str): + Required during job update. + + The resource name for the job. This is generated by the + service when a job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + Use of this field in job queries and API calls is preferred + over the use of + [requisition_id][google.cloud.talent.v4.Job.requisition_id] + since this value is unique. + company (str): + Required. The resource name of the company listing the job. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". + For example, "projects/foo/tenants/bar/companies/baz". + requisition_id (str): + Required. The requisition ID, also referred to as the + posting ID, is assigned by the client to identify a job. + This field is intended to be used by clients for client + identification and tracking of postings. A job isn't allowed + to be created if there is another job with the same + [company][google.cloud.talent.v4.Job.name], + [language_code][google.cloud.talent.v4.Job.language_code] + and + [requisition_id][google.cloud.talent.v4.Job.requisition_id]. + + The maximum number of allowed characters is 255. + title (str): + Required. The title of the job, such as + "Software Engineer" + The maximum number of allowed characters is 500. + description (str): + Required. The description of the job, which typically + includes a multi-paragraph description of the company and + related information. Separate fields are provided on the job + object for + [responsibilities][google.cloud.talent.v4.Job.responsibilities], + [qualifications][google.cloud.talent.v4.Job.qualifications], + and other job characteristics. Use of these separate job + fields is recommended. + + This field accepts and sanitizes HTML input, and also + accepts bold, italic, ordered list, and unordered list + markup tags. + + The maximum number of allowed characters is 100,000. + addresses (Sequence[str]): + Strongly recommended for the best service experience. + + Location(s) where the employer is looking to hire for this + job posting. + + Specifying the full street address(es) of the hiring + location enables better API results, especially job searches + by commute time. + + At most 50 locations are allowed for best search + performance. If a job has more locations, it is suggested to + split it into multiple jobs with unique + [requisition_id][google.cloud.talent.v4.Job.requisition_id]s + (e.g. 'ReqA' becomes 'ReqA-1', 'ReqA-2', and so on.) as + multiple jobs with the same + [company][google.cloud.talent.v4.Job.company], + [language_code][google.cloud.talent.v4.Job.language_code] + and + [requisition_id][google.cloud.talent.v4.Job.requisition_id] + are not allowed. If the original + [requisition_id][google.cloud.talent.v4.Job.requisition_id] + must be preserved, a custom field should be used for + storage. It is also suggested to group the locations that + close to each other in the same job for better search + experience. + + Jobs with multiple addresses must have their addresses with + the same [LocationType][] to allow location filtering to + work properly. (For example, a Job with addresses "1600 + Amphitheatre Parkway, Mountain View, CA, USA" and "London, + UK" may not have location filters applied correctly at + search time since the first is a + [LocationType.STREET_ADDRESS][] and the second is a + [LocationType.LOCALITY][].) If a job needs to have multiple + addresses, it is suggested to split it into multiple jobs + with same LocationTypes. + + The maximum number of allowed characters is 500. + application_info (google.cloud.talent_v4.types.Job.ApplicationInfo): + Job application information. + job_benefits (Sequence[google.cloud.talent_v4.types.JobBenefit]): + The benefits included with the job. + compensation_info (google.cloud.talent_v4.types.CompensationInfo): + Job compensation information (a.k.a. "pay + rate") i.e., the compensation that will paid to + the employee. + custom_attributes (Mapping[str, google.cloud.talent_v4.types.CustomAttribute]): + A map of fields to hold both filterable and non-filterable + custom job attributes that are not covered by the provided + structured fields. + + The keys of the map are strings up to 64 bytes and must + match the pattern: ``[a-zA-Z][a-zA-Z0-9_]*``. For example, + key0LikeThis or KEY_1_LIKE_THIS. + + At most 100 filterable and at most 100 unfilterable keys are + supported. For filterable ``string_values``, across all keys + at most 200 values are allowed, with each string no more + than 255 characters. For unfilterable ``string_values``, the + maximum total size of ``string_values`` across all keys is + 50KB. + degree_types (Sequence[google.cloud.talent_v4.types.DegreeType]): + The desired education degrees for the job, + such as Bachelors, Masters. + department (str): + The department or functional area within the + company with the open position. + + The maximum number of allowed characters is 255. + employment_types (Sequence[google.cloud.talent_v4.types.EmploymentType]): + The employment type(s) of a job, for example, [full + time][google.cloud.talent.v4.EmploymentType.FULL_TIME] or + [part + time][google.cloud.talent.v4.EmploymentType.PART_TIME]. + incentives (str): + A description of bonus, commission, and other + compensation incentives associated with the job + not including salary or pay. + The maximum number of allowed characters is + 10,000. + language_code (str): + The language of the posting. This field is distinct from any + requirements for fluency that are associated with the job. + + Language codes must be in BCP-47 format, such as "en-US" or + "sr-Latn". For more information, see `Tags for Identifying + Languages `__\ {: + class="external" target="_blank" }. + + If this field is unspecified and + [Job.description][google.cloud.talent.v4.Job.description] is + present, detected language code based on + [Job.description][google.cloud.talent.v4.Job.description] is + assigned, otherwise defaults to 'en_US'. + job_level (google.cloud.talent_v4.types.JobLevel): + The experience level associated with the job, + such as "Entry Level". + promotion_value (int): + A promotion value of the job, as determined by the client. + The value determines the sort order of the jobs returned + when searching for jobs using the featured jobs search call, + with higher promotional values being returned first and ties + being resolved by relevance sort. Only the jobs with a + promotionValue >0 are returned in a FEATURED_JOB_SEARCH. + + Default value is 0, and negative values are treated as 0. + qualifications (str): + A description of the qualifications required to perform the + job. The use of this field is recommended as an alternative + to using the more general + [description][google.cloud.talent.v4.Job.description] field. + + This field accepts and sanitizes HTML input, and also + accepts bold, italic, ordered list, and unordered list + markup tags. + + The maximum number of allowed characters is 10,000. + responsibilities (str): + A description of job responsibilities. The use of this field + is recommended as an alternative to using the more general + [description][google.cloud.talent.v4.Job.description] field. + + This field accepts and sanitizes HTML input, and also + accepts bold, italic, ordered list, and unordered list + markup tags. + + The maximum number of allowed characters is 10,000. + posting_region (google.cloud.talent_v4.types.PostingRegion): + The job + [PostingRegion][google.cloud.talent.v4.PostingRegion] (for + example, state, country) throughout which the job is + available. If this field is set, a + [LocationFilter][google.cloud.talent.v4.LocationFilter] in a + search query within the job region finds this job posting if + an exact location match isn't specified. If this field is + set to + [PostingRegion.NATION][google.cloud.talent.v4.PostingRegion.NATION] + or + [PostingRegion.ADMINISTRATIVE_AREA][google.cloud.talent.v4.PostingRegion.ADMINISTRATIVE_AREA], + setting job + [Job.addresses][google.cloud.talent.v4.Job.addresses] to the + same location level as this field is strongly recommended. + visibility (google.cloud.talent_v4.types.Visibility): + Deprecated. The job is only visible to the owner. + + The visibility of the job. + + Defaults to + [Visibility.ACCOUNT_ONLY][google.cloud.talent.v4.Visibility.ACCOUNT_ONLY] + if not specified. + job_start_time (google.protobuf.timestamp_pb2.Timestamp): + The start timestamp of the job in UTC time + zone. Typically this field is used for + contracting engagements. Invalid timestamps are + ignored. + job_end_time (google.protobuf.timestamp_pb2.Timestamp): + The end timestamp of the job. Typically this + field is used for contracting engagements. + Invalid timestamps are ignored. + posting_publish_time (google.protobuf.timestamp_pb2.Timestamp): + The timestamp this job posting was most + recently published. The default value is the + time the request arrives at the server. Invalid + timestamps are ignored. + posting_expire_time (google.protobuf.timestamp_pb2.Timestamp): + Strongly recommended for the best service experience. + + The expiration timestamp of the job. After this timestamp, + the job is marked as expired, and it no longer appears in + search results. The expired job can't be listed by the + [ListJobs][google.cloud.talent.v4.JobService.ListJobs] API, + but it can be retrieved with the + [GetJob][google.cloud.talent.v4.JobService.GetJob] API or + updated with the + [UpdateJob][google.cloud.talent.v4.JobService.UpdateJob] API + or deleted with the + [DeleteJob][google.cloud.talent.v4.JobService.DeleteJob] + API. An expired job can be updated and opened again by using + a future expiration timestamp. Updating an expired job fails + if there is another existing open job with same + [company][google.cloud.talent.v4.Job.company], + [language_code][google.cloud.talent.v4.Job.language_code] + and + [requisition_id][google.cloud.talent.v4.Job.requisition_id]. + + The expired jobs are retained in our system for 90 days. + However, the overall expired job count cannot exceed 3 times + the maximum number of open jobs over previous 7 days. If + this threshold is exceeded, expired jobs are cleaned out in + order of earliest expire time. Expired jobs are no longer + accessible after they are cleaned out. + + Invalid timestamps are ignored, and treated as expire time + not provided. + + If the timestamp is before the instant request is made, the + job is treated as expired immediately on creation. This kind + of job can not be updated. And when creating a job with past + timestamp, the + [posting_publish_time][google.cloud.talent.v4.Job.posting_publish_time] + must be set before + [posting_expire_time][google.cloud.talent.v4.Job.posting_expire_time]. + The purpose of this feature is to allow other objects, such + as [Application][], to refer a job that didn't exist in the + system prior to becoming expired. If you want to modify a + job that was expired on creation, delete it and create a new + one. + + If this value isn't provided at the time of job creation or + is invalid, the job posting expires after 30 days from the + job's creation time. For example, if the job was created on + 2017/01/01 13:00AM UTC with an unspecified expiration date, + the job expires after 2017/01/31 13:00AM UTC. + + If this value isn't provided on job update, it depends on + the field masks set by + [UpdateJobRequest.update_mask][google.cloud.talent.v4.UpdateJobRequest.update_mask]. + If the field masks include + [job_end_time][google.cloud.talent.v4.Job.job_end_time], or + the masks are empty meaning that every field is updated, the + job posting expires after 30 days from the job's last update + time. Otherwise the expiration date isn't updated. + posting_create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The timestamp when this job + posting was created. + posting_update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The timestamp when this job + posting was last updated. + company_display_name (str): + Output only. Display name of the company + listing the job. + derived_info (google.cloud.talent_v4.types.Job.DerivedInfo): + Output only. Derived details about the job + posting. + processing_options (google.cloud.talent_v4.types.Job.ProcessingOptions): + Options for job processing. + """ + + class ApplicationInfo(proto.Message): + r"""Application related details of a job posting. + + Attributes: + emails (Sequence[str]): + Use this field to specify email address(es) + to which resumes or applications can be sent. + The maximum number of allowed characters for + each entry is 255. + instruction (str): + Use this field to provide instructions, such + as "Mail your application to ...", that a + candidate can follow to apply for the job. + This field accepts and sanitizes HTML input, and + also accepts bold, italic, ordered list, and + unordered list markup tags. + The maximum number of allowed characters is + 3,000. + uris (Sequence[str]): + Use this URI field to direct an applicant to + a website, for example to link to an online + application form. + The maximum number of allowed characters for + each entry is 2,000. + """ + + emails = proto.RepeatedField( + proto.STRING, + number=1, + ) + instruction = proto.Field( + proto.STRING, + number=2, + ) + uris = proto.RepeatedField( + proto.STRING, + number=3, + ) + + class DerivedInfo(proto.Message): + r"""Derived details about the job posting. + + Attributes: + locations (Sequence[google.cloud.talent_v4.types.Location]): + Structured locations of the job, resolved from + [Job.addresses][google.cloud.talent.v4.Job.addresses]. + + [locations][google.cloud.talent.v4.Job.DerivedInfo.locations] + are exactly matched to + [Job.addresses][google.cloud.talent.v4.Job.addresses] in the + same order. + job_categories (Sequence[google.cloud.talent_v4.types.JobCategory]): + Job categories derived from + [Job.title][google.cloud.talent.v4.Job.title] and + [Job.description][google.cloud.talent.v4.Job.description]. + """ + + locations = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=common.Location, + ) + job_categories = proto.RepeatedField( + proto.ENUM, + number=3, + enum=common.JobCategory, + ) + + class ProcessingOptions(proto.Message): + r"""Options for job processing. + + Attributes: + disable_street_address_resolution (bool): + If set to ``true``, the service does not attempt to resolve + a more precise address for the job. + html_sanitization (google.cloud.talent_v4.types.HtmlSanitization): + Option for job HTML content sanitization. Applied fields + are: + + - description + - applicationInfo.instruction + - incentives + - qualifications + - responsibilities + + HTML tags in these fields may be stripped if sanitiazation + isn't disabled. + + Defaults to + [HtmlSanitization.SIMPLE_FORMATTING_ONLY][google.cloud.talent.v4.HtmlSanitization.SIMPLE_FORMATTING_ONLY]. + """ + + disable_street_address_resolution = proto.Field( + proto.BOOL, + number=1, + ) + html_sanitization = proto.Field( + proto.ENUM, + number=2, + enum=common.HtmlSanitization, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + company = proto.Field( + proto.STRING, + number=2, + ) + requisition_id = proto.Field( + proto.STRING, + number=3, + ) + title = proto.Field( + proto.STRING, + number=4, + ) + description = proto.Field( + proto.STRING, + number=5, + ) + addresses = proto.RepeatedField( + proto.STRING, + number=6, + ) + application_info = proto.Field( + proto.MESSAGE, + number=7, + message=ApplicationInfo, + ) + job_benefits = proto.RepeatedField( + proto.ENUM, + number=8, + enum=common.JobBenefit, + ) + compensation_info = proto.Field( + proto.MESSAGE, + number=9, + message=common.CompensationInfo, + ) + custom_attributes = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=10, + message=common.CustomAttribute, + ) + degree_types = proto.RepeatedField( + proto.ENUM, + number=11, + enum=common.DegreeType, + ) + department = proto.Field( + proto.STRING, + number=12, + ) + employment_types = proto.RepeatedField( + proto.ENUM, + number=13, + enum=common.EmploymentType, + ) + incentives = proto.Field( + proto.STRING, + number=14, + ) + language_code = proto.Field( + proto.STRING, + number=15, + ) + job_level = proto.Field( + proto.ENUM, + number=16, + enum=common.JobLevel, + ) + promotion_value = proto.Field( + proto.INT32, + number=17, + ) + qualifications = proto.Field( + proto.STRING, + number=18, + ) + responsibilities = proto.Field( + proto.STRING, + number=19, + ) + posting_region = proto.Field( + proto.ENUM, + number=20, + enum=common.PostingRegion, + ) + visibility = proto.Field( + proto.ENUM, + number=21, + enum=common.Visibility, + ) + job_start_time = proto.Field( + proto.MESSAGE, + number=22, + message=timestamp_pb2.Timestamp, + ) + job_end_time = proto.Field( + proto.MESSAGE, + number=23, + message=timestamp_pb2.Timestamp, + ) + posting_publish_time = proto.Field( + proto.MESSAGE, + number=24, + message=timestamp_pb2.Timestamp, + ) + posting_expire_time = proto.Field( + proto.MESSAGE, + number=25, + message=timestamp_pb2.Timestamp, + ) + posting_create_time = proto.Field( + proto.MESSAGE, + number=26, + message=timestamp_pb2.Timestamp, + ) + posting_update_time = proto.Field( + proto.MESSAGE, + number=27, + message=timestamp_pb2.Timestamp, + ) + company_display_name = proto.Field( + proto.STRING, + number=28, + ) + derived_info = proto.Field( + proto.MESSAGE, + number=29, + message=DerivedInfo, + ) + processing_options = proto.Field( + proto.MESSAGE, + number=30, + message=ProcessingOptions, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/job_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/job_service.py new file mode 100644 index 00000000..f5a308ee --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/job_service.py @@ -0,0 +1,1126 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import filters +from google.cloud.talent_v4.types import histogram +from google.cloud.talent_v4.types import job as gct_job +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'JobView', + 'CreateJobRequest', + 'GetJobRequest', + 'UpdateJobRequest', + 'DeleteJobRequest', + 'ListJobsRequest', + 'ListJobsResponse', + 'SearchJobsRequest', + 'SearchJobsResponse', + 'BatchCreateJobsRequest', + 'BatchUpdateJobsRequest', + 'BatchDeleteJobsRequest', + 'JobResult', + 'BatchCreateJobsResponse', + 'BatchUpdateJobsResponse', + 'BatchDeleteJobsResponse', + }, +) + + +class JobView(proto.Enum): + r"""An enum that specifies the job attributes that are returned in the + [MatchingJob.job][google.cloud.talent.v4.SearchJobsResponse.MatchingJob.job] + or + [ListJobsResponse.jobs][google.cloud.talent.v4.ListJobsResponse.jobs] + fields. + """ + JOB_VIEW_UNSPECIFIED = 0 + JOB_VIEW_ID_ONLY = 1 + JOB_VIEW_MINIMAL = 2 + JOB_VIEW_SMALL = 3 + JOB_VIEW_FULL = 4 + + +class CreateJobRequest(proto.Message): + r"""Create job request. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenants/bar". + job (google.cloud.talent_v4.types.Job): + Required. The Job to be created. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + job = proto.Field( + proto.MESSAGE, + number=2, + message=gct_job.Job, + ) + + +class GetJobRequest(proto.Message): + r"""Get job request. + + Attributes: + name (str): + Required. The resource name of the job to retrieve. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateJobRequest(proto.Message): + r"""Update job request. + + Attributes: + job (google.cloud.talent_v4.types.Job): + Required. The Job to be updated. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Strongly recommended for the best service experience. + + If + [update_mask][google.cloud.talent.v4.UpdateJobRequest.update_mask] + is provided, only the specified fields in + [job][google.cloud.talent.v4.UpdateJobRequest.job] are + updated. Otherwise all the fields are updated. + + A field mask to restrict the fields that are updated. Only + top level fields of [Job][google.cloud.talent.v4.Job] are + supported. + """ + + job = proto.Field( + proto.MESSAGE, + number=1, + message=gct_job.Job, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteJobRequest(proto.Message): + r"""Delete job request. + + Attributes: + name (str): + Required. The resource name of the job to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListJobsRequest(proto.Message): + r"""List jobs request. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenants/bar". + filter (str): + Required. The filter string specifies the jobs to be + enumerated. + + Supported operator: =, AND + + The fields eligible for filtering are: + + - ``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" + - requisitionId = "req-1" + - requisitionId = "req-1" AND status = "EXPIRED". + page_token (str): + The starting point of a query result. + page_size (int): + The maximum number of jobs to be returned per page of + results. + + If + [job_view][google.cloud.talent.v4.ListJobsRequest.job_view] + is set to + [JobView.JOB_VIEW_ID_ONLY][google.cloud.talent.v4.JobView.JOB_VIEW_ID_ONLY], + the maximum allowed page size is 1000. Otherwise, the + maximum allowed page size is 100. + + Default is 100 if empty or a number < 1 is specified. + job_view (google.cloud.talent_v4.types.JobView): + The desired job attributes returned for jobs in the search + response. Defaults to + [JobView.JOB_VIEW_FULL][google.cloud.talent.v4.JobView.JOB_VIEW_FULL] + if no value is specified. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + page_size = proto.Field( + proto.INT32, + number=4, + ) + job_view = proto.Field( + proto.ENUM, + number=5, + enum='JobView', + ) + + +class ListJobsResponse(proto.Message): + r"""List jobs response. + + Attributes: + jobs (Sequence[google.cloud.talent_v4.types.Job]): + The Jobs for a given company. + The maximum number of items returned is based on + the limit field provided in the request. + next_page_token (str): + A token to retrieve the next page of results. + metadata (google.cloud.talent_v4.types.ResponseMetadata): + Additional information for the API + invocation, such as the request tracking id. + """ + + @property + def raw_page(self): + return self + + jobs = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_job.Job, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + metadata = proto.Field( + proto.MESSAGE, + number=3, + message=common.ResponseMetadata, + ) + + +class SearchJobsRequest(proto.Message): + r"""The Request body of the ``SearchJobs`` 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". + search_mode (google.cloud.talent_v4.types.SearchJobsRequest.SearchMode): + Mode of a search. + + Defaults to + [SearchMode.JOB_SEARCH][google.cloud.talent.v4.SearchJobsRequest.SearchMode.JOB_SEARCH]. + request_metadata (google.cloud.talent_v4.types.RequestMetadata): + Required. The meta information collected about the job + searcher, used to improve the search quality of the service. + The identifiers (such as ``user_id``) are provided by users, + and must be unique and consistent. + job_query (google.cloud.talent_v4.types.JobQuery): + Query used to search against jobs, such as + keyword, location filters, etc. + enable_broadening (bool): + Controls whether to broaden the search when + it produces sparse results. Broadened queries + append results to the end of the matching + results list. + + Defaults to false. + histogram_queries (Sequence[google.cloud.talent_v4.types.HistogramQuery]): + An expression specifies a histogram request against matching + jobs. + + Expression syntax is an aggregation function call with + histogram facets and other options. + + Available aggregation function calls are: + + - ``count(string_histogram_facet)``: Count the number of + matching entities, for each distinct attribute value. + - ``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 + ``[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 built-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). + + Job histogram facets: + + - company_display_name: histogram by + [Job.company_display_name][google.cloud.talent.v4.Job.company_display_name]. + - employment_type: histogram by + [Job.employment_types][google.cloud.talent.v4.Job.employment_types], + for example, "FULL_TIME", "PART_TIME". + - company_size: histogram by + [CompanySize][google.cloud.talent.v4.CompanySize], for + example, "SMALL", "MEDIUM", "BIG". + - publish_time_in_day: histogram by the + [Job.posting_publish_time][google.cloud.talent.v4.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.v4.Job.posting_publish_time] + in months. Must specify list of numeric buckets in spec. + - publish_time_in_year: histogram by the + [Job.posting_publish_time][google.cloud.talent.v4.Job.posting_publish_time] + in years. Must specify list of numeric buckets in spec. + - degree_types: histogram by the + [Job.degree_types][google.cloud.talent.v4.Job.degree_types], + for example, "Bachelors", "Masters". + - job_level: histogram by the + [Job.job_level][google.cloud.talent.v4.Job.job_level], + for example, "Entry Level". + - country: histogram by the country code of jobs, for + example, "US", "FR". + - admin1: histogram by the admin1 code of jobs, which is a + global placeholder referring to the state, province, or + the particular term a country uses to define the + geographic structure below the country level, for + example, "CA", "IL". + - city: histogram by a combination of the "city name, + admin1 code". For example, "Mountain View, CA", "New + York, NY". + - admin1_country: histogram by a combination of the "admin1 + code, country", for example, "CA, US", "IL, US". + - city_coordinate: histogram by the city center's GPS + coordinates (latitude and longitude), for example, + 37.4038522,-122.0987765. Since the coordinates of a city + center can change, customers may need to refresh them + periodically. + - locale: histogram by the + [Job.language_code][google.cloud.talent.v4.Job.language_code], + for example, "en-US", "fr-FR". + - language: histogram by the language subtag of the + [Job.language_code][google.cloud.talent.v4.Job.language_code], + for example, "en", "fr". + - category: histogram by the + [JobCategory][google.cloud.talent.v4.JobCategory], for + example, "COMPUTER_AND_IT", "HEALTHCARE". + - base_compensation_unit: histogram by the + [CompensationInfo.CompensationUnit][google.cloud.talent.v4.CompensationInfo.CompensationUnit] + of base salary, for example, "WEEKLY", "MONTHLY". + - base_compensation: histogram by the base salary. Must + specify list of numeric buckets to group results by. + - annualized_base_compensation: histogram by the base + annualized salary. Must specify list of numeric buckets + to group results by. + - annualized_total_compensation: histogram by the total + annualized salary. Must specify list of numeric buckets + to group results by. + - string_custom_attribute: histogram by string + [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes]. + Values can be accessed via square bracket notations like + string_custom_attribute["key1"]. + - numeric_custom_attribute: histogram by numeric + [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes]. + Values can be accessed via square bracket notations like + numeric_custom_attribute["key1"]. Must specify list of + numeric buckets to group results by. + + Example expressions: + + - ``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")])`` + job_view (google.cloud.talent_v4.types.JobView): + The desired job attributes returned for jobs in the search + response. Defaults to + [JobView.JOB_VIEW_SMALL][google.cloud.talent.v4.JobView.JOB_VIEW_SMALL] + if no value is specified. + offset (int): + An integer that specifies the current offset (that is, + starting result location, amongst the jobs deemed by the API + as relevant) in search results. This field is only + considered if + [page_token][google.cloud.talent.v4.SearchJobsRequest.page_token] + is unset. + + The maximum allowed value is 5000. Otherwise an error is + thrown. + + For example, 0 means to return results starting from the + first matching job, and 10 means to return from the 11th + job. This can be used for pagination, (for example, pageSize + = 10 and offset = 10 means to return from the second page). + max_page_size (int): + A limit on the number of jobs returned in the + search results. Increasing this value above the + default value of 10 can increase search response + time. The value can be between 1 and 100. + page_token (str): + The token specifying the current offset within search + results. See + [SearchJobsResponse.next_page_token][google.cloud.talent.v4.SearchJobsResponse.next_page_token] + for an explanation of how to obtain the next set of query + results. + order_by (str): + The criteria determining how search results are sorted. + Default is ``"relevance desc"``. + + Supported options are: + + - ``"relevance desc"``: By relevance descending, as + determined by the API algorithms. Relevance thresholding + of query results is only available with this ordering. + - ``"posting_publish_time desc"``: By + [Job.posting_publish_time][google.cloud.talent.v4.Job.posting_publish_time] + descending. + - ``"posting_update_time desc"``: By + [Job.posting_update_time][google.cloud.talent.v4.Job.posting_update_time] + descending. + - ``"title"``: By + [Job.title][google.cloud.talent.v4.Job.title] ascending. + - ``"title desc"``: By + [Job.title][google.cloud.talent.v4.Job.title] descending. + - ``"annualized_base_compensation"``: By job's + [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range] + ascending. Jobs whose annualized base compensation is + unspecified are put at the end of search results. + - ``"annualized_base_compensation desc"``: By job's + [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range] + descending. Jobs whose annualized base compensation is + unspecified are put at the end of search results. + - ``"annualized_total_compensation"``: By job's + [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range] + ascending. Jobs whose annualized base compensation is + unspecified are put at the end of search results. + - ``"annualized_total_compensation desc"``: By job's + [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range] + descending. Jobs whose annualized base compensation is + unspecified are put at the end of search results. + - ``"custom_ranking desc"``: By the relevance score + adjusted to the + [SearchJobsRequest.CustomRankingInfo.ranking_expression][google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression] + with weight factor assigned by + [SearchJobsRequest.CustomRankingInfo.importance_level][google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.importance_level] + in descending order. + - Location sorting: Use the special syntax to order jobs by + distance: ``"distance_from('Hawaii')"``: Order by + distance from Hawaii. ``"distance_from(19.89, 155.5)"``: + Order by distance from a coordinate. + ``"distance_from('Hawaii'), distance_from('Puerto Rico')"``: + Order by multiple locations. See details below. + ``"distance_from('Hawaii'), distance_from(19.89, 155.5)"``: + Order by multiple locations. See details below. The + string can have a maximum of 256 characters. When + multiple distance centers are provided, a job that is + close to any of the distance centers would have a high + rank. When a job has multiple locations, the job location + closest to one of the distance centers will be used. Jobs + that don't have locations will be ranked at the bottom. + Distance is calculated with a precision of 11.3 meters + (37.4 feet). Diversification strategy is still applied + unless explicitly disabled in + [diversification_level][google.cloud.talent.v4.SearchJobsRequest.diversification_level]. + diversification_level (google.cloud.talent_v4.types.SearchJobsRequest.DiversificationLevel): + Controls whether highly similar jobs are returned next to + each other in the search results. Jobs are identified as + highly similar based on their titles, job categories, and + locations. Highly similar results are clustered so that only + one representative job of the cluster is displayed to the + job seeker higher up in the results, with the other jobs + being displayed lower down in the results. + + Defaults to + [DiversificationLevel.SIMPLE][google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel.SIMPLE] + if no value is specified. + custom_ranking_info (google.cloud.talent_v4.types.SearchJobsRequest.CustomRankingInfo): + Controls over how job documents get ranked on + 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.v4.SearchJobsRequest.keyword_match_mode] + going forward. + + To migrate, disable_keyword_match set to false maps to + [KeywordMatchMode.KEYWORD_MATCH_ALL][google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL], + and disable_keyword_match set to true maps to + [KeywordMatchMode.KEYWORD_MATCH_DISABLED][google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED]. + If + [SearchJobsRequest.keyword_match_mode][google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode] + is set, this field is ignored. + + Controls whether to disable exact keyword match on + [Job.title][google.cloud.talent.v4.Job.title], + [Job.description][google.cloud.talent.v4.Job.description], + [Job.company_display_name][google.cloud.talent.v4.Job.company_display_name], + [Job.addresses][google.cloud.talent.v4.Job.addresses], + [Job.qualifications][google.cloud.talent.v4.Job.qualifications]. + When disable keyword match is turned off, a keyword match + returns jobs that do not match given category filters when + there are matching keywords. For example, for the query + "program manager," a result is returned even if the job + posting has the title "software developer," which doesn't + fall into "program manager" ontology, but does have "program + manager" appearing in its description. + + For queries like "cloud" that don't contain title or + location specific ontology, jobs with "cloud" keyword + matches are returned regardless of this flag's value. + + Use + [Company.keyword_searchable_job_custom_attributes][google.cloud.talent.v4.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. + + Defaults to false. + keyword_match_mode (google.cloud.talent_v4.types.SearchJobsRequest.KeywordMatchMode): + Controls what keyword match options to use. If both + keyword_match_mode and disable_keyword_match are set, + keyword_match_mode will take precedence. + + Defaults to + [KeywordMatchMode.KEYWORD_MATCH_ALL][google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL] + if no value is specified. + """ + class SearchMode(proto.Enum): + r"""A string-represented enumeration of the job search mode. The + service operate differently for different modes of service. + """ + SEARCH_MODE_UNSPECIFIED = 0 + JOB_SEARCH = 1 + FEATURED_JOB_SEARCH = 2 + + class DiversificationLevel(proto.Enum): + r"""Controls whether highly similar jobs are returned next to + each other in the search results. Jobs are identified as highly + similar based on their titles, job categories, and locations. + Highly similar results are clustered so that only one + representative job of the cluster is displayed to the job seeker + higher up in the results, with the other jobs being displayed + lower down in the results. + + If you are using pageToken to page through the result set, + latency might be lower but we can't guarantee that all results + are returned. If you are using page offset, latency might be + higher but all results are returned. + """ + DIVERSIFICATION_LEVEL_UNSPECIFIED = 0 + DISABLED = 1 + SIMPLE = 2 + ONE_PER_COMPANY = 3 + TWO_PER_COMPANY = 4 + DIVERSIFY_BY_LOOSER_SIMILARITY = 5 + + 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.v4.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.v4.SearchJobsRequest]. + + Attributes: + importance_level (google.cloud.talent_v4.types.SearchJobsRequest.CustomRankingInfo.ImportanceLevel): + Required. Controls over how important the score of + [CustomRankingInfo.ranking_expression][google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression] + gets applied to job's final ranking position. + + An error is thrown if not specified. + ranking_expression (str): + Required. Controls over how job documents get ranked on top + of existing relevance score (determined by API algorithm). A + combination of the ranking expression and relevance score is + used to determine job's final ranking position. + + The syntax for this expression is a subset of Google SQL + syntax. + + Supported operators are: +, -, \*, /, where the left and + right side of the operator is either a numeric + [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes] + key, integer/double value or an expression that can be + evaluated to a number. + + Parenthesis are supported to adjust calculation precedence. + 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 + populated on the job or if the expression results in a + divide by zero. If an expression is invalid for a job, that + job is demoted to the end of the results. + + Sample ranking expression (year + 25) \* 0.25 - (freshness / + 0.5) + """ + class ImportanceLevel(proto.Enum): + r"""The importance level for + [CustomRankingInfo.ranking_expression][google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression]. + """ + IMPORTANCE_LEVEL_UNSPECIFIED = 0 + NONE = 1 + LOW = 2 + MILD = 3 + MEDIUM = 4 + HIGH = 5 + EXTREME = 6 + + importance_level = proto.Field( + proto.ENUM, + number=1, + enum='SearchJobsRequest.CustomRankingInfo.ImportanceLevel', + ) + ranking_expression = proto.Field( + proto.STRING, + number=2, + ) + + parent = proto.Field( + proto.STRING, + number=1, + ) + search_mode = proto.Field( + proto.ENUM, + number=2, + enum=SearchMode, + ) + request_metadata = proto.Field( + proto.MESSAGE, + number=3, + message=common.RequestMetadata, + ) + job_query = proto.Field( + proto.MESSAGE, + number=4, + message=filters.JobQuery, + ) + enable_broadening = proto.Field( + proto.BOOL, + number=5, + ) + histogram_queries = proto.RepeatedField( + proto.MESSAGE, + number=7, + message=histogram.HistogramQuery, + ) + job_view = proto.Field( + proto.ENUM, + number=8, + enum='JobView', + ) + offset = proto.Field( + proto.INT32, + number=9, + ) + max_page_size = proto.Field( + proto.INT32, + number=10, + ) + page_token = proto.Field( + proto.STRING, + number=11, + ) + order_by = proto.Field( + proto.STRING, + number=12, + ) + diversification_level = proto.Field( + proto.ENUM, + number=13, + enum=DiversificationLevel, + ) + custom_ranking_info = proto.Field( + proto.MESSAGE, + number=14, + message=CustomRankingInfo, + ) + disable_keyword_match = proto.Field( + proto.BOOL, + number=16, + ) + keyword_match_mode = proto.Field( + proto.ENUM, + number=18, + enum=KeywordMatchMode, + ) + + +class SearchJobsResponse(proto.Message): + r"""Response for SearchJob method. + + Attributes: + matching_jobs (Sequence[google.cloud.talent_v4.types.SearchJobsResponse.MatchingJob]): + The Job entities that match the specified + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + histogram_query_results (Sequence[google.cloud.talent_v4.types.HistogramQueryResult]): + The histogram results that match with specified + [SearchJobsRequest.histogram_queries][google.cloud.talent.v4.SearchJobsRequest.histogram_queries]. + next_page_token (str): + The token that specifies the starting + position of the next page of results. This field + is empty if there are no more results. + location_filters (Sequence[google.cloud.talent_v4.types.Location]): + The location filters that the service applied to the + specified query. If any filters are lat-lng based, the + [Location.location_type][google.cloud.talent.v4.Location.location_type] + is + [Location.LocationType.LOCATION_TYPE_UNSPECIFIED][google.cloud.talent.v4.Location.LocationType.LOCATION_TYPE_UNSPECIFIED]. + total_size (int): + Number of jobs that match the specified + query. + Note: This size is precise only if the total is + less than 100,000. + metadata (google.cloud.talent_v4.types.ResponseMetadata): + Additional information for the API + invocation, such as the request tracking id. + broadened_query_jobs_count (int): + If query broadening is enabled, we may append + additional results from the broadened query. + This number indicates how many of the jobs + returned in the jobs field are from the + broadened query. These results are always at the + end of the jobs list. In particular, a value of + 0, or if the field isn't set, all the jobs in + the jobs list are from the original (without + broadening) query. If this field is non-zero, + subsequent requests with offset after this + result set should contain all broadened results. + spell_correction (google.cloud.talent_v4.types.SpellingCorrection): + The spell checking result, and correction. + """ + + class MatchingJob(proto.Message): + r"""Job entry with metadata inside + [SearchJobsResponse][google.cloud.talent.v4.SearchJobsResponse]. + + Attributes: + job (google.cloud.talent_v4.types.Job): + Job resource that matches the specified + [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + job_summary (str): + A summary of the job with core information + that's displayed on the search results listing + page. + job_title_snippet (str): + Contains snippets of text from the + [Job.title][google.cloud.talent.v4.Job.title] field most + closely matching a search query's keywords, if available. + The matching query keywords are enclosed in HTML bold tags. + search_text_snippet (str): + Contains snippets of text from the + [Job.description][google.cloud.talent.v4.Job.description] + and similar fields that most closely match a search query's + keywords, if available. All HTML tags in the original fields + are stripped when returned in this field, and matching query + keywords are enclosed in HTML bold tags. + commute_info (google.cloud.talent_v4.types.SearchJobsResponse.CommuteInfo): + Commute information which is generated based on specified + [CommuteFilter][google.cloud.talent.v4.CommuteFilter]. + """ + + job = proto.Field( + proto.MESSAGE, + number=1, + message=gct_job.Job, + ) + job_summary = proto.Field( + proto.STRING, + number=2, + ) + job_title_snippet = proto.Field( + proto.STRING, + number=3, + ) + search_text_snippet = proto.Field( + proto.STRING, + number=4, + ) + commute_info = proto.Field( + proto.MESSAGE, + number=5, + message='SearchJobsResponse.CommuteInfo', + ) + + class CommuteInfo(proto.Message): + r"""Commute details related to this job. + + Attributes: + job_location (google.cloud.talent_v4.types.Location): + Location used as the destination in the + commute calculation. + travel_duration (google.protobuf.duration_pb2.Duration): + The number of seconds required to travel to + the job location from the query location. A + duration of 0 seconds indicates that the job + isn't reachable within the requested duration, + but was returned as part of an expanded query. + """ + + job_location = proto.Field( + proto.MESSAGE, + number=1, + message=common.Location, + ) + travel_duration = proto.Field( + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, + ) + + @property + def raw_page(self): + return self + + matching_jobs = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=MatchingJob, + ) + histogram_query_results = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=histogram.HistogramQueryResult, + ) + next_page_token = proto.Field( + proto.STRING, + number=3, + ) + location_filters = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=common.Location, + ) + total_size = proto.Field( + proto.INT32, + number=6, + ) + metadata = proto.Field( + proto.MESSAGE, + number=7, + message=common.ResponseMetadata, + ) + broadened_query_jobs_count = proto.Field( + proto.INT32, + number=8, + ) + spell_correction = proto.Field( + proto.MESSAGE, + number=9, + message=common.SpellingCorrection, + ) + + +class BatchCreateJobsRequest(proto.Message): + r"""Request to create a batch of jobs. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenants/bar". + jobs (Sequence[google.cloud.talent_v4.types.Job]): + Required. The jobs to be created. + A maximum of 200 jobs can be created in a batch. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + jobs = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=gct_job.Job, + ) + + +class BatchUpdateJobsRequest(proto.Message): + r"""Request to update a batch of jobs. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenants/bar". + jobs (Sequence[google.cloud.talent_v4.types.Job]): + Required. The jobs to be updated. + A maximum of 200 jobs can be updated in a batch. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Strongly recommended for the best service experience. Be + aware that it will also increase latency when checking the + status of a batch operation. + + If + [update_mask][google.cloud.talent.v4.BatchUpdateJobsRequest.update_mask] + is provided, only the specified fields in + [Job][google.cloud.talent.v4.Job] are updated. Otherwise all + the fields are updated. + + A field mask to restrict the fields that are updated. Only + top level fields of [Job][google.cloud.talent.v4.Job] are + supported. + + If + [update_mask][google.cloud.talent.v4.BatchUpdateJobsRequest.update_mask] + is provided, The [Job][google.cloud.talent.v4.Job] inside + [JobResult][JobOperationResult.JobResult] will only contains + fields that is updated, plus the Id of the Job. Otherwise, + [Job][google.cloud.talent.v4.Job] will include all fields, + which can yield a very large response. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + jobs = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=gct_job.Job, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=3, + message=field_mask_pb2.FieldMask, + ) + + +class BatchDeleteJobsRequest(proto.Message): + r"""Request to delete a batch of jobs. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenants/bar". + + The parent of all of the jobs specified in ``names`` must + match this field. + names (Sequence[str]): + The names of the jobs to delete. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + A maximum of 200 jobs can be deleted in a batch. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + names = proto.RepeatedField( + proto.STRING, + number=2, + ) + + +class JobResult(proto.Message): + r"""Mutation result of a job from a batch operation. + + Attributes: + job (google.cloud.talent_v4.types.Job): + Here [Job][google.cloud.talent.v4.Job] only contains basic + information including + [name][google.cloud.talent.v4.Job.name], + [company][google.cloud.talent.v4.Job.company], + [language_code][google.cloud.talent.v4.Job.language_code] + and + [requisition_id][google.cloud.talent.v4.Job.requisition_id], + use getJob method to retrieve detailed information of the + created/updated job. + status (google.rpc.status_pb2.Status): + The status of the job processed. This field is populated if + the processing of the + [job][google.cloud.talent.v4.JobResult.job] fails. + """ + + job = proto.Field( + proto.MESSAGE, + number=1, + message=gct_job.Job, + ) + status = proto.Field( + proto.MESSAGE, + number=2, + message=status_pb2.Status, + ) + + +class BatchCreateJobsResponse(proto.Message): + r"""The result of + [JobService.BatchCreateJobs][google.cloud.talent.v4.JobService.BatchCreateJobs]. + It's used to replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + Attributes: + job_results (Sequence[google.cloud.talent_v4.types.JobResult]): + List of job mutation results from a batch + create operation. It can change until operation + status is FINISHED, FAILED or CANCELLED. + """ + + job_results = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='JobResult', + ) + + +class BatchUpdateJobsResponse(proto.Message): + r"""The result of + [JobService.BatchUpdateJobs][google.cloud.talent.v4.JobService.BatchUpdateJobs]. + It's used to replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + Attributes: + job_results (Sequence[google.cloud.talent_v4.types.JobResult]): + List of job mutation results from a batch + update operation. It can change until operation + status is FINISHED, FAILED or CANCELLED. + """ + + job_results = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='JobResult', + ) + + +class BatchDeleteJobsResponse(proto.Message): + r"""The result of + [JobService.BatchDeleteJobs][google.cloud.talent.v4.JobService.BatchDeleteJobs]. + It's used to replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + Attributes: + job_results (Sequence[google.cloud.talent_v4.types.JobResult]): + List of job mutation results from a batch + delete operation. It can change until operation + status is FINISHED, FAILED or CANCELLED. + """ + + job_results = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='JobResult', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant.py new file mode 100644 index 00000000..c4f3349a --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant.py @@ -0,0 +1,58 @@ +# -*- 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 proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'Tenant', + }, +) + + +class Tenant(proto.Message): + r"""A Tenant resource represents a tenant in the service. A + tenant is a group or entity that shares common access with + specific privileges for resources like jobs. Customer may create + multiple tenants to provide data isolation for different groups. + + Attributes: + name (str): + Required during tenant update. + + The resource name for a tenant. This is generated by the + service when a tenant is created. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + external_id (str): + Required. Client side tenant identifier, used + to uniquely identify the tenant. + The maximum number of allowed characters is 255. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + external_id = proto.Field( + proto.STRING, + number=2, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant_service.py new file mode 100644 index 00000000..27492553 --- /dev/null +++ b/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant_service.py @@ -0,0 +1,194 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import tenant as gct_tenant +from google.protobuf import field_mask_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4', + manifest={ + 'CreateTenantRequest', + 'GetTenantRequest', + 'UpdateTenantRequest', + 'DeleteTenantRequest', + 'ListTenantsRequest', + 'ListTenantsResponse', + }, +) + + +class CreateTenantRequest(proto.Message): + r"""The Request of the CreateTenant method. + + Attributes: + parent (str): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + tenant (google.cloud.talent_v4.types.Tenant): + Required. The tenant to be created. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + tenant = proto.Field( + proto.MESSAGE, + number=2, + message=gct_tenant.Tenant, + ) + + +class GetTenantRequest(proto.Message): + r"""Request for getting a tenant by name. + + Attributes: + name (str): + Required. The resource name of the tenant to be retrieved. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateTenantRequest(proto.Message): + r"""Request for updating a specified tenant. + + Attributes: + tenant (google.cloud.talent_v4.types.Tenant): + Required. The tenant 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.v4.UpdateTenantRequest.update_mask] + is provided, only the specified fields in + [tenant][google.cloud.talent.v4.UpdateTenantRequest.tenant] + are updated. Otherwise all the fields are updated. + + A field mask to specify the tenant fields to be updated. + Only top level fields of + [Tenant][google.cloud.talent.v4.Tenant] are supported. + """ + + tenant = proto.Field( + proto.MESSAGE, + number=1, + message=gct_tenant.Tenant, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteTenantRequest(proto.Message): + r"""Request to delete a tenant. + + Attributes: + name (str): + Required. The resource name of the tenant to be deleted. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListTenantsRequest(proto.Message): + r"""List tenants for which the client has ACL visibility. + + Attributes: + parent (str): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + page_token (str): + The starting indicator from which to return + results. + page_size (int): + The maximum number of tenants 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 ListTenantsResponse(proto.Message): + r"""The List tenants response object. + + Attributes: + tenants (Sequence[google.cloud.talent_v4.types.Tenant]): + Tenants for the current client. + next_page_token (str): + A token to retrieve the next page of results. + metadata (google.cloud.talent_v4.types.ResponseMetadata): + Additional information for the API + invocation, such as the request tracking id. + """ + + @property + def raw_page(self): + return self + + tenants = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_tenant.Tenant, + ) + 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/owl-bot-staging/v4/mypy.ini b/owl-bot-staging/v4/mypy.ini new file mode 100644 index 00000000..574c5aed --- /dev/null +++ b/owl-bot-staging/v4/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.7 +namespace_packages = True diff --git a/owl-bot-staging/v4/noxfile.py b/owl-bot-staging/v4/noxfile.py new file mode 100644 index 00000000..68bf7fef --- /dev/null +++ b/owl-bot-staging/v4/noxfile.py @@ -0,0 +1,179 @@ +# -*- 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 +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +ALL_PYTHON = [ + "3.7", + "3.8", + "3.9", + "3.10", +] + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + +BLACK_VERSION = "black==22.3.0" +BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] +DEFAULT_PYTHON_VERSION = "3.10" + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", + "blacken", + "lint", + "lint_setup_py", +] + +@nox.session(python=ALL_PYTHON) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/talent_v4/', + '--cov=tests/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + 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", "erase") + + +@nox.session(python=ALL_PYTHON) +def mypy(session): + """Run the type checker.""" + session.install('mypy', 'types-pkg_resources') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx==4.0.1", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint(session): + """Run linters. + + Returns a failure if the linters find linting errors or sufficiently + serious code quality issues. + """ + session.install("flake8", BLACK_VERSION) + session.run( + "black", + "--check", + *BLACK_PATHS, + ) + session.run("flake8", "google", "tests", "samples") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def blacken(session): + """Run black. Format code to uniform standard.""" + session.install(BLACK_VERSION) + session.run( + "black", + *BLACK_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint_setup_py(session): + """Verify that setup.py is valid (including RST check).""" + session.install("docutils", "pygments") + session.run("python", "setup.py", "check", "--restructuredtext", "--strict") diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py new file mode 100644 index 00000000..3d8f0347 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py @@ -0,0 +1,57 @@ +# -*- 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 CreateCompany +# 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_v4_generated_CompanyService_CreateCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_create_company(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + company = talent_v4.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4.CreateCompanyRequest( + parent="parent_value", + company=company, + ) + + # Make the request + response = await client.create_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_CompanyService_CreateCompany_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py new file mode 100644 index 00000000..27af7ae7 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py @@ -0,0 +1,57 @@ +# -*- 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 CreateCompany +# 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_v4_generated_CompanyService_CreateCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_create_company(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + company = talent_v4.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4.CreateCompanyRequest( + parent="parent_value", + company=company, + ) + + # Make the request + response = client.create_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_CompanyService_CreateCompany_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py new file mode 100644 index 00000000..caa9c658 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteCompany +# 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_v4_generated_CompanyService_DeleteCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_delete_company(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.DeleteCompanyRequest( + name="name_value", + ) + + # Make the request + await client.delete_company(request=request) + + +# [END jobs_v4_generated_CompanyService_DeleteCompany_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py new file mode 100644 index 00000000..b2340952 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteCompany +# 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_v4_generated_CompanyService_DeleteCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_delete_company(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4.DeleteCompanyRequest( + name="name_value", + ) + + # Make the request + client.delete_company(request=request) + + +# [END jobs_v4_generated_CompanyService_DeleteCompany_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py new file mode 100644 index 00000000..413260e0 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py @@ -0,0 +1,52 @@ +# -*- 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 GetCompany +# 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_v4_generated_CompanyService_GetCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_get_company(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.GetCompanyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_CompanyService_GetCompany_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py new file mode 100644 index 00000000..d7a20735 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py @@ -0,0 +1,52 @@ +# -*- 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 GetCompany +# 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_v4_generated_CompanyService_GetCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_get_company(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4.GetCompanyRequest( + name="name_value", + ) + + # Make the request + response = client.get_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_CompanyService_GetCompany_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py new file mode 100644 index 00000000..acfa5f8c --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py @@ -0,0 +1,53 @@ +# -*- 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 ListCompanies +# 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_v4_generated_CompanyService_ListCompanies_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_list_companies(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.ListCompaniesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_companies(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END jobs_v4_generated_CompanyService_ListCompanies_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py new file mode 100644 index 00000000..8fc4f9a4 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py @@ -0,0 +1,53 @@ +# -*- 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 ListCompanies +# 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_v4_generated_CompanyService_ListCompanies_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_list_companies(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4.ListCompaniesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_companies(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END jobs_v4_generated_CompanyService_ListCompanies_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py new file mode 100644 index 00000000..15895bf7 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py @@ -0,0 +1,56 @@ +# -*- 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 UpdateCompany +# 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_v4_generated_CompanyService_UpdateCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_update_company(): + # Create a client + client = talent_v4.CompanyServiceAsyncClient() + + # Initialize request argument(s) + company = talent_v4.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4.UpdateCompanyRequest( + company=company, + ) + + # Make the request + response = await client.update_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_CompanyService_UpdateCompany_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py new file mode 100644 index 00000000..f382f1d7 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py @@ -0,0 +1,56 @@ +# -*- 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 UpdateCompany +# 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_v4_generated_CompanyService_UpdateCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_update_company(): + # Create a client + client = talent_v4.CompanyServiceClient() + + # Initialize request argument(s) + company = talent_v4.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4.UpdateCompanyRequest( + company=company, + ) + + # Make the request + response = client.update_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_CompanyService_UpdateCompany_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py new file mode 100644 index 00000000..9e06a6b2 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py @@ -0,0 +1,54 @@ +# -*- 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 CompleteQuery +# 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_v4_generated_Completion_CompleteQuery_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_complete_query(): + # Create a client + client = talent_v4.CompletionAsyncClient() + + # Initialize request argument(s) + request = talent_v4.CompleteQueryRequest( + tenant="tenant_value", + query="query_value", + page_size=951, + ) + + # Make the request + response = await client.complete_query(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_Completion_CompleteQuery_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py new file mode 100644 index 00000000..8859bc96 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py @@ -0,0 +1,54 @@ +# -*- 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 CompleteQuery +# 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_v4_generated_Completion_CompleteQuery_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_complete_query(): + # Create a client + client = talent_v4.CompletionClient() + + # Initialize request argument(s) + request = talent_v4.CompleteQueryRequest( + tenant="tenant_value", + query="query_value", + page_size=951, + ) + + # Make the request + response = client.complete_query(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_Completion_CompleteQuery_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py new file mode 100644 index 00000000..cbb8a812 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py @@ -0,0 +1,58 @@ +# -*- 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 CreateClientEvent +# 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_v4_generated_EventService_CreateClientEvent_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_create_client_event(): + # Create a client + client = talent_v4.EventServiceAsyncClient() + + # Initialize request argument(s) + client_event = talent_v4.ClientEvent() + client_event.job_event.type_ = "INTERVIEW_GRANTED" + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] + client_event.event_id = "event_id_value" + + request = talent_v4.CreateClientEventRequest( + parent="parent_value", + client_event=client_event, + ) + + # Make the request + response = await client.create_client_event(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_EventService_CreateClientEvent_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py new file mode 100644 index 00000000..21337ce6 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py @@ -0,0 +1,58 @@ +# -*- 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 CreateClientEvent +# 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_v4_generated_EventService_CreateClientEvent_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_create_client_event(): + # Create a client + client = talent_v4.EventServiceClient() + + # Initialize request argument(s) + client_event = talent_v4.ClientEvent() + client_event.job_event.type_ = "INTERVIEW_GRANTED" + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] + client_event.event_id = "event_id_value" + + request = talent_v4.CreateClientEventRequest( + parent="parent_value", + client_event=client_event, + ) + + # Make the request + response = client.create_client_event(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_EventService_CreateClientEvent_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py new file mode 100644 index 00000000..489582dd --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py @@ -0,0 +1,63 @@ +# -*- 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 BatchCreateJobs +# 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_v4_generated_JobService_BatchCreateJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_batch_create_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + jobs = talent_v4.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4.BatchCreateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_create_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_BatchCreateJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py new file mode 100644 index 00000000..b6d2524a --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py @@ -0,0 +1,63 @@ +# -*- 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 BatchCreateJobs +# 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_v4_generated_JobService_BatchCreateJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_batch_create_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + jobs = talent_v4.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4.BatchCreateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_create_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_BatchCreateJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py new file mode 100644 index 00000000..3fc26c7d --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py @@ -0,0 +1,56 @@ +# -*- 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 BatchDeleteJobs +# 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_v4_generated_JobService_BatchDeleteJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_batch_delete_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.BatchDeleteJobsRequest( + parent="parent_value", + ) + + # Make the request + operation = client.batch_delete_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_BatchDeleteJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py new file mode 100644 index 00000000..d9be665a --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py @@ -0,0 +1,56 @@ +# -*- 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 BatchDeleteJobs +# 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_v4_generated_JobService_BatchDeleteJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_batch_delete_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.BatchDeleteJobsRequest( + parent="parent_value", + ) + + # Make the request + operation = client.batch_delete_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_BatchDeleteJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py new file mode 100644 index 00000000..780f7ddd --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py @@ -0,0 +1,63 @@ +# -*- 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 BatchUpdateJobs +# 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_v4_generated_JobService_BatchUpdateJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_batch_update_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + jobs = talent_v4.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4.BatchUpdateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_update_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_BatchUpdateJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py new file mode 100644 index 00000000..952a835e --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py @@ -0,0 +1,63 @@ +# -*- 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 BatchUpdateJobs +# 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_v4_generated_JobService_BatchUpdateJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_batch_update_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + jobs = talent_v4.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4.BatchUpdateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_update_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_BatchUpdateJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py new file mode 100644 index 00000000..d5c1f62e --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py @@ -0,0 +1,59 @@ +# -*- 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 CreateJob +# 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_v4_generated_JobService_CreateJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_create_job(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + job = talent_v4.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = await client.create_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_CreateJob_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py new file mode 100644 index 00000000..b9a794a1 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py @@ -0,0 +1,59 @@ +# -*- 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 CreateJob +# 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_v4_generated_JobService_CreateJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_create_job(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + job = talent_v4.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = client.create_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_CreateJob_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py new file mode 100644 index 00000000..9bf6acb8 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteJob +# 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_v4_generated_JobService_DeleteJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_delete_job(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.DeleteJobRequest( + name="name_value", + ) + + # Make the request + await client.delete_job(request=request) + + +# [END jobs_v4_generated_JobService_DeleteJob_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py new file mode 100644 index 00000000..88bd9f96 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteJob +# 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_v4_generated_JobService_DeleteJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_delete_job(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.DeleteJobRequest( + name="name_value", + ) + + # Make the request + client.delete_job(request=request) + + +# [END jobs_v4_generated_JobService_DeleteJob_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py new file mode 100644 index 00000000..d69b7c04 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py @@ -0,0 +1,52 @@ +# -*- 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 GetJob +# 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_v4_generated_JobService_GetJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_get_job(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.GetJobRequest( + name="name_value", + ) + + # Make the request + response = await client.get_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_GetJob_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py new file mode 100644 index 00000000..f757ceea --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py @@ -0,0 +1,52 @@ +# -*- 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 GetJob +# 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_v4_generated_JobService_GetJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_get_job(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.GetJobRequest( + name="name_value", + ) + + # Make the request + response = client.get_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_GetJob_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py new file mode 100644 index 00000000..2bf1f6cd --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py @@ -0,0 +1,54 @@ +# -*- 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 ListJobs +# 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_v4_generated_JobService_ListJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_list_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.ListJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END jobs_v4_generated_JobService_ListJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py new file mode 100644 index 00000000..5537f71f --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py @@ -0,0 +1,54 @@ +# -*- 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 ListJobs +# 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_v4_generated_JobService_ListJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_list_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.ListJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END jobs_v4_generated_JobService_ListJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py new file mode 100644 index 00000000..76fb33fd --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py @@ -0,0 +1,52 @@ +# -*- 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 SearchJobs +# 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_v4_generated_JobService_SearchJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_search_jobs(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + response = await client.search_jobs(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_SearchJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py new file mode 100644 index 00000000..fb28ec78 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py @@ -0,0 +1,52 @@ +# -*- 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 SearchJobsForAlert +# 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_v4_generated_JobService_SearchJobsForAlert_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_search_jobs_for_alert(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + response = await client.search_jobs_for_alert(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_SearchJobsForAlert_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py new file mode 100644 index 00000000..65151219 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py @@ -0,0 +1,52 @@ +# -*- 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 SearchJobsForAlert +# 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_v4_generated_JobService_SearchJobsForAlert_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_search_jobs_for_alert(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + response = client.search_jobs_for_alert(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_SearchJobsForAlert_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py new file mode 100644 index 00000000..b629c86d --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py @@ -0,0 +1,52 @@ +# -*- 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 SearchJobs +# 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_v4_generated_JobService_SearchJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_search_jobs(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + response = client.search_jobs(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_SearchJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py new file mode 100644 index 00000000..295e6fde --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py @@ -0,0 +1,58 @@ +# -*- 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 UpdateJob +# 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_v4_generated_JobService_UpdateJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_update_job(): + # Create a client + client = talent_v4.JobServiceAsyncClient() + + # Initialize request argument(s) + job = talent_v4.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4.UpdateJobRequest( + job=job, + ) + + # Make the request + response = await client.update_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_UpdateJob_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py new file mode 100644 index 00000000..b0488902 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py @@ -0,0 +1,58 @@ +# -*- 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 UpdateJob +# 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_v4_generated_JobService_UpdateJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_update_job(): + # Create a client + client = talent_v4.JobServiceClient() + + # Initialize request argument(s) + job = talent_v4.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4.UpdateJobRequest( + job=job, + ) + + # Make the request + response = client.update_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_JobService_UpdateJob_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py new file mode 100644 index 00000000..6dc93795 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py @@ -0,0 +1,56 @@ +# -*- 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 CreateTenant +# 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_v4_generated_TenantService_CreateTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_create_tenant(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + tenant = talent_v4.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4.CreateTenantRequest( + parent="parent_value", + tenant=tenant, + ) + + # Make the request + response = await client.create_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_TenantService_CreateTenant_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py new file mode 100644 index 00000000..350b7d5b --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py @@ -0,0 +1,56 @@ +# -*- 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 CreateTenant +# 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_v4_generated_TenantService_CreateTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_create_tenant(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + tenant = talent_v4.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4.CreateTenantRequest( + parent="parent_value", + tenant=tenant, + ) + + # Make the request + response = client.create_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_TenantService_CreateTenant_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py new file mode 100644 index 00000000..4938c7d5 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteTenant +# 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_v4_generated_TenantService_DeleteTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_delete_tenant(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.DeleteTenantRequest( + name="name_value", + ) + + # Make the request + await client.delete_tenant(request=request) + + +# [END jobs_v4_generated_TenantService_DeleteTenant_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py new file mode 100644 index 00000000..948fb992 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteTenant +# 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_v4_generated_TenantService_DeleteTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_delete_tenant(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4.DeleteTenantRequest( + name="name_value", + ) + + # Make the request + client.delete_tenant(request=request) + + +# [END jobs_v4_generated_TenantService_DeleteTenant_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py new file mode 100644 index 00000000..329d4493 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py @@ -0,0 +1,52 @@ +# -*- 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 GetTenant +# 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_v4_generated_TenantService_GetTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_get_tenant(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.GetTenantRequest( + name="name_value", + ) + + # Make the request + response = await client.get_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_TenantService_GetTenant_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py new file mode 100644 index 00000000..d6b4a785 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py @@ -0,0 +1,52 @@ +# -*- 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 GetTenant +# 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_v4_generated_TenantService_GetTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_get_tenant(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4.GetTenantRequest( + name="name_value", + ) + + # Make the request + response = client.get_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_TenantService_GetTenant_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py new file mode 100644 index 00000000..1be0cc08 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py @@ -0,0 +1,53 @@ +# -*- 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 ListTenants +# 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_v4_generated_TenantService_ListTenants_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_list_tenants(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4.ListTenantsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tenants(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END jobs_v4_generated_TenantService_ListTenants_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py new file mode 100644 index 00000000..df7fa906 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py @@ -0,0 +1,53 @@ +# -*- 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 ListTenants +# 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_v4_generated_TenantService_ListTenants_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_list_tenants(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4.ListTenantsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tenants(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END jobs_v4_generated_TenantService_ListTenants_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py new file mode 100644 index 00000000..4098de41 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py @@ -0,0 +1,55 @@ +# -*- 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 UpdateTenant +# 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_v4_generated_TenantService_UpdateTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +async def sample_update_tenant(): + # Create a client + client = talent_v4.TenantServiceAsyncClient() + + # Initialize request argument(s) + tenant = talent_v4.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4.UpdateTenantRequest( + tenant=tenant, + ) + + # Make the request + response = await client.update_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_TenantService_UpdateTenant_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py new file mode 100644 index 00000000..d70a2de6 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py @@ -0,0 +1,55 @@ +# -*- 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 UpdateTenant +# 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_v4_generated_TenantService_UpdateTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4 + + +def sample_update_tenant(): + # Create a client + client = talent_v4.TenantServiceClient() + + # Initialize request argument(s) + tenant = talent_v4.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4.UpdateTenantRequest( + tenant=tenant, + ) + + # Make the request + response = client.update_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4_generated_TenantService_UpdateTenant_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/snippet_metadata_talent_v4.json b/owl-bot-staging/v4/samples/generated_samples/snippet_metadata_talent_v4.json new file mode 100644 index 00000000..abf91447 --- /dev/null +++ b/owl-bot-staging/v4/samples/generated_samples/snippet_metadata_talent_v4.json @@ -0,0 +1,3602 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.talent.v4", + "version": "v4" + } + ], + "language": "PYTHON", + "name": "google-cloud-talent" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.create_company", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.CreateCompany", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "CreateCompany" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.CreateCompanyRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "company", + "type": "google.cloud.talent_v4.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_v4.types.Company", + "shortName": "create_company" + }, + "description": "Sample for CreateCompany", + "file": "jobs_v4_generated_company_service_create_company_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_CreateCompany_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_create_company_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceClient", + "shortName": "CompanyServiceClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceClient.create_company", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.CreateCompany", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "CreateCompany" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.CreateCompanyRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "company", + "type": "google.cloud.talent_v4.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_v4.types.Company", + "shortName": "create_company" + }, + "description": "Sample for CreateCompany", + "file": "jobs_v4_generated_company_service_create_company_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_CreateCompany_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_create_company_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.delete_company", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.DeleteCompany", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "DeleteCompany" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4_generated_company_service_delete_company_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_DeleteCompany_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_delete_company_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceClient", + "shortName": "CompanyServiceClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceClient.delete_company", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.DeleteCompany", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "DeleteCompany" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4_generated_company_service_delete_company_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_DeleteCompany_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_delete_company_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.get_company", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.GetCompany", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "GetCompany" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4.types.Company", + "shortName": "get_company" + }, + "description": "Sample for GetCompany", + "file": "jobs_v4_generated_company_service_get_company_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_GetCompany_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_get_company_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceClient", + "shortName": "CompanyServiceClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceClient.get_company", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.GetCompany", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "GetCompany" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4.types.Company", + "shortName": "get_company" + }, + "description": "Sample for GetCompany", + "file": "jobs_v4_generated_company_service_get_company_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_GetCompany_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_get_company_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.list_companies", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.ListCompanies", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "ListCompanies" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4.services.company_service.pagers.ListCompaniesAsyncPager", + "shortName": "list_companies" + }, + "description": "Sample for ListCompanies", + "file": "jobs_v4_generated_company_service_list_companies_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_ListCompanies_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_list_companies_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceClient", + "shortName": "CompanyServiceClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceClient.list_companies", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.ListCompanies", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "ListCompanies" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4.services.company_service.pagers.ListCompaniesPager", + "shortName": "list_companies" + }, + "description": "Sample for ListCompanies", + "file": "jobs_v4_generated_company_service_list_companies_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_ListCompanies_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_list_companies_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.update_company", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.UpdateCompany", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "UpdateCompany" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.UpdateCompanyRequest" + }, + { + "name": "company", + "type": "google.cloud.talent_v4.types.Company" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.Company", + "shortName": "update_company" + }, + "description": "Sample for UpdateCompany", + "file": "jobs_v4_generated_company_service_update_company_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_UpdateCompany_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_update_company_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.CompanyServiceClient", + "shortName": "CompanyServiceClient" + }, + "fullName": "google.cloud.talent_v4.CompanyServiceClient.update_company", + "method": { + "fullName": "google.cloud.talent.v4.CompanyService.UpdateCompany", + "service": { + "fullName": "google.cloud.talent.v4.CompanyService", + "shortName": "CompanyService" + }, + "shortName": "UpdateCompany" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.UpdateCompanyRequest" + }, + { + "name": "company", + "type": "google.cloud.talent_v4.types.Company" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.Company", + "shortName": "update_company" + }, + "description": "Sample for UpdateCompany", + "file": "jobs_v4_generated_company_service_update_company_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_CompanyService_UpdateCompany_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_company_service_update_company_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.CompletionAsyncClient", + "shortName": "CompletionAsyncClient" + }, + "fullName": "google.cloud.talent_v4.CompletionAsyncClient.complete_query", + "method": { + "fullName": "google.cloud.talent.v4.Completion.CompleteQuery", + "service": { + "fullName": "google.cloud.talent.v4.Completion", + "shortName": "Completion" + }, + "shortName": "CompleteQuery" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4.types.CompleteQueryResponse", + "shortName": "complete_query" + }, + "description": "Sample for CompleteQuery", + "file": "jobs_v4_generated_completion_complete_query_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_Completion_CompleteQuery_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_completion_complete_query_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.CompletionClient", + "shortName": "CompletionClient" + }, + "fullName": "google.cloud.talent_v4.CompletionClient.complete_query", + "method": { + "fullName": "google.cloud.talent.v4.Completion.CompleteQuery", + "service": { + "fullName": "google.cloud.talent.v4.Completion", + "shortName": "Completion" + }, + "shortName": "CompleteQuery" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4.types.CompleteQueryResponse", + "shortName": "complete_query" + }, + "description": "Sample for CompleteQuery", + "file": "jobs_v4_generated_completion_complete_query_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_Completion_CompleteQuery_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_completion_complete_query_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.EventServiceAsyncClient", + "shortName": "EventServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.EventServiceAsyncClient.create_client_event", + "method": { + "fullName": "google.cloud.talent.v4.EventService.CreateClientEvent", + "service": { + "fullName": "google.cloud.talent.v4.EventService", + "shortName": "EventService" + }, + "shortName": "CreateClientEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.CreateClientEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "client_event", + "type": "google.cloud.talent_v4.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_v4.types.ClientEvent", + "shortName": "create_client_event" + }, + "description": "Sample for CreateClientEvent", + "file": "jobs_v4_generated_event_service_create_client_event_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_EventService_CreateClientEvent_async", + "segments": [ + { + "end": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_event_service_create_client_event_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.EventServiceClient", + "shortName": "EventServiceClient" + }, + "fullName": "google.cloud.talent_v4.EventServiceClient.create_client_event", + "method": { + "fullName": "google.cloud.talent.v4.EventService.CreateClientEvent", + "service": { + "fullName": "google.cloud.talent.v4.EventService", + "shortName": "EventService" + }, + "shortName": "CreateClientEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.CreateClientEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "client_event", + "type": "google.cloud.talent_v4.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_v4.types.ClientEvent", + "shortName": "create_client_event" + }, + "description": "Sample for CreateClientEvent", + "file": "jobs_v4_generated_event_service_create_client_event_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_EventService_CreateClientEvent_sync", + "segments": [ + { + "end": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_event_service_create_client_event_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.batch_create_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.BatchCreateJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "BatchCreateJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.BatchCreateJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "jobs", + "type": "Sequence[google.cloud.talent_v4.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_v4_generated_job_service_batch_create_jobs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_BatchCreateJobs_async", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_batch_create_jobs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.batch_create_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.BatchCreateJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "BatchCreateJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.BatchCreateJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "jobs", + "type": "Sequence[google.cloud.talent_v4.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_v4_generated_job_service_batch_create_jobs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_BatchCreateJobs_sync", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_batch_create_jobs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.batch_delete_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.BatchDeleteJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "BatchDeleteJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.BatchDeleteJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "names", + "type": "Sequence[str]" + }, + { + "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_delete_jobs" + }, + "description": "Sample for BatchDeleteJobs", + "file": "jobs_v4_generated_job_service_batch_delete_jobs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_BatchDeleteJobs_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_batch_delete_jobs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.batch_delete_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.BatchDeleteJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "BatchDeleteJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.BatchDeleteJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "names", + "type": "Sequence[str]" + }, + { + "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_delete_jobs" + }, + "description": "Sample for BatchDeleteJobs", + "file": "jobs_v4_generated_job_service_batch_delete_jobs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_BatchDeleteJobs_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_batch_delete_jobs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.batch_update_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.BatchUpdateJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "BatchUpdateJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.BatchUpdateJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "jobs", + "type": "Sequence[google.cloud.talent_v4.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_v4_generated_job_service_batch_update_jobs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_BatchUpdateJobs_async", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_batch_update_jobs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.batch_update_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.BatchUpdateJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "BatchUpdateJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.BatchUpdateJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "jobs", + "type": "Sequence[google.cloud.talent_v4.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_v4_generated_job_service_batch_update_jobs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_BatchUpdateJobs_sync", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_batch_update_jobs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.create_job", + "method": { + "fullName": "google.cloud.talent.v4.JobService.CreateJob", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "CreateJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.CreateJobRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "job", + "type": "google.cloud.talent_v4.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_v4.types.Job", + "shortName": "create_job" + }, + "description": "Sample for CreateJob", + "file": "jobs_v4_generated_job_service_create_job_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_CreateJob_async", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_create_job_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.create_job", + "method": { + "fullName": "google.cloud.talent.v4.JobService.CreateJob", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "CreateJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.CreateJobRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "job", + "type": "google.cloud.talent_v4.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_v4.types.Job", + "shortName": "create_job" + }, + "description": "Sample for CreateJob", + "file": "jobs_v4_generated_job_service_create_job_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_CreateJob_sync", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_create_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.delete_job", + "method": { + "fullName": "google.cloud.talent.v4.JobService.DeleteJob", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "DeleteJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4_generated_job_service_delete_job_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_DeleteJob_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_delete_job_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.delete_job", + "method": { + "fullName": "google.cloud.talent.v4.JobService.DeleteJob", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "DeleteJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.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_v4_generated_job_service_delete_job_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_DeleteJob_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_delete_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.get_job", + "method": { + "fullName": "google.cloud.talent.v4.JobService.GetJob", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "GetJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.GetJobRequest" + }, + { + "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_v4.types.Job", + "shortName": "get_job" + }, + "description": "Sample for GetJob", + "file": "jobs_v4_generated_job_service_get_job_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_GetJob_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_get_job_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.get_job", + "method": { + "fullName": "google.cloud.talent.v4.JobService.GetJob", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "GetJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.GetJobRequest" + }, + { + "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_v4.types.Job", + "shortName": "get_job" + }, + "description": "Sample for GetJob", + "file": "jobs_v4_generated_job_service_get_job_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_GetJob_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_get_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.list_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.ListJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "ListJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.ListJobsRequest" + }, + { + "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]" + } + ], + "resultType": "google.cloud.talent_v4.services.job_service.pagers.ListJobsAsyncPager", + "shortName": "list_jobs" + }, + "description": "Sample for ListJobs", + "file": "jobs_v4_generated_job_service_list_jobs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_ListJobs_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_list_jobs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.list_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.ListJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "ListJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.ListJobsRequest" + }, + { + "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]" + } + ], + "resultType": "google.cloud.talent_v4.services.job_service.pagers.ListJobsPager", + "shortName": "list_jobs" + }, + "description": "Sample for ListJobs", + "file": "jobs_v4_generated_job_service_list_jobs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_ListJobs_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_list_jobs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.search_jobs_for_alert", + "method": { + "fullName": "google.cloud.talent.v4.JobService.SearchJobsForAlert", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "SearchJobsForAlert" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.SearchJobsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", + "shortName": "search_jobs_for_alert" + }, + "description": "Sample for SearchJobsForAlert", + "file": "jobs_v4_generated_job_service_search_jobs_for_alert_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_SearchJobsForAlert_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_search_jobs_for_alert_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.search_jobs_for_alert", + "method": { + "fullName": "google.cloud.talent.v4.JobService.SearchJobsForAlert", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "SearchJobsForAlert" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.SearchJobsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", + "shortName": "search_jobs_for_alert" + }, + "description": "Sample for SearchJobsForAlert", + "file": "jobs_v4_generated_job_service_search_jobs_for_alert_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_SearchJobsForAlert_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_search_jobs_for_alert_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.search_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.SearchJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "SearchJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.SearchJobsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", + "shortName": "search_jobs" + }, + "description": "Sample for SearchJobs", + "file": "jobs_v4_generated_job_service_search_jobs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_SearchJobs_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_search_jobs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.search_jobs", + "method": { + "fullName": "google.cloud.talent.v4.JobService.SearchJobs", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "SearchJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.SearchJobsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", + "shortName": "search_jobs" + }, + "description": "Sample for SearchJobs", + "file": "jobs_v4_generated_job_service_search_jobs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_SearchJobs_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_search_jobs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.update_job", + "method": { + "fullName": "google.cloud.talent.v4.JobService.UpdateJob", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "UpdateJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.UpdateJobRequest" + }, + { + "name": "job", + "type": "google.cloud.talent_v4.types.Job" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.Job", + "shortName": "update_job" + }, + "description": "Sample for UpdateJob", + "file": "jobs_v4_generated_job_service_update_job_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_UpdateJob_async", + "segments": [ + { + "end": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_update_job_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4.JobServiceClient.update_job", + "method": { + "fullName": "google.cloud.talent.v4.JobService.UpdateJob", + "service": { + "fullName": "google.cloud.talent.v4.JobService", + "shortName": "JobService" + }, + "shortName": "UpdateJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.UpdateJobRequest" + }, + { + "name": "job", + "type": "google.cloud.talent_v4.types.Job" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.Job", + "shortName": "update_job" + }, + "description": "Sample for UpdateJob", + "file": "jobs_v4_generated_job_service_update_job_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_JobService_UpdateJob_sync", + "segments": [ + { + "end": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_job_service_update_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.create_tenant", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.CreateTenant", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "CreateTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.CreateTenantRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "tenant", + "type": "google.cloud.talent_v4.types.Tenant" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.Tenant", + "shortName": "create_tenant" + }, + "description": "Sample for CreateTenant", + "file": "jobs_v4_generated_tenant_service_create_tenant_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_CreateTenant_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_create_tenant_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceClient.create_tenant", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.CreateTenant", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "CreateTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.CreateTenantRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "tenant", + "type": "google.cloud.talent_v4.types.Tenant" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.Tenant", + "shortName": "create_tenant" + }, + "description": "Sample for CreateTenant", + "file": "jobs_v4_generated_tenant_service_create_tenant_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_CreateTenant_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_create_tenant_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.delete_tenant", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.DeleteTenant", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "DeleteTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.DeleteTenantRequest" + }, + { + "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_tenant" + }, + "description": "Sample for DeleteTenant", + "file": "jobs_v4_generated_tenant_service_delete_tenant_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_DeleteTenant_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_delete_tenant_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceClient.delete_tenant", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.DeleteTenant", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "DeleteTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.DeleteTenantRequest" + }, + { + "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_tenant" + }, + "description": "Sample for DeleteTenant", + "file": "jobs_v4_generated_tenant_service_delete_tenant_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_DeleteTenant_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_delete_tenant_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.get_tenant", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.GetTenant", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "GetTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.GetTenantRequest" + }, + { + "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_v4.types.Tenant", + "shortName": "get_tenant" + }, + "description": "Sample for GetTenant", + "file": "jobs_v4_generated_tenant_service_get_tenant_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_GetTenant_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_get_tenant_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceClient.get_tenant", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.GetTenant", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "GetTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.GetTenantRequest" + }, + { + "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_v4.types.Tenant", + "shortName": "get_tenant" + }, + "description": "Sample for GetTenant", + "file": "jobs_v4_generated_tenant_service_get_tenant_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_GetTenant_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_get_tenant_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.list_tenants", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.ListTenants", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "ListTenants" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.ListTenantsRequest" + }, + { + "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_v4.services.tenant_service.pagers.ListTenantsAsyncPager", + "shortName": "list_tenants" + }, + "description": "Sample for ListTenants", + "file": "jobs_v4_generated_tenant_service_list_tenants_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_ListTenants_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_list_tenants_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceClient.list_tenants", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.ListTenants", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "ListTenants" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.ListTenantsRequest" + }, + { + "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_v4.services.tenant_service.pagers.ListTenantsPager", + "shortName": "list_tenants" + }, + "description": "Sample for ListTenants", + "file": "jobs_v4_generated_tenant_service_list_tenants_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_ListTenants_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_list_tenants_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.update_tenant", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.UpdateTenant", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "UpdateTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.UpdateTenantRequest" + }, + { + "name": "tenant", + "type": "google.cloud.talent_v4.types.Tenant" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.Tenant", + "shortName": "update_tenant" + }, + "description": "Sample for UpdateTenant", + "file": "jobs_v4_generated_tenant_service_update_tenant_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_UpdateTenant_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_update_tenant_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4.TenantServiceClient.update_tenant", + "method": { + "fullName": "google.cloud.talent.v4.TenantService.UpdateTenant", + "service": { + "fullName": "google.cloud.talent.v4.TenantService", + "shortName": "TenantService" + }, + "shortName": "UpdateTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4.types.UpdateTenantRequest" + }, + { + "name": "tenant", + "type": "google.cloud.talent_v4.types.Tenant" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.talent_v4.types.Tenant", + "shortName": "update_tenant" + }, + "description": "Sample for UpdateTenant", + "file": "jobs_v4_generated_tenant_service_update_tenant_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4_generated_TenantService_UpdateTenant_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4_generated_tenant_service_update_tenant_sync.py" + } + ] +} diff --git a/owl-bot-staging/v4/scripts/fixup_talent_v4_keywords.py b/owl-bot-staging/v4/scripts/fixup_talent_v4_keywords.py new file mode 100644 index 00000000..29540143 --- /dev/null +++ b/owl-bot-staging/v4/scripts/fixup_talent_v4_keywords.py @@ -0,0 +1,197 @@ +#! /usr/bin/env python3 +# -*- 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 argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class talentCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'batch_create_jobs': ('parent', 'jobs', ), + 'batch_delete_jobs': ('parent', 'names', ), + 'batch_update_jobs': ('parent', 'jobs', 'update_mask', ), + 'complete_query': ('tenant', 'query', 'page_size', 'language_codes', 'company', 'scope', 'type_', ), + 'create_client_event': ('parent', 'client_event', ), + 'create_company': ('parent', 'company', ), + 'create_job': ('parent', 'job', ), + 'create_tenant': ('parent', 'tenant', ), + 'delete_company': ('name', ), + 'delete_job': ('name', ), + 'delete_tenant': ('name', ), + 'get_company': ('name', ), + 'get_job': ('name', ), + 'get_tenant': ('name', ), + 'list_companies': ('parent', 'page_token', 'page_size', 'require_open_jobs', ), + 'list_jobs': ('parent', 'filter', 'page_token', 'page_size', 'job_view', ), + 'list_tenants': ('parent', 'page_token', 'page_size', ), + 'search_jobs': ('parent', 'request_metadata', 'search_mode', 'job_query', 'enable_broadening', 'histogram_queries', 'job_view', 'offset', 'max_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', 'histogram_queries', 'job_view', 'offset', 'max_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_tenant': ('tenant', 'update_mask', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=talentCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the talent client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v4/setup.py b/owl-bot-staging/v4/setup.py new file mode 100644 index 00000000..ddcd0c82 --- /dev/null +++ b/owl-bot-staging/v4/setup.py @@ -0,0 +1,58 @@ +# -*- 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 io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-cloud-talent', + author="Google LLC", + author_email="googleapis-packages@google.com", + url="https://github.com/googleapis/python-google-cloud-talent", + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 2.10.0, < 3.0.0dev', + 'libcst >= 0.2.5', + 'googleapis-common-protos >= 1.55.0, <2.0.0dev', + 'proto-plus >= 1.19.7', + ), + python_requires='>=3.7', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v4/tests/__init__.py b/owl-bot-staging/v4/tests/__init__.py new file mode 100644 index 00000000..231bc125 --- /dev/null +++ b/owl-bot-staging/v4/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/v4/tests/unit/__init__.py b/owl-bot-staging/v4/tests/unit/__init__.py new file mode 100644 index 00000000..231bc125 --- /dev/null +++ b/owl-bot-staging/v4/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/v4/tests/unit/gapic/__init__.py b/owl-bot-staging/v4/tests/unit/gapic/__init__.py new file mode 100644 index 00000000..231bc125 --- /dev/null +++ b/owl-bot-staging/v4/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/__init__.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/__init__.py new file mode 100644 index 00000000..231bc125 --- /dev/null +++ b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_company_service.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_company_service.py new file mode 100644 index 00000000..fe019c6b --- /dev/null +++ b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_company_service.py @@ -0,0 +1,2687 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4.services.company_service import CompanyServiceAsyncClient +from google.cloud.talent_v4.services.company_service import CompanyServiceClient +from google.cloud.talent_v4.services.company_service import pagers +from google.cloud.talent_v4.services.company_service import transports +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import company +from google.cloud.talent_v4.types import company as gct_company +from google.cloud.talent_v4.types import company_service +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +from google.type import latlng_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore +import google.auth + + +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 CompanyServiceClient._get_default_mtls_endpoint(None) is None + assert CompanyServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert CompanyServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert CompanyServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert CompanyServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert CompanyServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (CompanyServiceClient, "grpc"), + (CompanyServiceAsyncClient, "grpc_asyncio"), +]) +def test_company_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.CompanyServiceGrpcTransport, "grpc"), + (transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_company_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", [ + (CompanyServiceClient, "grpc"), + (CompanyServiceAsyncClient, "grpc_asyncio"), +]) +def test_company_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_company_service_client_get_transport_class(): + transport = CompanyServiceClient.get_transport_class() + available_transports = [ + transports.CompanyServiceGrpcTransport, + ] + assert transport in available_transports + + transport = CompanyServiceClient.get_transport_class("grpc") + assert transport == transports.CompanyServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc"), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) +@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) +def test_company_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(CompanyServiceClient, '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(CompanyServiceClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", "true"), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", "false"), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) +@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_company_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + CompanyServiceClient, CompanyServiceAsyncClient +]) +@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) +@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) +def test_company_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", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc"), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_company_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", grpc_helpers), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_company_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, + api_audience=None, + ) + +def test_company_service_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4.services.company_service.transports.CompanyServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = CompanyServiceClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", grpc_helpers), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_company_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, + api_audience=None, + ) + + # 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", [ + company_service.CreateCompanyRequest, + dict, +]) +def test_create_company(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + ) + response = client.create_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.CreateCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +def test_create_company_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 = CompanyServiceClient( + 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_company), + '__call__') as call: + client.create_company() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.CreateCompanyRequest() + +@pytest.mark.asyncio +async def test_create_company_async(transport: str = 'grpc_asyncio', request_type=company_service.CreateCompanyRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + )) + response = await client.create_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.CreateCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +@pytest.mark.asyncio +async def test_create_company_async_from_dict(): + await test_create_company_async(request_type=dict) + + +def test_create_company_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 = company_service.CreateCompanyRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_company), + '__call__') as call: + call.return_value = gct_company.Company() + client.create_company(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_company_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 = company_service.CreateCompanyRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_company), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) + await client.create_company(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_company_flattened(): + 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.create_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_company( + parent='parent_value', + company=gct_company.Company(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].company + mock_val = gct_company.Company(name='name_value') + assert arg == mock_val + + +def test_create_company_flattened_error(): + client = CompanyServiceClient( + 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_company( + company_service.CreateCompanyRequest(), + parent='parent_value', + company=gct_company.Company(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_company_flattened_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.create_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_company( + parent='parent_value', + company=gct_company.Company(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].company + mock_val = gct_company.Company(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_company_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_company( + company_service.CreateCompanyRequest(), + parent='parent_value', + company=gct_company.Company(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + company_service.GetCompanyRequest, + dict, +]) +def test_get_company(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + ) + response = client.get_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.GetCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +def test_get_company_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 = CompanyServiceClient( + 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_company), + '__call__') as call: + client.get_company() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.GetCompanyRequest() + +@pytest.mark.asyncio +async def test_get_company_async(transport: str = 'grpc_asyncio', request_type=company_service.GetCompanyRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + )) + response = await client.get_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.GetCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +@pytest.mark.asyncio +async def test_get_company_async_from_dict(): + await test_get_company_async(request_type=dict) + + +def test_get_company_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 = company_service.GetCompanyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_company), + '__call__') as call: + call.return_value = company.Company() + client.get_company(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_company_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 = company_service.GetCompanyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_company), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) + await client.get_company(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_company_flattened(): + 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_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company.Company() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_company( + 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_company_flattened_error(): + client = CompanyServiceClient( + 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_company( + company_service.GetCompanyRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_company_flattened_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_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company.Company() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_company( + 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_company_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_company( + company_service.GetCompanyRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + company_service.UpdateCompanyRequest, + dict, +]) +def test_update_company(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + ) + response = client.update_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.UpdateCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +def test_update_company_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 = CompanyServiceClient( + 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_company), + '__call__') as call: + client.update_company() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.UpdateCompanyRequest() + +@pytest.mark.asyncio +async def test_update_company_async(transport: str = 'grpc_asyncio', request_type=company_service.UpdateCompanyRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + )) + response = await client.update_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.UpdateCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +@pytest.mark.asyncio +async def test_update_company_async_from_dict(): + await test_update_company_async(request_type=dict) + + +def test_update_company_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 = company_service.UpdateCompanyRequest() + + request.company.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_company), + '__call__') as call: + call.return_value = gct_company.Company() + client.update_company(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', + 'company.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_company_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 = company_service.UpdateCompanyRequest() + + request.company.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_company), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) + await client.update_company(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', + 'company.name=name_value', + ) in kw['metadata'] + + +def test_update_company_flattened(): + 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.update_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_company( + company=gct_company.Company(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_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].company + mock_val = gct_company.Company(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_company_flattened_error(): + client = CompanyServiceClient( + 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_company( + company_service.UpdateCompanyRequest(), + company=gct_company.Company(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_company_flattened_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.update_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_company( + company=gct_company.Company(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_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].company + mock_val = gct_company.Company(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_company_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_company( + company_service.UpdateCompanyRequest(), + company=gct_company.Company(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + company_service.DeleteCompanyRequest, + dict, +]) +def test_delete_company(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.DeleteCompanyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_company_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 = CompanyServiceClient( + 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_company), + '__call__') as call: + client.delete_company() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.DeleteCompanyRequest() + +@pytest.mark.asyncio +async def test_delete_company_async(transport: str = 'grpc_asyncio', request_type=company_service.DeleteCompanyRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.DeleteCompanyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_company_async_from_dict(): + await test_delete_company_async(request_type=dict) + + +def test_delete_company_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 = company_service.DeleteCompanyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_company), + '__call__') as call: + call.return_value = None + client.delete_company(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_company_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 = company_service.DeleteCompanyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_company), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_company(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_company_flattened(): + 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.delete_company), + '__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_company( + 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_company_flattened_error(): + client = CompanyServiceClient( + 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_company( + company_service.DeleteCompanyRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_company_flattened_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.delete_company), + '__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_company( + 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_company_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_company( + company_service.DeleteCompanyRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + company_service.ListCompaniesRequest, + dict, +]) +def test_list_companies(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_companies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company_service.ListCompaniesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_companies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.ListCompaniesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCompaniesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_companies_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 = CompanyServiceClient( + 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_companies), + '__call__') as call: + client.list_companies() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.ListCompaniesRequest() + +@pytest.mark.asyncio +async def test_list_companies_async(transport: str = 'grpc_asyncio', request_type=company_service.ListCompaniesRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_companies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_companies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.ListCompaniesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCompaniesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_companies_async_from_dict(): + await test_list_companies_async(request_type=dict) + + +def test_list_companies_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 = company_service.ListCompaniesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_companies), + '__call__') as call: + call.return_value = company_service.ListCompaniesResponse() + client.list_companies(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_companies_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 = company_service.ListCompaniesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_companies), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse()) + await client.list_companies(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_companies_flattened(): + 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.list_companies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company_service.ListCompaniesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_companies( + 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_companies_flattened_error(): + client = CompanyServiceClient( + 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_companies( + company_service.ListCompaniesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_companies_flattened_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.list_companies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company_service.ListCompaniesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_companies( + 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_companies_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_companies( + company_service.ListCompaniesRequest(), + parent='parent_value', + ) + + +def test_list_companies_pager(transport_name: str = "grpc"): + client = CompanyServiceClient( + 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_companies), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + company.Company(), + ], + next_page_token='abc', + ), + company_service.ListCompaniesResponse( + companies=[], + next_page_token='def', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + ], + next_page_token='ghi', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_companies(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, company.Company) + for i in results) +def test_list_companies_pages(transport_name: str = "grpc"): + client = CompanyServiceClient( + 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_companies), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + company.Company(), + ], + next_page_token='abc', + ), + company_service.ListCompaniesResponse( + companies=[], + next_page_token='def', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + ], + next_page_token='ghi', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + ], + ), + RuntimeError, + ) + pages = list(client.list_companies(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_companies_async_pager(): + 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.list_companies), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + company.Company(), + ], + next_page_token='abc', + ), + company_service.ListCompaniesResponse( + companies=[], + next_page_token='def', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + ], + next_page_token='ghi', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_companies(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, company.Company) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_companies_async_pages(): + 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.list_companies), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + company.Company(), + ], + next_page_token='abc', + ), + company_service.ListCompaniesResponse( + companies=[], + next_page_token='def', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + ], + next_page_token='ghi', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_companies(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.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompanyServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompanyServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CompanyServiceClient( + 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 = CompanyServiceClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompanyServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = CompanyServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.CompanyServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.CompanyServiceGrpcTransport, + transports.CompanyServiceGrpcAsyncIOTransport, +]) +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 = CompanyServiceClient.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 = CompanyServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CompanyServiceGrpcTransport, + ) + +def test_company_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.CompanyServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_company_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4.services.company_service.transports.CompanyServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.CompanyServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_company', + 'get_company', + 'update_company', + 'delete_company', + 'list_companies', + ) + 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_company_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_v4.services.company_service.transports.CompanyServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CompanyServiceTransport( + 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_company_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_v4.services.company_service.transports.CompanyServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CompanyServiceTransport() + adc.assert_called_once() + + +def test_company_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) + CompanyServiceClient() + 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.CompanyServiceGrpcTransport, + transports.CompanyServiceGrpcAsyncIOTransport, + ], +) +def test_company_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", + [ + 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", + [ + (transports.CompanyServiceGrpcTransport, grpc_helpers), + (transports.CompanyServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_company_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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) +def test_company_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_company_service_host_no_port(transport_name): + client = CompanyServiceClient( + 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_company_service_host_with_port(transport_name): + client = CompanyServiceClient( + 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_company_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CompanyServiceGrpcTransport( + 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_company_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CompanyServiceGrpcAsyncIOTransport( + 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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) +def test_company_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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) +def test_company_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_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) + actual = CompanyServiceClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = CompanyServiceClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_company_path(path) + assert expected == actual + +def test_tenant_path(): + project = "cuttlefish" + tenant = "mussel" + expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) + actual = CompanyServiceClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "winkle", + "tenant": "nautilus", + } + path = CompanyServiceClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.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 = CompanyServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "abalone", + } + path = CompanyServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "squid" + expected = "folders/{folder}".format(folder=folder, ) + actual = CompanyServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "clam", + } + path = CompanyServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "whelk" + expected = "organizations/{organization}".format(organization=organization, ) + actual = CompanyServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "octopus", + } + path = CompanyServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "oyster" + expected = "projects/{project}".format(project=project, ) + actual = CompanyServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nudibranch", + } + path = CompanyServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.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 = CompanyServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "winkle", + "location": "nautilus", + } + path = CompanyServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.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.CompanyServiceTransport, '_prep_wrapped_messages') as prep: + client = CompanyServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.CompanyServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = CompanyServiceClient.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 = CompanyServiceAsyncClient( + 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 = CompanyServiceClient( + 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 = CompanyServiceClient( + 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", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_completion.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_completion.py new file mode 100644 index 00000000..af11befb --- /dev/null +++ b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_completion.py @@ -0,0 +1,1328 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4.services.completion import CompletionAsyncClient +from google.cloud.talent_v4.services.completion import CompletionClient +from google.cloud.talent_v4.services.completion import transports +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import completion_service +from google.oauth2 import service_account +import google.auth + + +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 CompletionClient._get_default_mtls_endpoint(None) is None + assert CompletionClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert CompletionClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert CompletionClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert CompletionClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert CompletionClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (CompletionClient, "grpc"), + (CompletionAsyncClient, "grpc_asyncio"), +]) +def test_completion_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.CompletionGrpcTransport, "grpc"), + (transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_completion_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", [ + (CompletionClient, "grpc"), + (CompletionAsyncClient, "grpc_asyncio"), +]) +def test_completion_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_completion_client_get_transport_class(): + transport = CompletionClient.get_transport_class() + available_transports = [ + transports.CompletionGrpcTransport, + ] + assert transport in available_transports + + transport = CompletionClient.get_transport_class("grpc") + assert transport == transports.CompletionGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc"), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) +@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) +def test_completion_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(CompletionClient, '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(CompletionClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc", "true"), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (CompletionClient, transports.CompletionGrpcTransport, "grpc", "false"), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) +@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_completion_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + CompletionClient, CompletionAsyncClient +]) +@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) +@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) +def test_completion_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", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc"), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_completion_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc", grpc_helpers), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_completion_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, + api_audience=None, + ) + +def test_completion_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4.services.completion.transports.CompletionGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = CompletionClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc", grpc_helpers), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_completion_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, + api_audience=None, + ) + + # 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", [ + completion_service.CompleteQueryRequest, + dict, +]) +def test_complete_query(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.complete_query), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = completion_service.CompleteQueryResponse( + ) + response = client.complete_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == completion_service.CompleteQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, completion_service.CompleteQueryResponse) + + +def test_complete_query_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 = CompletionClient( + 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.complete_query), + '__call__') as call: + client.complete_query() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == completion_service.CompleteQueryRequest() + +@pytest.mark.asyncio +async def test_complete_query_async(transport: str = 'grpc_asyncio', request_type=completion_service.CompleteQueryRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.complete_query), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(completion_service.CompleteQueryResponse( + )) + response = await client.complete_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == completion_service.CompleteQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, completion_service.CompleteQueryResponse) + + +@pytest.mark.asyncio +async def test_complete_query_async_from_dict(): + await test_complete_query_async(request_type=dict) + + +def test_complete_query_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 = completion_service.CompleteQueryRequest() + + request.tenant = 'tenant_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.complete_query), + '__call__') as call: + call.return_value = completion_service.CompleteQueryResponse() + client.complete_query(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', + 'tenant=tenant_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_complete_query_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 = completion_service.CompleteQueryRequest() + + request.tenant = 'tenant_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.complete_query), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(completion_service.CompleteQueryResponse()) + await client.complete_query(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', + 'tenant=tenant_value', + ) in kw['metadata'] + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompletionClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompletionClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CompletionClient( + 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 = CompletionClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompletionClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = CompletionClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.CompletionGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.CompletionGrpcTransport, + transports.CompletionGrpcAsyncIOTransport, +]) +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 = CompletionClient.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 = CompletionClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CompletionGrpcTransport, + ) + +def test_completion_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.CompletionTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_completion_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4.services.completion.transports.CompletionTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.CompletionTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'complete_query', + ) + 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_completion_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_v4.services.completion.transports.CompletionTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CompletionTransport( + 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_completion_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_v4.services.completion.transports.CompletionTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CompletionTransport() + adc.assert_called_once() + + +def test_completion_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) + CompletionClient() + 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.CompletionGrpcTransport, + transports.CompletionGrpcAsyncIOTransport, + ], +) +def test_completion_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", + [ + 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", + [ + (transports.CompletionGrpcTransport, grpc_helpers), + (transports.CompletionGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_completion_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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) +def test_completion_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_completion_host_no_port(transport_name): + client = CompletionClient( + 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_completion_host_with_port(transport_name): + client = CompletionClient( + 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_completion_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CompletionGrpcTransport( + 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_completion_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CompletionGrpcAsyncIOTransport( + 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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) +def test_completion_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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) +def test_completion_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_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) + actual = CompletionClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = CompletionClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_company_path(path) + assert expected == actual + +def test_tenant_path(): + project = "cuttlefish" + tenant = "mussel" + expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) + actual = CompletionClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "winkle", + "tenant": "nautilus", + } + path = CompletionClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.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 = CompletionClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "abalone", + } + path = CompletionClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "squid" + expected = "folders/{folder}".format(folder=folder, ) + actual = CompletionClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "clam", + } + path = CompletionClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "whelk" + expected = "organizations/{organization}".format(organization=organization, ) + actual = CompletionClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "octopus", + } + path = CompletionClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "oyster" + expected = "projects/{project}".format(project=project, ) + actual = CompletionClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nudibranch", + } + path = CompletionClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.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 = CompletionClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "winkle", + "location": "nautilus", + } + path = CompletionClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.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.CompletionTransport, '_prep_wrapped_messages') as prep: + client = CompletionClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.CompletionTransport, '_prep_wrapped_messages') as prep: + transport_class = CompletionClient.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 = CompletionAsyncClient( + 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 = CompletionClient( + 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 = CompletionClient( + 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", [ + (CompletionClient, transports.CompletionGrpcTransport), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_event_service.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_event_service.py new file mode 100644 index 00000000..5ea08b83 --- /dev/null +++ b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_event_service.py @@ -0,0 +1,1413 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4.services.event_service import EventServiceAsyncClient +from google.cloud.talent_v4.services.event_service import EventServiceClient +from google.cloud.talent_v4.services.event_service import transports +from google.cloud.talent_v4.types import event +from google.cloud.talent_v4.types import event_service +from google.oauth2 import service_account +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +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 EventServiceClient._get_default_mtls_endpoint(None) is None + assert EventServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert EventServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert EventServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert EventServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert EventServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (EventServiceClient, "grpc"), + (EventServiceAsyncClient, "grpc_asyncio"), +]) +def test_event_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.EventServiceGrpcTransport, "grpc"), + (transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_event_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", [ + (EventServiceClient, "grpc"), + (EventServiceAsyncClient, "grpc_asyncio"), +]) +def test_event_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_event_service_client_get_transport_class(): + transport = EventServiceClient.get_transport_class() + available_transports = [ + transports.EventServiceGrpcTransport, + ] + assert transport in available_transports + + transport = EventServiceClient.get_transport_class("grpc") + assert transport == transports.EventServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc"), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) +@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) +def test_event_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(EventServiceClient, '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(EventServiceClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", "true"), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", "false"), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) +@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_event_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + EventServiceClient, EventServiceAsyncClient +]) +@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) +@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) +def test_event_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", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc"), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_event_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", grpc_helpers), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_event_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, + api_audience=None, + ) + +def test_event_service_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4.services.event_service.transports.EventServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = EventServiceClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", grpc_helpers), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_event_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, + api_audience=None, + ) + + # 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", [ + event_service.CreateClientEventRequest, + dict, +]) +def test_create_client_event(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_client_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = event.ClientEvent( + request_id='request_id_value', + event_id='event_id_value', + event_notes='event_notes_value', + job_event=event.JobEvent(type_=event.JobEvent.JobEventType.IMPRESSION), + ) + response = client.create_client_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == event_service.CreateClientEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event.ClientEvent) + assert response.request_id == 'request_id_value' + assert response.event_id == 'event_id_value' + assert response.event_notes == 'event_notes_value' + + +def test_create_client_event_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 = EventServiceClient( + 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_client_event), + '__call__') as call: + client.create_client_event() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == event_service.CreateClientEventRequest() + +@pytest.mark.asyncio +async def test_create_client_event_async(transport: str = 'grpc_asyncio', request_type=event_service.CreateClientEventRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_client_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent( + request_id='request_id_value', + event_id='event_id_value', + event_notes='event_notes_value', + )) + response = await client.create_client_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == event_service.CreateClientEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event.ClientEvent) + assert response.request_id == 'request_id_value' + assert response.event_id == 'event_id_value' + assert response.event_notes == 'event_notes_value' + + +@pytest.mark.asyncio +async def test_create_client_event_async_from_dict(): + await test_create_client_event_async(request_type=dict) + + +def test_create_client_event_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 = event_service.CreateClientEventRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_client_event), + '__call__') as call: + call.return_value = event.ClientEvent() + client.create_client_event(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_client_event_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 = event_service.CreateClientEventRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_client_event), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) + await client.create_client_event(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_client_event_flattened(): + 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.create_client_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = event.ClientEvent() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_client_event( + parent='parent_value', + client_event=event.ClientEvent(request_id='request_id_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].client_event + mock_val = event.ClientEvent(request_id='request_id_value') + assert arg == mock_val + + +def test_create_client_event_flattened_error(): + client = EventServiceClient( + 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_client_event( + event_service.CreateClientEventRequest(), + parent='parent_value', + client_event=event.ClientEvent(request_id='request_id_value'), + ) + +@pytest.mark.asyncio +async def test_create_client_event_flattened_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.create_client_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = event.ClientEvent() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_client_event( + parent='parent_value', + client_event=event.ClientEvent(request_id='request_id_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].client_event + mock_val = event.ClientEvent(request_id='request_id_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_client_event_flattened_error_async(): + client = EventServiceAsyncClient( + 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_client_event( + event_service.CreateClientEventRequest(), + parent='parent_value', + client_event=event.ClientEvent(request_id='request_id_value'), + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = EventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = EventServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EventServiceClient( + 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 = EventServiceClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = EventServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = EventServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.EventServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.EventServiceGrpcTransport, + transports.EventServiceGrpcAsyncIOTransport, +]) +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 = EventServiceClient.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 = EventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.EventServiceGrpcTransport, + ) + +def test_event_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.EventServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_event_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4.services.event_service.transports.EventServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.EventServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_client_event', + ) + 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_event_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_v4.services.event_service.transports.EventServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.EventServiceTransport( + 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_event_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_v4.services.event_service.transports.EventServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.EventServiceTransport() + adc.assert_called_once() + + +def test_event_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) + EventServiceClient() + 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.EventServiceGrpcTransport, + transports.EventServiceGrpcAsyncIOTransport, + ], +) +def test_event_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", + [ + 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", + [ + (transports.EventServiceGrpcTransport, grpc_helpers), + (transports.EventServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_event_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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) +def test_event_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_event_service_host_no_port(transport_name): + client = EventServiceClient( + 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_event_service_host_with_port(transport_name): + client = EventServiceClient( + 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_event_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.EventServiceGrpcTransport( + 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_event_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.EventServiceGrpcAsyncIOTransport( + 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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) +def test_event_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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) +def test_event_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_tenant_path(): + project = "squid" + tenant = "clam" + expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) + actual = EventServiceClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "whelk", + "tenant": "octopus", + } + path = EventServiceClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_tenant_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "oyster" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = EventServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nudibranch", + } + path = EventServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "cuttlefish" + expected = "folders/{folder}".format(folder=folder, ) + actual = EventServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "mussel", + } + path = EventServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "winkle" + expected = "organizations/{organization}".format(organization=organization, ) + actual = EventServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nautilus", + } + path = EventServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "scallop" + expected = "projects/{project}".format(project=project, ) + actual = EventServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "abalone", + } + path = EventServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "squid" + location = "clam" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = EventServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = EventServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.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.EventServiceTransport, '_prep_wrapped_messages') as prep: + client = EventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.EventServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = EventServiceClient.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 = EventServiceAsyncClient( + 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 = EventServiceClient( + 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 = EventServiceClient( + 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", [ + (EventServiceClient, transports.EventServiceGrpcTransport), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_job_service.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_job_service.py new file mode 100644 index 00000000..fb8b018e --- /dev/null +++ b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_job_service.py @@ -0,0 +1,3895 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import operation +from google.api_core import operation_async # type: ignore +from google.api_core import operations_v1 +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4.services.job_service import JobServiceAsyncClient +from google.cloud.talent_v4.services.job_service import JobServiceClient +from google.cloud.talent_v4.services.job_service import pagers +from google.cloud.talent_v4.services.job_service import transports +from google.cloud.talent_v4.types import common +from google.cloud.talent_v4.types import filters +from google.cloud.talent_v4.types import histogram +from google.cloud.talent_v4.types import job +from google.cloud.talent_v4.types import job as gct_job +from google.cloud.talent_v4.types import job_service +from google.longrunning import operations_pb2 +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 latlng_pb2 # type: ignore +from google.type import money_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore +from google.type import timeofday_pb2 # type: ignore +import google.auth + + +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 JobServiceClient._get_default_mtls_endpoint(None) is None + assert JobServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert JobServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert JobServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert JobServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert JobServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (JobServiceClient, "grpc"), + (JobServiceAsyncClient, "grpc_asyncio"), +]) +def test_job_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.JobServiceGrpcTransport, "grpc"), + (transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_job_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", [ + (JobServiceClient, "grpc"), + (JobServiceAsyncClient, "grpc_asyncio"), +]) +def test_job_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_job_service_client_get_transport_class(): + transport = JobServiceClient.get_transport_class() + available_transports = [ + transports.JobServiceGrpcTransport, + ] + assert transport in available_transports + + transport = JobServiceClient.get_transport_class("grpc") + assert transport == transports.JobServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc"), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) +@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) +def test_job_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(JobServiceClient, '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(JobServiceClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", "true"), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", "false"), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) +@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_job_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + JobServiceClient, JobServiceAsyncClient +]) +@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) +@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) +def test_job_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", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc"), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_job_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", grpc_helpers), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_job_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, + api_audience=None, + ) + +def test_job_service_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4.services.job_service.transports.JobServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = JobServiceClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", grpc_helpers), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_job_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, + api_audience=None, + ) + + # 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", [ + job_service.CreateJobRequest, + dict, +]) +def test_create_job(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + ) + response = client.create_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.CreateJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +def test_create_job_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 = JobServiceClient( + 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_job), + '__call__') as call: + client.create_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.CreateJobRequest() + +@pytest.mark.asyncio +async def test_create_job_async(transport: str = 'grpc_asyncio', request_type=job_service.CreateJobRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + )) + response = await client.create_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.CreateJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +@pytest.mark.asyncio +async def test_create_job_async_from_dict(): + await test_create_job_async(request_type=dict) + + +def test_create_job_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 = job_service.CreateJobRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_job), + '__call__') as call: + call.return_value = gct_job.Job() + client.create_job(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_job_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 = job_service.CreateJobRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_job), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) + await client.create_job(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_job_flattened(): + 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.create_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_job( + parent='parent_value', + job=gct_job.Job(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].job + mock_val = gct_job.Job(name='name_value') + assert arg == mock_val + + +def test_create_job_flattened_error(): + client = JobServiceClient( + 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_job( + job_service.CreateJobRequest(), + parent='parent_value', + job=gct_job.Job(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_job_flattened_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.create_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_job( + parent='parent_value', + job=gct_job.Job(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].job + mock_val = gct_job.Job(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_job_flattened_error_async(): + client = JobServiceAsyncClient( + 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_job( + job_service.CreateJobRequest(), + parent='parent_value', + job=gct_job.Job(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.BatchCreateJobsRequest, + dict, +]) +def test_batch_create_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.batch_create_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchCreateJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_batch_create_jobs_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 = JobServiceClient( + 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.batch_create_jobs), + '__call__') as call: + client.batch_create_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchCreateJobsRequest() + +@pytest.mark.asyncio +async def test_batch_create_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchCreateJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.batch_create_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchCreateJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_batch_create_jobs_async_from_dict(): + await test_batch_create_jobs_async(request_type=dict) + + +def test_batch_create_jobs_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 = job_service.BatchCreateJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_jobs), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.batch_create_jobs(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_batch_create_jobs_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 = job_service.BatchCreateJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.batch_create_jobs(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_batch_create_jobs_flattened(): + 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.batch_create_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.batch_create_jobs( + parent='parent_value', + jobs=[job.Job(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].jobs + mock_val = [job.Job(name='name_value')] + assert arg == mock_val + + +def test_batch_create_jobs_flattened_error(): + client = JobServiceClient( + 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.batch_create_jobs( + job_service.BatchCreateJobsRequest(), + parent='parent_value', + jobs=[job.Job(name='name_value')], + ) + +@pytest.mark.asyncio +async def test_batch_create_jobs_flattened_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.batch_create_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.batch_create_jobs( + parent='parent_value', + jobs=[job.Job(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].jobs + mock_val = [job.Job(name='name_value')] + assert arg == mock_val + +@pytest.mark.asyncio +async def test_batch_create_jobs_flattened_error_async(): + client = JobServiceAsyncClient( + 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.batch_create_jobs( + job_service.BatchCreateJobsRequest(), + parent='parent_value', + jobs=[job.Job(name='name_value')], + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.GetJobRequest, + dict, +]) +def test_get_job(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + ) + response = client.get_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.GetJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +def test_get_job_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 = JobServiceClient( + 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_job), + '__call__') as call: + client.get_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.GetJobRequest() + +@pytest.mark.asyncio +async def test_get_job_async(transport: str = 'grpc_asyncio', request_type=job_service.GetJobRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + )) + response = await client.get_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.GetJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +@pytest.mark.asyncio +async def test_get_job_async_from_dict(): + await test_get_job_async(request_type=dict) + + +def test_get_job_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 = job_service.GetJobRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_job), + '__call__') as call: + call.return_value = job.Job() + client.get_job(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_job_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 = job_service.GetJobRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_job), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) + await client.get_job(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_job_flattened(): + 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_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job.Job() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_job( + 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_job_flattened_error(): + client = JobServiceClient( + 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_job( + job_service.GetJobRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_job_flattened_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_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job.Job() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_job( + 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_job_flattened_error_async(): + client = JobServiceAsyncClient( + 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_job( + job_service.GetJobRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.UpdateJobRequest, + dict, +]) +def test_update_job(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + ) + response = client.update_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.UpdateJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +def test_update_job_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 = JobServiceClient( + 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_job), + '__call__') as call: + client.update_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.UpdateJobRequest() + +@pytest.mark.asyncio +async def test_update_job_async(transport: str = 'grpc_asyncio', request_type=job_service.UpdateJobRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + )) + response = await client.update_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.UpdateJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +@pytest.mark.asyncio +async def test_update_job_async_from_dict(): + await test_update_job_async(request_type=dict) + + +def test_update_job_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 = job_service.UpdateJobRequest() + + request.job.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_job), + '__call__') as call: + call.return_value = gct_job.Job() + client.update_job(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', + 'job.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_job_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 = job_service.UpdateJobRequest() + + request.job.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_job), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) + await client.update_job(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', + 'job.name=name_value', + ) in kw['metadata'] + + +def test_update_job_flattened(): + 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.update_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_job( + job=gct_job.Job(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_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].job + mock_val = gct_job.Job(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_job_flattened_error(): + client = JobServiceClient( + 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_job( + job_service.UpdateJobRequest(), + job=gct_job.Job(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_job_flattened_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.update_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_job( + job=gct_job.Job(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_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].job + mock_val = gct_job.Job(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_job_flattened_error_async(): + client = JobServiceAsyncClient( + 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_job( + job_service.UpdateJobRequest(), + job=gct_job.Job(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.BatchUpdateJobsRequest, + dict, +]) +def test_batch_update_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.batch_update_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchUpdateJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_batch_update_jobs_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 = JobServiceClient( + 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.batch_update_jobs), + '__call__') as call: + client.batch_update_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchUpdateJobsRequest() + +@pytest.mark.asyncio +async def test_batch_update_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchUpdateJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.batch_update_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchUpdateJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_batch_update_jobs_async_from_dict(): + await test_batch_update_jobs_async(request_type=dict) + + +def test_batch_update_jobs_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 = job_service.BatchUpdateJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_jobs), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.batch_update_jobs(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_batch_update_jobs_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 = job_service.BatchUpdateJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.batch_update_jobs(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_batch_update_jobs_flattened(): + 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.batch_update_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.batch_update_jobs( + parent='parent_value', + jobs=[job.Job(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].jobs + mock_val = [job.Job(name='name_value')] + assert arg == mock_val + + +def test_batch_update_jobs_flattened_error(): + client = JobServiceClient( + 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.batch_update_jobs( + job_service.BatchUpdateJobsRequest(), + parent='parent_value', + jobs=[job.Job(name='name_value')], + ) + +@pytest.mark.asyncio +async def test_batch_update_jobs_flattened_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.batch_update_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.batch_update_jobs( + parent='parent_value', + jobs=[job.Job(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].jobs + mock_val = [job.Job(name='name_value')] + assert arg == mock_val + +@pytest.mark.asyncio +async def test_batch_update_jobs_flattened_error_async(): + client = JobServiceAsyncClient( + 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.batch_update_jobs( + job_service.BatchUpdateJobsRequest(), + parent='parent_value', + jobs=[job.Job(name='name_value')], + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.DeleteJobRequest, + dict, +]) +def test_delete_job(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.DeleteJobRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_job_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 = JobServiceClient( + 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_job), + '__call__') as call: + client.delete_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.DeleteJobRequest() + +@pytest.mark.asyncio +async def test_delete_job_async(transport: str = 'grpc_asyncio', request_type=job_service.DeleteJobRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.DeleteJobRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_job_async_from_dict(): + await test_delete_job_async(request_type=dict) + + +def test_delete_job_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 = job_service.DeleteJobRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_job), + '__call__') as call: + call.return_value = None + client.delete_job(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_job_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 = job_service.DeleteJobRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_job), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_job(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_job_flattened(): + 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.delete_job), + '__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_job( + 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_job_flattened_error(): + client = JobServiceClient( + 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_job( + job_service.DeleteJobRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_job_flattened_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.delete_job), + '__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_job( + 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_job_flattened_error_async(): + client = JobServiceAsyncClient( + 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_job( + job_service.DeleteJobRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.BatchDeleteJobsRequest, + dict, +]) +def test_batch_delete_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.batch_delete_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchDeleteJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_batch_delete_jobs_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 = JobServiceClient( + 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.batch_delete_jobs), + '__call__') as call: + client.batch_delete_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchDeleteJobsRequest() + +@pytest.mark.asyncio +async def test_batch_delete_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchDeleteJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.batch_delete_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchDeleteJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_batch_delete_jobs_async_from_dict(): + await test_batch_delete_jobs_async(request_type=dict) + + +def test_batch_delete_jobs_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 = job_service.BatchDeleteJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_jobs), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.batch_delete_jobs(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_batch_delete_jobs_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 = job_service.BatchDeleteJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.batch_delete_jobs(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_batch_delete_jobs_flattened(): + 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.batch_delete_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.batch_delete_jobs( + parent='parent_value', + names=['names_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].names + mock_val = ['names_value'] + assert arg == mock_val + + +def test_batch_delete_jobs_flattened_error(): + client = JobServiceClient( + 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.batch_delete_jobs( + job_service.BatchDeleteJobsRequest(), + parent='parent_value', + names=['names_value'], + ) + +@pytest.mark.asyncio +async def test_batch_delete_jobs_flattened_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.batch_delete_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.batch_delete_jobs( + parent='parent_value', + names=['names_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].names + mock_val = ['names_value'] + assert arg == mock_val + +@pytest.mark.asyncio +async def test_batch_delete_jobs_flattened_error_async(): + client = JobServiceAsyncClient( + 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.batch_delete_jobs( + job_service.BatchDeleteJobsRequest(), + parent='parent_value', + names=['names_value'], + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.ListJobsRequest, + dict, +]) +def test_list_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.ListJobsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.ListJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListJobsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_jobs_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 = JobServiceClient( + 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_jobs), + '__call__') as call: + client.list_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.ListJobsRequest() + +@pytest.mark.asyncio +async def test_list_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.ListJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.ListJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListJobsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_jobs_async_from_dict(): + await test_list_jobs_async(request_type=dict) + + +def test_list_jobs_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 = job_service.ListJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_jobs), + '__call__') as call: + call.return_value = job_service.ListJobsResponse() + client.list_jobs(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_jobs_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 = job_service.ListJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse()) + await client.list_jobs(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_jobs_flattened(): + 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.list_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.ListJobsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_jobs( + parent='parent_value', + filter='filter_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].filter + mock_val = 'filter_value' + assert arg == mock_val + + +def test_list_jobs_flattened_error(): + client = JobServiceClient( + 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_jobs( + job_service.ListJobsRequest(), + parent='parent_value', + filter='filter_value', + ) + +@pytest.mark.asyncio +async def test_list_jobs_flattened_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.list_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.ListJobsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_jobs( + parent='parent_value', + filter='filter_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].filter + mock_val = 'filter_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_jobs_flattened_error_async(): + client = JobServiceAsyncClient( + 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_jobs( + job_service.ListJobsRequest(), + parent='parent_value', + filter='filter_value', + ) + + +def test_list_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + 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_jobs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + job.Job(), + ], + next_page_token='abc', + ), + job_service.ListJobsResponse( + jobs=[], + next_page_token='def', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + ], + next_page_token='ghi', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_jobs(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, job.Job) + for i in results) +def test_list_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + 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_jobs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + job.Job(), + ], + next_page_token='abc', + ), + job_service.ListJobsResponse( + jobs=[], + next_page_token='def', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + ], + next_page_token='ghi', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + ], + ), + RuntimeError, + ) + pages = list(client.list_jobs(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_jobs_async_pager(): + 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.list_jobs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + job.Job(), + ], + next_page_token='abc', + ), + job_service.ListJobsResponse( + jobs=[], + next_page_token='def', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + ], + next_page_token='ghi', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_jobs(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, job.Job) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_jobs_async_pages(): + 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.list_jobs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + job.Job(), + ], + next_page_token='abc', + ), + job_service.ListJobsResponse( + jobs=[], + next_page_token='def', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + ], + next_page_token='ghi', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_jobs(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", [ + job_service.SearchJobsRequest, + dict, +]) +def test_search_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.SearchJobsResponse( + next_page_token='next_page_token_value', + total_size=1086, + broadened_query_jobs_count=2766, + ) + response = client.search_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + + # Establish that the response is the type that we expect. + assert response.raw_page is response + assert isinstance(response, job_service.SearchJobsResponse) + assert response.next_page_token == 'next_page_token_value' + assert response.total_size == 1086 + assert response.broadened_query_jobs_count == 2766 + + +def test_search_jobs_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 = JobServiceClient( + 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_jobs), + '__call__') as call: + client.search_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + +@pytest.mark.asyncio +async def test_search_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.SearchJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse( + next_page_token='next_page_token_value', + total_size=1086, + broadened_query_jobs_count=2766, + )) + response = await client.search_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, job_service.SearchJobsResponse) + assert response.next_page_token == 'next_page_token_value' + assert response.total_size == 1086 + assert response.broadened_query_jobs_count == 2766 + + +@pytest.mark.asyncio +async def test_search_jobs_async_from_dict(): + await test_search_jobs_async(request_type=dict) + + +def test_search_jobs_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 = job_service.SearchJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs), + '__call__') as call: + call.return_value = job_service.SearchJobsResponse() + client.search_jobs(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_jobs_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 = job_service.SearchJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse()) + await client.search_jobs(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'] + + +@pytest.mark.parametrize("request_type", [ + job_service.SearchJobsRequest, + dict, +]) +def test_search_jobs_for_alert(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs_for_alert), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.SearchJobsResponse( + next_page_token='next_page_token_value', + total_size=1086, + broadened_query_jobs_count=2766, + ) + response = client.search_jobs_for_alert(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + + # Establish that the response is the type that we expect. + assert response.raw_page is response + assert isinstance(response, job_service.SearchJobsResponse) + assert response.next_page_token == 'next_page_token_value' + assert response.total_size == 1086 + assert response.broadened_query_jobs_count == 2766 + + +def test_search_jobs_for_alert_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 = JobServiceClient( + 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_jobs_for_alert), + '__call__') as call: + client.search_jobs_for_alert() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + +@pytest.mark.asyncio +async def test_search_jobs_for_alert_async(transport: str = 'grpc_asyncio', request_type=job_service.SearchJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs_for_alert), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse( + next_page_token='next_page_token_value', + total_size=1086, + broadened_query_jobs_count=2766, + )) + response = await client.search_jobs_for_alert(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, job_service.SearchJobsResponse) + assert response.next_page_token == 'next_page_token_value' + assert response.total_size == 1086 + assert response.broadened_query_jobs_count == 2766 + + +@pytest.mark.asyncio +async def test_search_jobs_for_alert_async_from_dict(): + await test_search_jobs_for_alert_async(request_type=dict) + + +def test_search_jobs_for_alert_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 = job_service.SearchJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs_for_alert), + '__call__') as call: + call.return_value = job_service.SearchJobsResponse() + client.search_jobs_for_alert(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_jobs_for_alert_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 = job_service.SearchJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs_for_alert), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse()) + await client.search_jobs_for_alert(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_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = JobServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = JobServiceClient( + 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 = JobServiceClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = JobServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = JobServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.JobServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.JobServiceGrpcTransport, + transports.JobServiceGrpcAsyncIOTransport, +]) +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 = JobServiceClient.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 = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.JobServiceGrpcTransport, + ) + +def test_job_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.JobServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_job_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4.services.job_service.transports.JobServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.JobServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_job', + 'batch_create_jobs', + 'get_job', + 'update_job', + 'batch_update_jobs', + 'delete_job', + 'batch_delete_jobs', + 'list_jobs', + 'search_jobs', + 'search_jobs_for_alert', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + # Catch all for all remaining methods and properties + remainder = [ + 'kind', + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + + +def test_job_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_v4.services.job_service.transports.JobServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.JobServiceTransport( + 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_job_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_v4.services.job_service.transports.JobServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.JobServiceTransport() + adc.assert_called_once() + + +def test_job_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) + JobServiceClient() + 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.JobServiceGrpcTransport, + transports.JobServiceGrpcAsyncIOTransport, + ], +) +def test_job_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", + [ + 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", + [ + (transports.JobServiceGrpcTransport, grpc_helpers), + (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_job_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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) +def test_job_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_job_service_host_no_port(transport_name): + client = JobServiceClient( + 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_job_service_host_with_port(transport_name): + client = JobServiceClient( + 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_job_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.JobServiceGrpcTransport( + 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_job_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.JobServiceGrpcAsyncIOTransport( + 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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) +def test_job_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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) +def test_job_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_job_service_grpc_lro_client(): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_job_service_grpc_lro_async_client(): + client = JobServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc_asyncio', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) + actual = JobServiceClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = JobServiceClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_company_path(path) + assert expected == actual + +def test_job_path(): + project = "cuttlefish" + tenant = "mussel" + job = "winkle" + expected = "projects/{project}/tenants/{tenant}/jobs/{job}".format(project=project, tenant=tenant, job=job, ) + actual = JobServiceClient.job_path(project, tenant, job) + assert expected == actual + + +def test_parse_job_path(): + expected = { + "project": "nautilus", + "tenant": "scallop", + "job": "abalone", + } + path = JobServiceClient.job_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_job_path(path) + assert expected == actual + +def test_tenant_path(): + project = "squid" + tenant = "clam" + expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) + actual = JobServiceClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "whelk", + "tenant": "octopus", + } + path = JobServiceClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_tenant_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "oyster" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = JobServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nudibranch", + } + path = JobServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "cuttlefish" + expected = "folders/{folder}".format(folder=folder, ) + actual = JobServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "mussel", + } + path = JobServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "winkle" + expected = "organizations/{organization}".format(organization=organization, ) + actual = JobServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nautilus", + } + path = JobServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "scallop" + expected = "projects/{project}".format(project=project, ) + actual = JobServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "abalone", + } + path = JobServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "squid" + location = "clam" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = JobServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = JobServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.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.JobServiceTransport, '_prep_wrapped_messages') as prep: + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.JobServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = JobServiceClient.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 = JobServiceAsyncClient( + 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 = JobServiceClient( + 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 = JobServiceClient( + 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", [ + (JobServiceClient, transports.JobServiceGrpcTransport), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_tenant_service.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_tenant_service.py new file mode 100644 index 00000000..e2d7945c --- /dev/null +++ b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_tenant_service.py @@ -0,0 +1,2543 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4.services.tenant_service import TenantServiceAsyncClient +from google.cloud.talent_v4.services.tenant_service import TenantServiceClient +from google.cloud.talent_v4.services.tenant_service import pagers +from google.cloud.talent_v4.services.tenant_service import transports +from google.cloud.talent_v4.types import tenant +from google.cloud.talent_v4.types import tenant as gct_tenant +from google.cloud.talent_v4.types import tenant_service +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +import google.auth + + +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 TenantServiceClient._get_default_mtls_endpoint(None) is None + assert TenantServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert TenantServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert TenantServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert TenantServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert TenantServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (TenantServiceClient, "grpc"), + (TenantServiceAsyncClient, "grpc_asyncio"), +]) +def test_tenant_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.TenantServiceGrpcTransport, "grpc"), + (transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_tenant_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", [ + (TenantServiceClient, "grpc"), + (TenantServiceAsyncClient, "grpc_asyncio"), +]) +def test_tenant_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_tenant_service_client_get_transport_class(): + transport = TenantServiceClient.get_transport_class() + available_transports = [ + transports.TenantServiceGrpcTransport, + ] + assert transport in available_transports + + transport = TenantServiceClient.get_transport_class("grpc") + assert transport == transports.TenantServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc"), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) +@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) +def test_tenant_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(TenantServiceClient, '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(TenantServiceClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", "true"), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", "false"), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) +@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_tenant_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + TenantServiceClient, TenantServiceAsyncClient +]) +@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) +@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) +def test_tenant_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", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc"), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_tenant_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", grpc_helpers), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_tenant_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, + api_audience=None, + ) + +def test_tenant_service_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4.services.tenant_service.transports.TenantServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = TenantServiceClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", grpc_helpers), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_tenant_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, + api_audience=None, + ) + + # 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", [ + tenant_service.CreateTenantRequest, + dict, +]) +def test_create_tenant(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant( + name='name_value', + external_id='external_id_value', + ) + response = client.create_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.CreateTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + + +def test_create_tenant_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 = TenantServiceClient( + 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_tenant), + '__call__') as call: + client.create_tenant() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.CreateTenantRequest() + +@pytest.mark.asyncio +async def test_create_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.CreateTenantRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant( + name='name_value', + external_id='external_id_value', + )) + response = await client.create_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.CreateTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + + +@pytest.mark.asyncio +async def test_create_tenant_async_from_dict(): + await test_create_tenant_async(request_type=dict) + + +def test_create_tenant_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 = tenant_service.CreateTenantRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tenant), + '__call__') as call: + call.return_value = gct_tenant.Tenant() + client.create_tenant(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_tenant_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 = tenant_service.CreateTenantRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tenant), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) + await client.create_tenant(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_tenant_flattened(): + 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.create_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_tenant( + parent='parent_value', + tenant=gct_tenant.Tenant(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].tenant + mock_val = gct_tenant.Tenant(name='name_value') + assert arg == mock_val + + +def test_create_tenant_flattened_error(): + client = TenantServiceClient( + 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_tenant( + tenant_service.CreateTenantRequest(), + parent='parent_value', + tenant=gct_tenant.Tenant(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_tenant_flattened_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.create_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_tenant( + parent='parent_value', + tenant=gct_tenant.Tenant(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].tenant + mock_val = gct_tenant.Tenant(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_tenant_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenant( + tenant_service.CreateTenantRequest(), + parent='parent_value', + tenant=gct_tenant.Tenant(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + tenant_service.GetTenantRequest, + dict, +]) +def test_get_tenant(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant.Tenant( + name='name_value', + external_id='external_id_value', + ) + response = client.get_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.GetTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + + +def test_get_tenant_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 = TenantServiceClient( + 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_tenant), + '__call__') as call: + client.get_tenant() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.GetTenantRequest() + +@pytest.mark.asyncio +async def test_get_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.GetTenantRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant( + name='name_value', + external_id='external_id_value', + )) + response = await client.get_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.GetTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + + +@pytest.mark.asyncio +async def test_get_tenant_async_from_dict(): + await test_get_tenant_async(request_type=dict) + + +def test_get_tenant_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 = tenant_service.GetTenantRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tenant), + '__call__') as call: + call.return_value = tenant.Tenant() + client.get_tenant(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_tenant_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 = tenant_service.GetTenantRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tenant), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) + await client.get_tenant(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_tenant_flattened(): + 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_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant.Tenant() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_tenant( + 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_tenant_flattened_error(): + client = TenantServiceClient( + 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_tenant( + tenant_service.GetTenantRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_tenant_flattened_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_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant.Tenant() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_tenant( + 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_tenant_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenant( + tenant_service.GetTenantRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + tenant_service.UpdateTenantRequest, + dict, +]) +def test_update_tenant(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant( + name='name_value', + external_id='external_id_value', + ) + response = client.update_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.UpdateTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + + +def test_update_tenant_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 = TenantServiceClient( + 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_tenant), + '__call__') as call: + client.update_tenant() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.UpdateTenantRequest() + +@pytest.mark.asyncio +async def test_update_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.UpdateTenantRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant( + name='name_value', + external_id='external_id_value', + )) + response = await client.update_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.UpdateTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + + +@pytest.mark.asyncio +async def test_update_tenant_async_from_dict(): + await test_update_tenant_async(request_type=dict) + + +def test_update_tenant_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 = tenant_service.UpdateTenantRequest() + + request.tenant.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tenant), + '__call__') as call: + call.return_value = gct_tenant.Tenant() + client.update_tenant(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', + 'tenant.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_tenant_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 = tenant_service.UpdateTenantRequest() + + request.tenant.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tenant), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) + await client.update_tenant(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', + 'tenant.name=name_value', + ) in kw['metadata'] + + +def test_update_tenant_flattened(): + 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.update_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_tenant( + tenant=gct_tenant.Tenant(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_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].tenant + mock_val = gct_tenant.Tenant(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_tenant_flattened_error(): + client = TenantServiceClient( + 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_tenant( + tenant_service.UpdateTenantRequest(), + tenant=gct_tenant.Tenant(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_tenant_flattened_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.update_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_tenant( + tenant=gct_tenant.Tenant(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_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].tenant + mock_val = gct_tenant.Tenant(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_tenant_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenant( + tenant_service.UpdateTenantRequest(), + tenant=gct_tenant.Tenant(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + tenant_service.DeleteTenantRequest, + dict, +]) +def test_delete_tenant(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.DeleteTenantRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_tenant_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 = TenantServiceClient( + 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_tenant), + '__call__') as call: + client.delete_tenant() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.DeleteTenantRequest() + +@pytest.mark.asyncio +async def test_delete_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.DeleteTenantRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.DeleteTenantRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_tenant_async_from_dict(): + await test_delete_tenant_async(request_type=dict) + + +def test_delete_tenant_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 = tenant_service.DeleteTenantRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tenant), + '__call__') as call: + call.return_value = None + client.delete_tenant(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_tenant_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 = tenant_service.DeleteTenantRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tenant), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_tenant(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_tenant_flattened(): + 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.delete_tenant), + '__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_tenant( + 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_tenant_flattened_error(): + client = TenantServiceClient( + 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_tenant( + tenant_service.DeleteTenantRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_tenant_flattened_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.delete_tenant), + '__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_tenant( + 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_tenant_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenant( + tenant_service.DeleteTenantRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + tenant_service.ListTenantsRequest, + dict, +]) +def test_list_tenants(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tenants), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant_service.ListTenantsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_tenants(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.ListTenantsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTenantsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_tenants_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 = TenantServiceClient( + 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_tenants), + '__call__') as call: + client.list_tenants() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.ListTenantsRequest() + +@pytest.mark.asyncio +async def test_list_tenants_async(transport: str = 'grpc_asyncio', request_type=tenant_service.ListTenantsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tenants), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_tenants(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.ListTenantsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTenantsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_tenants_async_from_dict(): + await test_list_tenants_async(request_type=dict) + + +def test_list_tenants_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 = tenant_service.ListTenantsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tenants), + '__call__') as call: + call.return_value = tenant_service.ListTenantsResponse() + client.list_tenants(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_tenants_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 = tenant_service.ListTenantsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tenants), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse()) + await client.list_tenants(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_tenants_flattened(): + 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.list_tenants), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant_service.ListTenantsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_tenants( + 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_tenants_flattened_error(): + client = TenantServiceClient( + 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_tenants( + tenant_service.ListTenantsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_tenants_flattened_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.list_tenants), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant_service.ListTenantsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_tenants( + 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_tenants_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenants( + tenant_service.ListTenantsRequest(), + parent='parent_value', + ) + + +def test_list_tenants_pager(transport_name: str = "grpc"): + client = TenantServiceClient( + 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_tenants), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + tenant.Tenant(), + ], + next_page_token='abc', + ), + tenant_service.ListTenantsResponse( + tenants=[], + next_page_token='def', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + ], + next_page_token='ghi', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_tenants(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, tenant.Tenant) + for i in results) +def test_list_tenants_pages(transport_name: str = "grpc"): + client = TenantServiceClient( + 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_tenants), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + tenant.Tenant(), + ], + next_page_token='abc', + ), + tenant_service.ListTenantsResponse( + tenants=[], + next_page_token='def', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + ], + next_page_token='ghi', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + ], + ), + RuntimeError, + ) + pages = list(client.list_tenants(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_tenants_async_pager(): + 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.list_tenants), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + tenant.Tenant(), + ], + next_page_token='abc', + ), + tenant_service.ListTenantsResponse( + tenants=[], + next_page_token='def', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + ], + next_page_token='ghi', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_tenants(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, tenant.Tenant) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_tenants_async_pages(): + 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.list_tenants), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + tenant.Tenant(), + ], + next_page_token='abc', + ), + tenant_service.ListTenantsResponse( + tenants=[], + next_page_token='def', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + ], + next_page_token='ghi', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_tenants(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.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = TenantServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = TenantServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TenantServiceClient( + 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 = TenantServiceClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = TenantServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = TenantServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.TenantServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.TenantServiceGrpcTransport, + transports.TenantServiceGrpcAsyncIOTransport, +]) +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 = TenantServiceClient.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 = TenantServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.TenantServiceGrpcTransport, + ) + +def test_tenant_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.TenantServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_tenant_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4.services.tenant_service.transports.TenantServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.TenantServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_tenant', + 'get_tenant', + 'update_tenant', + 'delete_tenant', + 'list_tenants', + ) + 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_tenant_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_v4.services.tenant_service.transports.TenantServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.TenantServiceTransport( + 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_tenant_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_v4.services.tenant_service.transports.TenantServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.TenantServiceTransport() + adc.assert_called_once() + + +def test_tenant_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) + TenantServiceClient() + 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.TenantServiceGrpcTransport, + transports.TenantServiceGrpcAsyncIOTransport, + ], +) +def test_tenant_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", + [ + 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", + [ + (transports.TenantServiceGrpcTransport, grpc_helpers), + (transports.TenantServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_tenant_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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) +def test_tenant_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_tenant_service_host_no_port(transport_name): + client = TenantServiceClient( + 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_tenant_service_host_with_port(transport_name): + client = TenantServiceClient( + 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_tenant_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.TenantServiceGrpcTransport( + 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_tenant_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.TenantServiceGrpcAsyncIOTransport( + 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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) +def test_tenant_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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) +def test_tenant_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_tenant_path(): + project = "squid" + tenant = "clam" + expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) + actual = TenantServiceClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "whelk", + "tenant": "octopus", + } + path = TenantServiceClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_tenant_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "oyster" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = TenantServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nudibranch", + } + path = TenantServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "cuttlefish" + expected = "folders/{folder}".format(folder=folder, ) + actual = TenantServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "mussel", + } + path = TenantServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "winkle" + expected = "organizations/{organization}".format(organization=organization, ) + actual = TenantServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nautilus", + } + path = TenantServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "scallop" + expected = "projects/{project}".format(project=project, ) + actual = TenantServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "abalone", + } + path = TenantServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "squid" + location = "clam" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = TenantServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = TenantServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.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.TenantServiceTransport, '_prep_wrapped_messages') as prep: + client = TenantServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.TenantServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = TenantServiceClient.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 = TenantServiceAsyncClient( + 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 = TenantServiceClient( + 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 = TenantServiceClient( + 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", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) diff --git a/owl-bot-staging/v4beta1/.coveragerc b/owl-bot-staging/v4beta1/.coveragerc new file mode 100644 index 00000000..4ad22152 --- /dev/null +++ b/owl-bot-staging/v4beta1/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/talent/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v4beta1/.flake8 b/owl-bot-staging/v4beta1/.flake8 new file mode 100644 index 00000000..29227d4c --- /dev/null +++ b/owl-bot-staging/v4beta1/.flake8 @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 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 +# +# https://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 by synthtool. DO NOT EDIT! +[flake8] +ignore = E203, E266, E501, W503 +exclude = + # Exclude generated code. + **/proto/** + **/gapic/** + **/services/** + **/types/** + *_pb2.py + + # Standard linting exemptions. + **/.nox/** + __pycache__, + .git, + *.pyc, + conf.py diff --git a/owl-bot-staging/v4beta1/MANIFEST.in b/owl-bot-staging/v4beta1/MANIFEST.in new file mode 100644 index 00000000..2dd6511d --- /dev/null +++ b/owl-bot-staging/v4beta1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/talent *.py +recursive-include google/cloud/talent_v4beta1 *.py diff --git a/owl-bot-staging/v4beta1/README.rst b/owl-bot-staging/v4beta1/README.rst new file mode 100644 index 00000000..97bb9aff --- /dev/null +++ b/owl-bot-staging/v4beta1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Talent API +================================================= + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. Enable the Google Cloud Talent API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v4beta1/docs/conf.py b/owl-bot-staging/v4beta1/docs/conf.py new file mode 100644 index 00000000..3dd2f845 --- /dev/null +++ b/owl-bot-staging/v4beta1/docs/conf.py @@ -0,0 +1,376 @@ +# -*- 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. +# +# +# google-cloud-talent documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "4.0.1" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The root toctree document. +root_doc = "index" + +# General information about the project. +project = u"google-cloud-talent" +copyright = u"2022, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-talent-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + root_doc, + "google-cloud-talent.tex", + u"google-cloud-talent Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + root_doc, + "google-cloud-talent", + u"Google Cloud Talent Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + root_doc, + "google-cloud-talent", + u"google-cloud-talent Documentation", + author, + "google-cloud-talent", + "GAPIC library for Google Cloud Talent API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/v4beta1/docs/index.rst b/owl-bot-staging/v4beta1/docs/index.rst new file mode 100644 index 00000000..67a267d0 --- /dev/null +++ b/owl-bot-staging/v4beta1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + talent_v4beta1/services + talent_v4beta1/types diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/company_service.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/company_service.rst new file mode 100644 index 00000000..b77843f6 --- /dev/null +++ b/owl-bot-staging/v4beta1/docs/talent_v4beta1/company_service.rst @@ -0,0 +1,10 @@ +CompanyService +-------------------------------- + +.. automodule:: google.cloud.talent_v4beta1.services.company_service + :members: + :inherited-members: + +.. automodule:: google.cloud.talent_v4beta1.services.company_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/completion.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/completion.rst new file mode 100644 index 00000000..764a23f3 --- /dev/null +++ b/owl-bot-staging/v4beta1/docs/talent_v4beta1/completion.rst @@ -0,0 +1,6 @@ +Completion +---------------------------- + +.. automodule:: google.cloud.talent_v4beta1.services.completion + :members: + :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/event_service.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/event_service.rst new file mode 100644 index 00000000..8e489d4c --- /dev/null +++ b/owl-bot-staging/v4beta1/docs/talent_v4beta1/event_service.rst @@ -0,0 +1,6 @@ +EventService +------------------------------ + +.. automodule:: google.cloud.talent_v4beta1.services.event_service + :members: + :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/job_service.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/job_service.rst new file mode 100644 index 00000000..605042c2 --- /dev/null +++ b/owl-bot-staging/v4beta1/docs/talent_v4beta1/job_service.rst @@ -0,0 +1,10 @@ +JobService +---------------------------- + +.. automodule:: google.cloud.talent_v4beta1.services.job_service + :members: + :inherited-members: + +.. automodule:: google.cloud.talent_v4beta1.services.job_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/services.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/services.rst new file mode 100644 index 00000000..f7b55d45 --- /dev/null +++ b/owl-bot-staging/v4beta1/docs/talent_v4beta1/services.rst @@ -0,0 +1,10 @@ +Services for Google Cloud Talent v4beta1 API +============================================ +.. toctree:: + :maxdepth: 2 + + company_service + completion + event_service + job_service + tenant_service diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/tenant_service.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/tenant_service.rst new file mode 100644 index 00000000..cc5630b3 --- /dev/null +++ b/owl-bot-staging/v4beta1/docs/talent_v4beta1/tenant_service.rst @@ -0,0 +1,10 @@ +TenantService +------------------------------- + +.. automodule:: google.cloud.talent_v4beta1.services.tenant_service + :members: + :inherited-members: + +.. automodule:: google.cloud.talent_v4beta1.services.tenant_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/types.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/types.rst new file mode 100644 index 00000000..e6abbcac --- /dev/null +++ b/owl-bot-staging/v4beta1/docs/talent_v4beta1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Talent v4beta1 API +========================================= + +.. automodule:: google.cloud.talent_v4beta1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v4beta1/google/cloud/talent/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent/__init__.py new file mode 100644 index 00000000..babd23c7 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent/__init__.py @@ -0,0 +1,155 @@ +# -*- 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.cloud.talent_v4beta1.services.company_service.client import CompanyServiceClient +from google.cloud.talent_v4beta1.services.company_service.async_client import CompanyServiceAsyncClient +from google.cloud.talent_v4beta1.services.completion.client import CompletionClient +from google.cloud.talent_v4beta1.services.completion.async_client import CompletionAsyncClient +from google.cloud.talent_v4beta1.services.event_service.client import EventServiceClient +from google.cloud.talent_v4beta1.services.event_service.async_client import EventServiceAsyncClient +from google.cloud.talent_v4beta1.services.job_service.client import JobServiceClient +from google.cloud.talent_v4beta1.services.job_service.async_client import JobServiceAsyncClient +from google.cloud.talent_v4beta1.services.tenant_service.client import TenantServiceClient +from google.cloud.talent_v4beta1.services.tenant_service.async_client import TenantServiceAsyncClient + +from google.cloud.talent_v4beta1.types.common import BatchOperationMetadata +from google.cloud.talent_v4beta1.types.common import CompensationInfo +from google.cloud.talent_v4beta1.types.common import CustomAttribute +from google.cloud.talent_v4beta1.types.common import DeviceInfo +from google.cloud.talent_v4beta1.types.common import Location +from google.cloud.talent_v4beta1.types.common import RequestMetadata +from google.cloud.talent_v4beta1.types.common import ResponseMetadata +from google.cloud.talent_v4beta1.types.common import SpellingCorrection +from google.cloud.talent_v4beta1.types.common import TimestampRange +from google.cloud.talent_v4beta1.types.common import CommuteMethod +from google.cloud.talent_v4beta1.types.common import CompanySize +from google.cloud.talent_v4beta1.types.common import DegreeType +from google.cloud.talent_v4beta1.types.common import EmploymentType +from google.cloud.talent_v4beta1.types.common import HtmlSanitization +from google.cloud.talent_v4beta1.types.common import JobBenefit +from google.cloud.talent_v4beta1.types.common import JobCategory +from google.cloud.talent_v4beta1.types.common import JobLevel +from google.cloud.talent_v4beta1.types.common import PostingRegion +from google.cloud.talent_v4beta1.types.common import Visibility +from google.cloud.talent_v4beta1.types.company import Company +from google.cloud.talent_v4beta1.types.company_service import CreateCompanyRequest +from google.cloud.talent_v4beta1.types.company_service import DeleteCompanyRequest +from google.cloud.talent_v4beta1.types.company_service import GetCompanyRequest +from google.cloud.talent_v4beta1.types.company_service import ListCompaniesRequest +from google.cloud.talent_v4beta1.types.company_service import ListCompaniesResponse +from google.cloud.talent_v4beta1.types.company_service import UpdateCompanyRequest +from google.cloud.talent_v4beta1.types.completion_service import CompleteQueryRequest +from google.cloud.talent_v4beta1.types.completion_service import CompleteQueryResponse +from google.cloud.talent_v4beta1.types.event import ClientEvent +from google.cloud.talent_v4beta1.types.event import JobEvent +from google.cloud.talent_v4beta1.types.event_service import CreateClientEventRequest +from google.cloud.talent_v4beta1.types.filters import CommuteFilter +from google.cloud.talent_v4beta1.types.filters import CompensationFilter +from google.cloud.talent_v4beta1.types.filters import JobQuery +from google.cloud.talent_v4beta1.types.filters import LocationFilter +from google.cloud.talent_v4beta1.types.histogram import HistogramQuery +from google.cloud.talent_v4beta1.types.histogram import HistogramQueryResult +from google.cloud.talent_v4beta1.types.job import Job +from google.cloud.talent_v4beta1.types.job_service import BatchCreateJobsRequest +from google.cloud.talent_v4beta1.types.job_service import BatchDeleteJobsRequest +from google.cloud.talent_v4beta1.types.job_service import BatchUpdateJobsRequest +from google.cloud.talent_v4beta1.types.job_service import CreateJobRequest +from google.cloud.talent_v4beta1.types.job_service import DeleteJobRequest +from google.cloud.talent_v4beta1.types.job_service import GetJobRequest +from google.cloud.talent_v4beta1.types.job_service import JobOperationResult +from google.cloud.talent_v4beta1.types.job_service import ListJobsRequest +from google.cloud.talent_v4beta1.types.job_service import ListJobsResponse +from google.cloud.talent_v4beta1.types.job_service import SearchJobsRequest +from google.cloud.talent_v4beta1.types.job_service import SearchJobsResponse +from google.cloud.talent_v4beta1.types.job_service import UpdateJobRequest +from google.cloud.talent_v4beta1.types.job_service import JobView +from google.cloud.talent_v4beta1.types.tenant import Tenant +from google.cloud.talent_v4beta1.types.tenant_service import CreateTenantRequest +from google.cloud.talent_v4beta1.types.tenant_service import DeleteTenantRequest +from google.cloud.talent_v4beta1.types.tenant_service import GetTenantRequest +from google.cloud.talent_v4beta1.types.tenant_service import ListTenantsRequest +from google.cloud.talent_v4beta1.types.tenant_service import ListTenantsResponse +from google.cloud.talent_v4beta1.types.tenant_service import UpdateTenantRequest + +__all__ = ('CompanyServiceClient', + 'CompanyServiceAsyncClient', + 'CompletionClient', + 'CompletionAsyncClient', + 'EventServiceClient', + 'EventServiceAsyncClient', + 'JobServiceClient', + 'JobServiceAsyncClient', + 'TenantServiceClient', + 'TenantServiceAsyncClient', + 'BatchOperationMetadata', + 'CompensationInfo', + 'CustomAttribute', + 'DeviceInfo', + 'Location', + 'RequestMetadata', + 'ResponseMetadata', + 'SpellingCorrection', + 'TimestampRange', + 'CommuteMethod', + 'CompanySize', + 'DegreeType', + 'EmploymentType', + 'HtmlSanitization', + 'JobBenefit', + 'JobCategory', + 'JobLevel', + 'PostingRegion', + 'Visibility', + 'Company', + 'CreateCompanyRequest', + 'DeleteCompanyRequest', + 'GetCompanyRequest', + 'ListCompaniesRequest', + 'ListCompaniesResponse', + 'UpdateCompanyRequest', + 'CompleteQueryRequest', + 'CompleteQueryResponse', + 'ClientEvent', + 'JobEvent', + 'CreateClientEventRequest', + 'CommuteFilter', + 'CompensationFilter', + 'JobQuery', + 'LocationFilter', + 'HistogramQuery', + 'HistogramQueryResult', + 'Job', + 'BatchCreateJobsRequest', + 'BatchDeleteJobsRequest', + 'BatchUpdateJobsRequest', + 'CreateJobRequest', + 'DeleteJobRequest', + 'GetJobRequest', + 'JobOperationResult', + 'ListJobsRequest', + 'ListJobsResponse', + 'SearchJobsRequest', + 'SearchJobsResponse', + 'UpdateJobRequest', + 'JobView', + 'Tenant', + 'CreateTenantRequest', + 'DeleteTenantRequest', + 'GetTenantRequest', + 'ListTenantsRequest', + 'ListTenantsResponse', + 'UpdateTenantRequest', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent/py.typed b/owl-bot-staging/v4beta1/google/cloud/talent/py.typed new file mode 100644 index 00000000..d9645927 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-talent package uses inline types. diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/__init__.py new file mode 100644 index 00000000..d9a40828 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/__init__.py @@ -0,0 +1,156 @@ +# -*- 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 .services.company_service import CompanyServiceClient +from .services.company_service import CompanyServiceAsyncClient +from .services.completion import CompletionClient +from .services.completion import CompletionAsyncClient +from .services.event_service import EventServiceClient +from .services.event_service import EventServiceAsyncClient +from .services.job_service import JobServiceClient +from .services.job_service import JobServiceAsyncClient +from .services.tenant_service import TenantServiceClient +from .services.tenant_service import TenantServiceAsyncClient + +from .types.common import BatchOperationMetadata +from .types.common import CompensationInfo +from .types.common import CustomAttribute +from .types.common import DeviceInfo +from .types.common import Location +from .types.common import RequestMetadata +from .types.common import ResponseMetadata +from .types.common import SpellingCorrection +from .types.common import TimestampRange +from .types.common import CommuteMethod +from .types.common import CompanySize +from .types.common import DegreeType +from .types.common import EmploymentType +from .types.common import HtmlSanitization +from .types.common import JobBenefit +from .types.common import JobCategory +from .types.common import JobLevel +from .types.common import PostingRegion +from .types.common import Visibility +from .types.company import Company +from .types.company_service import CreateCompanyRequest +from .types.company_service import DeleteCompanyRequest +from .types.company_service import GetCompanyRequest +from .types.company_service import ListCompaniesRequest +from .types.company_service import ListCompaniesResponse +from .types.company_service import UpdateCompanyRequest +from .types.completion_service import CompleteQueryRequest +from .types.completion_service import CompleteQueryResponse +from .types.event import ClientEvent +from .types.event import JobEvent +from .types.event_service import CreateClientEventRequest +from .types.filters import CommuteFilter +from .types.filters import CompensationFilter +from .types.filters import JobQuery +from .types.filters import LocationFilter +from .types.histogram import HistogramQuery +from .types.histogram import HistogramQueryResult +from .types.job import Job +from .types.job_service import BatchCreateJobsRequest +from .types.job_service import BatchDeleteJobsRequest +from .types.job_service import BatchUpdateJobsRequest +from .types.job_service import CreateJobRequest +from .types.job_service import DeleteJobRequest +from .types.job_service import GetJobRequest +from .types.job_service import JobOperationResult +from .types.job_service import ListJobsRequest +from .types.job_service import ListJobsResponse +from .types.job_service import SearchJobsRequest +from .types.job_service import SearchJobsResponse +from .types.job_service import UpdateJobRequest +from .types.job_service import JobView +from .types.tenant import Tenant +from .types.tenant_service import CreateTenantRequest +from .types.tenant_service import DeleteTenantRequest +from .types.tenant_service import GetTenantRequest +from .types.tenant_service import ListTenantsRequest +from .types.tenant_service import ListTenantsResponse +from .types.tenant_service import UpdateTenantRequest + +__all__ = ( + 'CompanyServiceAsyncClient', + 'CompletionAsyncClient', + 'EventServiceAsyncClient', + 'JobServiceAsyncClient', + 'TenantServiceAsyncClient', +'BatchCreateJobsRequest', +'BatchDeleteJobsRequest', +'BatchOperationMetadata', +'BatchUpdateJobsRequest', +'ClientEvent', +'CommuteFilter', +'CommuteMethod', +'Company', +'CompanyServiceClient', +'CompanySize', +'CompensationFilter', +'CompensationInfo', +'CompleteQueryRequest', +'CompleteQueryResponse', +'CompletionClient', +'CreateClientEventRequest', +'CreateCompanyRequest', +'CreateJobRequest', +'CreateTenantRequest', +'CustomAttribute', +'DegreeType', +'DeleteCompanyRequest', +'DeleteJobRequest', +'DeleteTenantRequest', +'DeviceInfo', +'EmploymentType', +'EventServiceClient', +'GetCompanyRequest', +'GetJobRequest', +'GetTenantRequest', +'HistogramQuery', +'HistogramQueryResult', +'HtmlSanitization', +'Job', +'JobBenefit', +'JobCategory', +'JobEvent', +'JobLevel', +'JobOperationResult', +'JobQuery', +'JobServiceClient', +'JobView', +'ListCompaniesRequest', +'ListCompaniesResponse', +'ListJobsRequest', +'ListJobsResponse', +'ListTenantsRequest', +'ListTenantsResponse', +'Location', +'LocationFilter', +'PostingRegion', +'RequestMetadata', +'ResponseMetadata', +'SearchJobsRequest', +'SearchJobsResponse', +'SpellingCorrection', +'Tenant', +'TenantServiceClient', +'TimestampRange', +'UpdateCompanyRequest', +'UpdateJobRequest', +'UpdateTenantRequest', +'Visibility', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/gapic_metadata.json b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/gapic_metadata.json new file mode 100644 index 00000000..ca15e97b --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/gapic_metadata.json @@ -0,0 +1,299 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.talent_v4beta1", + "protoPackage": "google.cloud.talent.v4beta1", + "schema": "1.0", + "services": { + "CompanyService": { + "clients": { + "grpc": { + "libraryClient": "CompanyServiceClient", + "rpcs": { + "CreateCompany": { + "methods": [ + "create_company" + ] + }, + "DeleteCompany": { + "methods": [ + "delete_company" + ] + }, + "GetCompany": { + "methods": [ + "get_company" + ] + }, + "ListCompanies": { + "methods": [ + "list_companies" + ] + }, + "UpdateCompany": { + "methods": [ + "update_company" + ] + } + } + }, + "grpc-async": { + "libraryClient": "CompanyServiceAsyncClient", + "rpcs": { + "CreateCompany": { + "methods": [ + "create_company" + ] + }, + "DeleteCompany": { + "methods": [ + "delete_company" + ] + }, + "GetCompany": { + "methods": [ + "get_company" + ] + }, + "ListCompanies": { + "methods": [ + "list_companies" + ] + }, + "UpdateCompany": { + "methods": [ + "update_company" + ] + } + } + } + } + }, + "Completion": { + "clients": { + "grpc": { + "libraryClient": "CompletionClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "complete_query" + ] + } + } + }, + "grpc-async": { + "libraryClient": "CompletionAsyncClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "complete_query" + ] + } + } + } + } + }, + "EventService": { + "clients": { + "grpc": { + "libraryClient": "EventServiceClient", + "rpcs": { + "CreateClientEvent": { + "methods": [ + "create_client_event" + ] + } + } + }, + "grpc-async": { + "libraryClient": "EventServiceAsyncClient", + "rpcs": { + "CreateClientEvent": { + "methods": [ + "create_client_event" + ] + } + } + } + } + }, + "JobService": { + "clients": { + "grpc": { + "libraryClient": "JobServiceClient", + "rpcs": { + "BatchCreateJobs": { + "methods": [ + "batch_create_jobs" + ] + }, + "BatchDeleteJobs": { + "methods": [ + "batch_delete_jobs" + ] + }, + "BatchUpdateJobs": { + "methods": [ + "batch_update_jobs" + ] + }, + "CreateJob": { + "methods": [ + "create_job" + ] + }, + "DeleteJob": { + "methods": [ + "delete_job" + ] + }, + "GetJob": { + "methods": [ + "get_job" + ] + }, + "ListJobs": { + "methods": [ + "list_jobs" + ] + }, + "SearchJobs": { + "methods": [ + "search_jobs" + ] + }, + "SearchJobsForAlert": { + "methods": [ + "search_jobs_for_alert" + ] + }, + "UpdateJob": { + "methods": [ + "update_job" + ] + } + } + }, + "grpc-async": { + "libraryClient": "JobServiceAsyncClient", + "rpcs": { + "BatchCreateJobs": { + "methods": [ + "batch_create_jobs" + ] + }, + "BatchDeleteJobs": { + "methods": [ + "batch_delete_jobs" + ] + }, + "BatchUpdateJobs": { + "methods": [ + "batch_update_jobs" + ] + }, + "CreateJob": { + "methods": [ + "create_job" + ] + }, + "DeleteJob": { + "methods": [ + "delete_job" + ] + }, + "GetJob": { + "methods": [ + "get_job" + ] + }, + "ListJobs": { + "methods": [ + "list_jobs" + ] + }, + "SearchJobs": { + "methods": [ + "search_jobs" + ] + }, + "SearchJobsForAlert": { + "methods": [ + "search_jobs_for_alert" + ] + }, + "UpdateJob": { + "methods": [ + "update_job" + ] + } + } + } + } + }, + "TenantService": { + "clients": { + "grpc": { + "libraryClient": "TenantServiceClient", + "rpcs": { + "CreateTenant": { + "methods": [ + "create_tenant" + ] + }, + "DeleteTenant": { + "methods": [ + "delete_tenant" + ] + }, + "GetTenant": { + "methods": [ + "get_tenant" + ] + }, + "ListTenants": { + "methods": [ + "list_tenants" + ] + }, + "UpdateTenant": { + "methods": [ + "update_tenant" + ] + } + } + }, + "grpc-async": { + "libraryClient": "TenantServiceAsyncClient", + "rpcs": { + "CreateTenant": { + "methods": [ + "create_tenant" + ] + }, + "DeleteTenant": { + "methods": [ + "delete_tenant" + ] + }, + "GetTenant": { + "methods": [ + "get_tenant" + ] + }, + "ListTenants": { + "methods": [ + "list_tenants" + ] + }, + "UpdateTenant": { + "methods": [ + "update_tenant" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/py.typed b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/py.typed new file mode 100644 index 00000000..d9645927 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-talent package uses inline types. diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/__init__.py new file mode 100644 index 00000000..e8e1c384 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- 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. +# diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/__init__.py new file mode 100644 index 00000000..bf2d436c --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import CompanyServiceClient +from .async_client import CompanyServiceAsyncClient + +__all__ = ( + 'CompanyServiceClient', + 'CompanyServiceAsyncClient', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/async_client.py new file mode 100644 index 00000000..afd5fdcb --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/async_client.py @@ -0,0 +1,846 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +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 +from google.cloud.talent_v4beta1.types import company as gct_company +from google.cloud.talent_v4beta1.types import company_service +from google.longrunning import operations_pb2 +from .transports.base import CompanyServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport +from .client import CompanyServiceClient + + +class CompanyServiceAsyncClient: + """A service that handles company management, including CRUD and + enumeration. + """ + + _client: CompanyServiceClient + + DEFAULT_ENDPOINT = CompanyServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = CompanyServiceClient.DEFAULT_MTLS_ENDPOINT + + company_path = staticmethod(CompanyServiceClient.company_path) + parse_company_path = staticmethod(CompanyServiceClient.parse_company_path) + common_billing_account_path = staticmethod(CompanyServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(CompanyServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(CompanyServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(CompanyServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(CompanyServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(CompanyServiceClient.parse_common_organization_path) + common_project_path = staticmethod(CompanyServiceClient.common_project_path) + parse_common_project_path = staticmethod(CompanyServiceClient.parse_common_project_path) + common_location_path = staticmethod(CompanyServiceClient.common_location_path) + parse_common_location_path = staticmethod(CompanyServiceClient.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: + CompanyServiceAsyncClient: The constructed client. + """ + return CompanyServiceClient.from_service_account_info.__func__(CompanyServiceAsyncClient, 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: + CompanyServiceAsyncClient: The constructed client. + """ + return CompanyServiceClient.from_service_account_file.__func__(CompanyServiceAsyncClient, 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 CompanyServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> CompanyServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CompanyServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(CompanyServiceClient).get_transport_class, type(CompanyServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, CompanyServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the company 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, ~.CompanyServiceTransport]): 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 = CompanyServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_company(self, + request: Union[company_service.CreateCompanyRequest, dict] = None, + *, + parent: str = None, + company: gct_company.Company = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_company.Company: + r"""Creates a new company entity. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_create_company(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + company = talent_v4beta1.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4beta1.CreateCompanyRequest( + parent="parent_value", + company=company, + ) + + # Make the request + response = await client.create_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CreateCompanyRequest, dict]): + The request object. The Request of the CreateCompany + method. + parent (:class:`str`): + Required. Resource name of the tenant under which the + company is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created, for example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + company (:class:`google.cloud.talent_v4beta1.types.Company`): + Required. The company to be created. + This corresponds to the ``company`` 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.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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, company]) + 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 = company_service.CreateCompanyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if company is not None: + request.company = company + + # 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_company, + 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_company(self, + request: Union[company_service.GetCompanyRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> company.Company: + r"""Retrieves specified company. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_get_company(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetCompanyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.GetCompanyRequest, dict]): + The request object. Request for getting a company by + name. + name (:class:`str`): + Required. The resource name of the company to be + retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, + "projects/api-test-project/tenants/foo/companies/bar". + + If tenant id is unspecified, the default tenant is used, + for example, "projects/api-test-project/companies/bar". + + 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.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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 = company_service.GetCompanyRequest(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_company, + 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_company(self, + request: Union[company_service.UpdateCompanyRequest, dict] = None, + *, + company: gct_company.Company = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_company.Company: + r"""Updates specified company. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_update_company(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + company = talent_v4beta1.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4beta1.UpdateCompanyRequest( + company=company, + ) + + # Make the request + response = await client.update_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.UpdateCompanyRequest, dict]): + The request object. Request for updating a specified + company. + company (:class:`google.cloud.talent_v4beta1.types.Company`): + Required. The company resource to + replace the current resource in the + system. + + This corresponds to the ``company`` 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.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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([company]) + 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 = company_service.UpdateCompanyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if company is not None: + request.company = company + + # 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_company, + 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(( + ("company.name", request.company.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_company(self, + request: Union[company_service.DeleteCompanyRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes specified company. + Prerequisite: The company has no jobs associated with + it. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_delete_company(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteCompanyRequest( + name="name_value", + ) + + # Make the request + await client.delete_company(request=request) + + Args: + request (Union[google.cloud.talent_v4beta1.types.DeleteCompanyRequest, dict]): + The request object. Request to delete a company. + name (:class:`str`): + Required. The resource name of the company to be + deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/baz". + + If tenant id is unspecified, the default tenant is used, + for example, "projects/foo/companies/bar". + + 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 = company_service.DeleteCompanyRequest(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_company, + 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_companies(self, + request: Union[company_service.ListCompaniesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCompaniesAsyncPager: + r"""Lists all companies associated with the project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_list_companies(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListCompaniesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_companies(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.ListCompaniesRequest, dict]): + The request object. List companies for which the client + has ACL visibility. + parent (:class:`str`): + Required. Resource name of the tenant under which the + company is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenant/bar". + + If tenant id is unspecified, the default tenant will be + used, for example, "projects/foo". + + 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.company_service.pagers.ListCompaniesAsyncPager: + The List companies 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 = company_service.ListCompaniesRequest(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_companies, + 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.ListCompaniesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # 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 + + 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__ = ( + "CompanyServiceAsyncClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/client.py new file mode 100644 index 00000000..e54ab3bb --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/client.py @@ -0,0 +1,1027 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +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 +from google.cloud.talent_v4beta1.types import company as gct_company +from google.cloud.talent_v4beta1.types import company_service +from google.longrunning import operations_pb2 +from .transports.base import CompanyServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import CompanyServiceGrpcTransport +from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport + + +class CompanyServiceClientMeta(type): + """Metaclass for the CompanyService 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[CompanyServiceTransport]] + _transport_registry["grpc"] = CompanyServiceGrpcTransport + _transport_registry["grpc_asyncio"] = CompanyServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[CompanyServiceTransport]: + """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 CompanyServiceClient(metaclass=CompanyServiceClientMeta): + """A service that handles company 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: + CompanyServiceClient: 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: + CompanyServiceClient: 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) -> CompanyServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CompanyServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @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 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, CompanyServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the company 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, CompanyServiceTransport]): 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, CompanyServiceTransport): + # transport is a CompanyServiceTransport 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, + api_audience=client_options.api_audience, + ) + + def create_company(self, + request: Union[company_service.CreateCompanyRequest, dict] = None, + *, + parent: str = None, + company: gct_company.Company = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_company.Company: + r"""Creates a new company entity. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_create_company(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + company = talent_v4beta1.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4beta1.CreateCompanyRequest( + parent="parent_value", + company=company, + ) + + # Make the request + response = client.create_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CreateCompanyRequest, dict]): + The request object. The Request of the CreateCompany + method. + parent (str): + Required. Resource name of the tenant under which the + company is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created, for example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + company (google.cloud.talent_v4beta1.types.Company): + Required. The company to be created. + This corresponds to the ``company`` 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.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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, company]) + 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 company_service.CreateCompanyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.CreateCompanyRequest): + request = company_service.CreateCompanyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if company is not None: + request.company = company + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_company] + + # 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_company(self, + request: Union[company_service.GetCompanyRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> company.Company: + r"""Retrieves specified company. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_get_company(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetCompanyRequest( + name="name_value", + ) + + # Make the request + response = client.get_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.GetCompanyRequest, dict]): + The request object. Request for getting a company by + name. + name (str): + Required. The resource name of the company to be + retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, + "projects/api-test-project/tenants/foo/companies/bar". + + If tenant id is unspecified, the default tenant is used, + for example, "projects/api-test-project/companies/bar". + + 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.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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 company_service.GetCompanyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.GetCompanyRequest): + request = company_service.GetCompanyRequest(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_company] + + # 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_company(self, + request: Union[company_service.UpdateCompanyRequest, dict] = None, + *, + company: gct_company.Company = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_company.Company: + r"""Updates specified company. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_update_company(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + company = talent_v4beta1.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4beta1.UpdateCompanyRequest( + company=company, + ) + + # Make the request + response = client.update_company(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.UpdateCompanyRequest, dict]): + The request object. Request for updating a specified + company. + company (google.cloud.talent_v4beta1.types.Company): + Required. The company resource to + replace the current resource in the + system. + + This corresponds to the ``company`` 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.Company: + A Company resource represents a + company in the service. A company is the + entity that owns job postings, that is, + the hiring entity responsible for + employing applicants for the job + position. + + """ + # 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([company]) + 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 company_service.UpdateCompanyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.UpdateCompanyRequest): + request = company_service.UpdateCompanyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if company is not None: + request.company = company + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_company] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("company.name", request.company.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_company(self, + request: Union[company_service.DeleteCompanyRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes specified company. + Prerequisite: The company has no jobs associated with + it. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_delete_company(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteCompanyRequest( + name="name_value", + ) + + # Make the request + client.delete_company(request=request) + + Args: + request (Union[google.cloud.talent_v4beta1.types.DeleteCompanyRequest, dict]): + The request object. Request to delete a company. + name (str): + Required. The resource name of the company to be + deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/baz". + + If tenant id is unspecified, the default tenant is used, + for example, "projects/foo/companies/bar". + + 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 company_service.DeleteCompanyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.DeleteCompanyRequest): + request = company_service.DeleteCompanyRequest(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_company] + + # 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_companies(self, + request: Union[company_service.ListCompaniesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCompaniesPager: + r"""Lists all companies associated with the project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_list_companies(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListCompaniesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_companies(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.ListCompaniesRequest, dict]): + The request object. List companies for which the client + has ACL visibility. + parent (str): + Required. Resource name of the tenant under which the + company is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenant/bar". + + If tenant id is unspecified, the default tenant will be + used, for example, "projects/foo". + + 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.company_service.pagers.ListCompaniesPager: + The List companies 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 company_service.ListCompaniesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, company_service.ListCompaniesRequest): + request = company_service.ListCompaniesRequest(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_companies] + + # 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.ListCompaniesPager( + 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() + + 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( + gapic_version=pkg_resources.get_distribution( + "google-cloud-talent", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "CompanyServiceClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/pagers.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/pagers.py new file mode 100644 index 00000000..c37d1eaf --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/pagers.py @@ -0,0 +1,140 @@ +# -*- 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, Sequence, Tuple, Optional, Iterator + +from google.cloud.talent_v4beta1.types import company +from google.cloud.talent_v4beta1.types import company_service + + +class ListCompaniesPager: + """A pager for iterating through ``list_companies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.ListCompaniesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``companies`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCompanies`` requests and continue to iterate + through the ``companies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.ListCompaniesResponse` + 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[..., company_service.ListCompaniesResponse], + request: company_service.ListCompaniesRequest, + response: company_service.ListCompaniesResponse, + *, + 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.ListCompaniesRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.ListCompaniesResponse): + 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 = company_service.ListCompaniesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[company_service.ListCompaniesResponse]: + 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[company.Company]: + for page in self.pages: + yield from page.companies + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCompaniesAsyncPager: + """A pager for iterating through ``list_companies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.ListCompaniesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``companies`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCompanies`` requests and continue to iterate + through the ``companies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.ListCompaniesResponse` + 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[company_service.ListCompaniesResponse]], + request: company_service.ListCompaniesRequest, + response: company_service.ListCompaniesResponse, + *, + 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.ListCompaniesRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.ListCompaniesResponse): + 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 = company_service.ListCompaniesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[company_service.ListCompaniesResponse]: + 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[company.Company]: + async def async_generator(): + async for page in self.pages: + for response in page.companies: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py new file mode 100644 index 00000000..1b586f42 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 CompanyServiceTransport +from .grpc import CompanyServiceGrpcTransport +from .grpc_asyncio import CompanyServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[CompanyServiceTransport]] +_transport_registry['grpc'] = CompanyServiceGrpcTransport +_transport_registry['grpc_asyncio'] = CompanyServiceGrpcAsyncIOTransport + +__all__ = ( + 'CompanyServiceTransport', + 'CompanyServiceGrpcTransport', + 'CompanyServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/base.py new file mode 100644 index 00000000..6308966e --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/base.py @@ -0,0 +1,245 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4beta1.types import company +from google.cloud.talent_v4beta1.types import company as gct_company +from google.cloud.talent_v4beta1.types import company_service +from google.longrunning import operations_pb2 +from google.protobuf import empty_pb2 # type: ignore + +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 CompanyServiceTransport(abc.ABC): + """Abstract transport class for CompanyService.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.create_company: gapic_v1.method.wrap_method( + self.create_company, + default_timeout=30.0, + client_info=client_info, + ), + self.get_company: gapic_v1.method.wrap_method( + self.get_company, + 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_company: gapic_v1.method.wrap_method( + self.update_company, + default_timeout=30.0, + client_info=client_info, + ), + self.delete_company: gapic_v1.method.wrap_method( + self.delete_company, + 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_companies: gapic_v1.method.wrap_method( + self.list_companies, + 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_company(self) -> Callable[ + [company_service.CreateCompanyRequest], + Union[ + gct_company.Company, + Awaitable[gct_company.Company] + ]]: + raise NotImplementedError() + + @property + def get_company(self) -> Callable[ + [company_service.GetCompanyRequest], + Union[ + company.Company, + Awaitable[company.Company] + ]]: + raise NotImplementedError() + + @property + def update_company(self) -> Callable[ + [company_service.UpdateCompanyRequest], + Union[ + gct_company.Company, + Awaitable[gct_company.Company] + ]]: + raise NotImplementedError() + + @property + def delete_company(self) -> Callable[ + [company_service.DeleteCompanyRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def list_companies(self) -> Callable[ + [company_service.ListCompaniesRequest], + Union[ + company_service.ListCompaniesResponse, + Awaitable[company_service.ListCompaniesResponse] + ]]: + 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() + + +__all__ = ( + 'CompanyServiceTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py new file mode 100644 index 00000000..2e2c4a1e --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py @@ -0,0 +1,393 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4beta1.types import company +from google.cloud.talent_v4beta1.types import company as gct_company +from google.cloud.talent_v4beta1.types import company_service +from google.longrunning import operations_pb2 +from google.protobuf import empty_pb2 # type: ignore +from .base import CompanyServiceTransport, DEFAULT_CLIENT_INFO + + +class CompanyServiceGrpcTransport(CompanyServiceTransport): + """gRPC backend transport for CompanyService. + + A service that handles company 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_company(self) -> Callable[ + [company_service.CreateCompanyRequest], + gct_company.Company]: + r"""Return a callable for the create company method over gRPC. + + Creates a new company entity. + + Returns: + Callable[[~.CreateCompanyRequest], + ~.Company]: + 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_company' not in self._stubs: + self._stubs['create_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/CreateCompany', + request_serializer=company_service.CreateCompanyRequest.serialize, + response_deserializer=gct_company.Company.deserialize, + ) + return self._stubs['create_company'] + + @property + def get_company(self) -> Callable[ + [company_service.GetCompanyRequest], + company.Company]: + r"""Return a callable for the get company method over gRPC. + + Retrieves specified company. + + Returns: + Callable[[~.GetCompanyRequest], + ~.Company]: + 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_company' not in self._stubs: + self._stubs['get_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/GetCompany', + request_serializer=company_service.GetCompanyRequest.serialize, + response_deserializer=company.Company.deserialize, + ) + return self._stubs['get_company'] + + @property + def update_company(self) -> Callable[ + [company_service.UpdateCompanyRequest], + gct_company.Company]: + r"""Return a callable for the update company method over gRPC. + + Updates specified company. + + Returns: + Callable[[~.UpdateCompanyRequest], + ~.Company]: + 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_company' not in self._stubs: + self._stubs['update_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/UpdateCompany', + request_serializer=company_service.UpdateCompanyRequest.serialize, + response_deserializer=gct_company.Company.deserialize, + ) + return self._stubs['update_company'] + + @property + def delete_company(self) -> Callable[ + [company_service.DeleteCompanyRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete company method over gRPC. + + Deletes specified company. + Prerequisite: The company has no jobs associated with + it. + + Returns: + Callable[[~.DeleteCompanyRequest], + ~.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_company' not in self._stubs: + self._stubs['delete_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/DeleteCompany', + request_serializer=company_service.DeleteCompanyRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_company'] + + @property + def list_companies(self) -> Callable[ + [company_service.ListCompaniesRequest], + company_service.ListCompaniesResponse]: + r"""Return a callable for the list companies method over gRPC. + + Lists all companies associated with the project. + + Returns: + Callable[[~.ListCompaniesRequest], + ~.ListCompaniesResponse]: + 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_companies' not in self._stubs: + self._stubs['list_companies'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/ListCompanies', + request_serializer=company_service.ListCompaniesRequest.serialize, + response_deserializer=company_service.ListCompaniesResponse.deserialize, + ) + return self._stubs['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" + + +__all__ = ( + 'CompanyServiceGrpcTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py new file mode 100644 index 00000000..c2a5af33 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py @@ -0,0 +1,392 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4beta1.types import company +from google.cloud.talent_v4beta1.types import company as gct_company +from google.cloud.talent_v4beta1.types import company_service +from google.longrunning import operations_pb2 +from google.protobuf import empty_pb2 # type: ignore +from .base import CompanyServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import CompanyServiceGrpcTransport + + +class CompanyServiceGrpcAsyncIOTransport(CompanyServiceTransport): + """gRPC AsyncIO backend transport for CompanyService. + + A service that handles company 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_company(self) -> Callable[ + [company_service.CreateCompanyRequest], + Awaitable[gct_company.Company]]: + r"""Return a callable for the create company method over gRPC. + + Creates a new company entity. + + Returns: + Callable[[~.CreateCompanyRequest], + Awaitable[~.Company]]: + 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_company' not in self._stubs: + self._stubs['create_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/CreateCompany', + request_serializer=company_service.CreateCompanyRequest.serialize, + response_deserializer=gct_company.Company.deserialize, + ) + return self._stubs['create_company'] + + @property + def get_company(self) -> Callable[ + [company_service.GetCompanyRequest], + Awaitable[company.Company]]: + r"""Return a callable for the get company method over gRPC. + + Retrieves specified company. + + Returns: + Callable[[~.GetCompanyRequest], + Awaitable[~.Company]]: + 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_company' not in self._stubs: + self._stubs['get_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/GetCompany', + request_serializer=company_service.GetCompanyRequest.serialize, + response_deserializer=company.Company.deserialize, + ) + return self._stubs['get_company'] + + @property + def update_company(self) -> Callable[ + [company_service.UpdateCompanyRequest], + Awaitable[gct_company.Company]]: + r"""Return a callable for the update company method over gRPC. + + Updates specified company. + + Returns: + Callable[[~.UpdateCompanyRequest], + Awaitable[~.Company]]: + 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_company' not in self._stubs: + self._stubs['update_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/UpdateCompany', + request_serializer=company_service.UpdateCompanyRequest.serialize, + response_deserializer=gct_company.Company.deserialize, + ) + return self._stubs['update_company'] + + @property + def delete_company(self) -> Callable[ + [company_service.DeleteCompanyRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete company method over gRPC. + + Deletes specified company. + Prerequisite: The company has no jobs associated with + it. + + Returns: + Callable[[~.DeleteCompanyRequest], + 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_company' not in self._stubs: + self._stubs['delete_company'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/DeleteCompany', + request_serializer=company_service.DeleteCompanyRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_company'] + + @property + def list_companies(self) -> Callable[ + [company_service.ListCompaniesRequest], + Awaitable[company_service.ListCompaniesResponse]]: + r"""Return a callable for the list companies method over gRPC. + + Lists all companies associated with the project. + + Returns: + Callable[[~.ListCompaniesRequest], + Awaitable[~.ListCompaniesResponse]]: + 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_companies' not in self._stubs: + self._stubs['list_companies'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.CompanyService/ListCompanies', + request_serializer=company_service.ListCompaniesRequest.serialize, + response_deserializer=company_service.ListCompaniesResponse.deserialize, + ) + return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/__init__.py new file mode 100644 index 00000000..28d77594 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import CompletionClient +from .async_client import CompletionAsyncClient + +__all__ = ( + 'CompletionClient', + 'CompletionAsyncClient', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/async_client.py new file mode 100644 index 00000000..9428436e --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/async_client.py @@ -0,0 +1,345 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import completion_service +from google.longrunning import operations_pb2 +from .transports.base import CompletionTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport +from .client import CompletionClient + + +class CompletionAsyncClient: + """A service handles auto completion.""" + + _client: CompletionClient + + DEFAULT_ENDPOINT = CompletionClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = CompletionClient.DEFAULT_MTLS_ENDPOINT + + company_path = staticmethod(CompletionClient.company_path) + parse_company_path = staticmethod(CompletionClient.parse_company_path) + common_billing_account_path = staticmethod(CompletionClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(CompletionClient.parse_common_billing_account_path) + common_folder_path = staticmethod(CompletionClient.common_folder_path) + parse_common_folder_path = staticmethod(CompletionClient.parse_common_folder_path) + common_organization_path = staticmethod(CompletionClient.common_organization_path) + parse_common_organization_path = staticmethod(CompletionClient.parse_common_organization_path) + common_project_path = staticmethod(CompletionClient.common_project_path) + parse_common_project_path = staticmethod(CompletionClient.parse_common_project_path) + common_location_path = staticmethod(CompletionClient.common_location_path) + parse_common_location_path = staticmethod(CompletionClient.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: + CompletionAsyncClient: The constructed client. + """ + return CompletionClient.from_service_account_info.__func__(CompletionAsyncClient, 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: + CompletionAsyncClient: The constructed client. + """ + return CompletionClient.from_service_account_file.__func__(CompletionAsyncClient, 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 CompletionClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> CompletionTransport: + """Returns the transport used by the client instance. + + Returns: + CompletionTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(CompletionClient).get_transport_class, type(CompletionClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, CompletionTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the completion 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, ~.CompletionTransport]): 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 = CompletionClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def complete_query(self, + request: Union[completion_service.CompleteQueryRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> completion_service.CompleteQueryResponse: + r"""Completes the specified prefix with keyword + suggestions. Intended for use by a job search + auto-complete search box. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_complete_query(): + # Create a client + client = talent_v4beta1.CompletionAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.CompleteQueryRequest( + parent="parent_value", + query="query_value", + page_size=951, + ) + + # Make the request + response = await client.complete_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CompleteQueryRequest, dict]): + The request object. Auto-complete parameters. + 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.CompleteQueryResponse: + Response of auto-complete query. + """ + # Create or coerce a protobuf request object. + request = completion_service.CompleteQueryRequest(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.complete_query, + 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, + ) + + # 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 + + 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__ = ( + "CompletionAsyncClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/client.py new file mode 100644 index 00000000..9166016a --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/client.py @@ -0,0 +1,541 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import completion_service +from google.longrunning import operations_pb2 +from .transports.base import CompletionTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import CompletionGrpcTransport +from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport + + +class CompletionClientMeta(type): + """Metaclass for the Completion 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[CompletionTransport]] + _transport_registry["grpc"] = CompletionGrpcTransport + _transport_registry["grpc_asyncio"] = CompletionGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[CompletionTransport]: + """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 CompletionClient(metaclass=CompletionClientMeta): + """A service handles auto completion.""" + + @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: + CompletionClient: 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: + CompletionClient: 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) -> CompletionTransport: + """Returns the transport used by the client instance. + + Returns: + CompletionTransport: The transport used by the client + instance. + """ + return self._transport + + @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 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, CompletionTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the completion 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, CompletionTransport]): 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, CompletionTransport): + # transport is a CompletionTransport 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, + api_audience=client_options.api_audience, + ) + + def complete_query(self, + request: Union[completion_service.CompleteQueryRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> completion_service.CompleteQueryResponse: + r"""Completes the specified prefix with keyword + suggestions. Intended for use by a job search + auto-complete search box. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_complete_query(): + # Create a client + client = talent_v4beta1.CompletionClient() + + # Initialize request argument(s) + request = talent_v4beta1.CompleteQueryRequest( + parent="parent_value", + query="query_value", + page_size=951, + ) + + # Make the request + response = client.complete_query(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CompleteQueryRequest, dict]): + The request object. Auto-complete parameters. + 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.CompleteQueryResponse: + Response of auto-complete query. + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a completion_service.CompleteQueryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, completion_service.CompleteQueryRequest): + request = completion_service.CompleteQueryRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.complete_query] + + # 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 __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() + + 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( + gapic_version=pkg_resources.get_distribution( + "google-cloud-talent", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "CompletionClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/__init__.py new file mode 100644 index 00000000..14e86855 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 CompletionTransport +from .grpc import CompletionGrpcTransport +from .grpc_asyncio import CompletionGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[CompletionTransport]] +_transport_registry['grpc'] = CompletionGrpcTransport +_transport_registry['grpc_asyncio'] = CompletionGrpcAsyncIOTransport + +__all__ = ( + 'CompletionTransport', + 'CompletionGrpcTransport', + 'CompletionGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/base.py new file mode 100644 index 00000000..63ea341e --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/base.py @@ -0,0 +1,172 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4beta1.types import completion_service +from google.longrunning import operations_pb2 + +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 CompletionTransport(abc.ABC): + """Abstract transport class for Completion.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.complete_query: gapic_v1.method.wrap_method( + self.complete_query, + 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 complete_query(self) -> Callable[ + [completion_service.CompleteQueryRequest], + Union[ + completion_service.CompleteQueryResponse, + Awaitable[completion_service.CompleteQueryResponse] + ]]: + 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() + + +__all__ = ( + 'CompletionTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc.py new file mode 100644 index 00000000..362f4a2b --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc.py @@ -0,0 +1,285 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4beta1.types import completion_service +from google.longrunning import operations_pb2 +from .base import CompletionTransport, DEFAULT_CLIENT_INFO + + +class CompletionGrpcTransport(CompletionTransport): + """gRPC backend transport for Completion. + + A service handles auto completion. + + 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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 complete_query(self) -> Callable[ + [completion_service.CompleteQueryRequest], + completion_service.CompleteQueryResponse]: + r"""Return a callable for the complete query method over gRPC. + + Completes the specified prefix with keyword + suggestions. Intended for use by a job search + auto-complete search box. + + Returns: + Callable[[~.CompleteQueryRequest], + ~.CompleteQueryResponse]: + 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 'complete_query' not in self._stubs: + self._stubs['complete_query'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.Completion/CompleteQuery', + request_serializer=completion_service.CompleteQueryRequest.serialize, + response_deserializer=completion_service.CompleteQueryResponse.deserialize, + ) + return self._stubs['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" + + +__all__ = ( + 'CompletionGrpcTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py new file mode 100644 index 00000000..635ed224 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py @@ -0,0 +1,284 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4beta1.types import completion_service +from google.longrunning import operations_pb2 +from .base import CompletionTransport, DEFAULT_CLIENT_INFO +from .grpc import CompletionGrpcTransport + + +class CompletionGrpcAsyncIOTransport(CompletionTransport): + """gRPC AsyncIO backend transport for Completion. + + A service handles auto completion. + + 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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 complete_query(self) -> Callable[ + [completion_service.CompleteQueryRequest], + Awaitable[completion_service.CompleteQueryResponse]]: + r"""Return a callable for the complete query method over gRPC. + + Completes the specified prefix with keyword + suggestions. Intended for use by a job search + auto-complete search box. + + Returns: + Callable[[~.CompleteQueryRequest], + Awaitable[~.CompleteQueryResponse]]: + 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 'complete_query' not in self._stubs: + self._stubs['complete_query'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.Completion/CompleteQuery', + request_serializer=completion_service.CompleteQueryRequest.serialize, + response_deserializer=completion_service.CompleteQueryResponse.deserialize, + ) + return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/__init__.py new file mode 100644 index 00000000..194a67c4 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import EventServiceClient +from .async_client import EventServiceAsyncClient + +__all__ = ( + 'EventServiceClient', + 'EventServiceAsyncClient', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/async_client.py new file mode 100644 index 00000000..f3d7c3a3 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/async_client.py @@ -0,0 +1,394 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4beta1.types import event +from google.cloud.talent_v4beta1.types import event_service +from google.longrunning import operations_pb2 +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import EventServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport +from .client import EventServiceClient + + +class EventServiceAsyncClient: + """A service handles client event report.""" + + _client: EventServiceClient + + DEFAULT_ENDPOINT = EventServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = EventServiceClient.DEFAULT_MTLS_ENDPOINT + + company_path = staticmethod(EventServiceClient.company_path) + parse_company_path = staticmethod(EventServiceClient.parse_company_path) + common_billing_account_path = staticmethod(EventServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(EventServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(EventServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(EventServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(EventServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(EventServiceClient.parse_common_organization_path) + common_project_path = staticmethod(EventServiceClient.common_project_path) + parse_common_project_path = staticmethod(EventServiceClient.parse_common_project_path) + common_location_path = staticmethod(EventServiceClient.common_location_path) + parse_common_location_path = staticmethod(EventServiceClient.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: + EventServiceAsyncClient: The constructed client. + """ + return EventServiceClient.from_service_account_info.__func__(EventServiceAsyncClient, 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: + EventServiceAsyncClient: The constructed client. + """ + return EventServiceClient.from_service_account_file.__func__(EventServiceAsyncClient, 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 EventServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> EventServiceTransport: + """Returns the transport used by the client instance. + + Returns: + EventServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(EventServiceClient).get_transport_class, type(EventServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, EventServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the event 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, ~.EventServiceTransport]): 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 = EventServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_client_event(self, + request: Union[event_service.CreateClientEventRequest, dict] = None, + *, + parent: str = None, + client_event: event.ClientEvent = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> event.ClientEvent: + r"""Report events issued when end user interacts with customer's + application that uses Cloud Talent Solution. You may inspect the + created events in `self service + tools `__. + `Learn + more `__ + about self service tools. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_create_client_event(): + # Create a client + client = talent_v4beta1.EventServiceAsyncClient() + + # Initialize request argument(s) + client_event = talent_v4beta1.ClientEvent() + client_event.job_event.type_ = "INTERVIEW_GRANTED" + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] + client_event.event_id = "event_id_value" + + request = talent_v4beta1.CreateClientEventRequest( + parent="parent_value", + client_event=client_event, + ) + + # Make the request + response = await client.create_client_event(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CreateClientEventRequest, dict]): + The request object. The report event request. + parent (:class:`str`): + Required. Resource name of the tenant under which the + event is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created, for example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + client_event (:class:`google.cloud.talent_v4beta1.types.ClientEvent`): + Required. Events issued when end user + interacts with customer's application + that uses Cloud Talent Solution. + + This corresponds to the ``client_event`` 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.ClientEvent: + An event issued when an end user + interacts with the application that + implements Cloud Talent Solution. + Providing this information improves the + quality of results for the API clients, + enabling the service to perform + optimally. The number of events sent + must be consistent with other calls, + such as job searches, issued to the + service by the client. + + """ + # 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, client_event]) + 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 = event_service.CreateClientEventRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if client_event is not None: + request.client_event = client_event + + # 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_client_event, + 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_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 + + 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__ = ( + "EventServiceAsyncClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/client.py new file mode 100644 index 00000000..f2be937f --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/client.py @@ -0,0 +1,596 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.talent_v4beta1.types import event +from google.cloud.talent_v4beta1.types import event_service +from google.longrunning import operations_pb2 +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import EventServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import EventServiceGrpcTransport +from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport + + +class EventServiceClientMeta(type): + """Metaclass for the EventService 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[EventServiceTransport]] + _transport_registry["grpc"] = EventServiceGrpcTransport + _transport_registry["grpc_asyncio"] = EventServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[EventServiceTransport]: + """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 EventServiceClient(metaclass=EventServiceClientMeta): + """A service handles client event report.""" + + @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: + EventServiceClient: 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: + EventServiceClient: 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) -> EventServiceTransport: + """Returns the transport used by the client instance. + + Returns: + EventServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @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 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, EventServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the event 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, EventServiceTransport]): 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, EventServiceTransport): + # transport is a EventServiceTransport 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, + api_audience=client_options.api_audience, + ) + + def create_client_event(self, + request: Union[event_service.CreateClientEventRequest, dict] = None, + *, + parent: str = None, + client_event: event.ClientEvent = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> event.ClientEvent: + r"""Report events issued when end user interacts with customer's + application that uses Cloud Talent Solution. You may inspect the + created events in `self service + tools `__. + `Learn + more `__ + about self service tools. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_create_client_event(): + # Create a client + client = talent_v4beta1.EventServiceClient() + + # Initialize request argument(s) + client_event = talent_v4beta1.ClientEvent() + client_event.job_event.type_ = "INTERVIEW_GRANTED" + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] + client_event.event_id = "event_id_value" + + request = talent_v4beta1.CreateClientEventRequest( + parent="parent_value", + client_event=client_event, + ) + + # Make the request + response = client.create_client_event(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CreateClientEventRequest, dict]): + The request object. The report event request. + parent (str): + Required. Resource name of the tenant under which the + event is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created, for example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + client_event (google.cloud.talent_v4beta1.types.ClientEvent): + Required. Events issued when end user + interacts with customer's application + that uses Cloud Talent Solution. + + This corresponds to the ``client_event`` 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.ClientEvent: + An event issued when an end user + interacts with the application that + implements Cloud Talent Solution. + Providing this information improves the + quality of results for the API clients, + enabling the service to perform + optimally. The number of events sent + must be consistent with other calls, + such as job searches, issued to the + service by the client. + + """ + # 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, client_event]) + 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 event_service.CreateClientEventRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, event_service.CreateClientEventRequest): + request = event_service.CreateClientEventRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if client_event is not None: + request.client_event = client_event + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_client_event] + + # 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 __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() + + 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( + gapic_version=pkg_resources.get_distribution( + "google-cloud-talent", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "EventServiceClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py new file mode 100644 index 00000000..4647d6a8 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 EventServiceTransport +from .grpc import EventServiceGrpcTransport +from .grpc_asyncio import EventServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[EventServiceTransport]] +_transport_registry['grpc'] = EventServiceGrpcTransport +_transport_registry['grpc_asyncio'] = EventServiceGrpcAsyncIOTransport + +__all__ = ( + 'EventServiceTransport', + 'EventServiceGrpcTransport', + 'EventServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/base.py new file mode 100644 index 00000000..a73f141c --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/base.py @@ -0,0 +1,166 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4beta1.types import event +from google.cloud.talent_v4beta1.types import event_service +from google.longrunning import operations_pb2 + +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 EventServiceTransport(abc.ABC): + """Abstract transport class for EventService.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.create_client_event: gapic_v1.method.wrap_method( + self.create_client_event, + 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_client_event(self) -> Callable[ + [event_service.CreateClientEventRequest], + Union[ + event.ClientEvent, + Awaitable[event.ClientEvent] + ]]: + 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() + + +__all__ = ( + 'EventServiceTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py new file mode 100644 index 00000000..5c17699c --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py @@ -0,0 +1,290 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4beta1.types import event +from google.cloud.talent_v4beta1.types import event_service +from google.longrunning import operations_pb2 +from .base import EventServiceTransport, DEFAULT_CLIENT_INFO + + +class EventServiceGrpcTransport(EventServiceTransport): + """gRPC backend transport for EventService. + + A service handles client event report. + + 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_client_event(self) -> Callable[ + [event_service.CreateClientEventRequest], + event.ClientEvent]: + r"""Return a callable for the create client event method over gRPC. + + Report events issued when end user interacts with customer's + application that uses Cloud Talent Solution. You may inspect the + created events in `self service + tools `__. + `Learn + more `__ + about self service tools. + + Returns: + Callable[[~.CreateClientEventRequest], + ~.ClientEvent]: + 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_client_event' not in self._stubs: + self._stubs['create_client_event'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.EventService/CreateClientEvent', + request_serializer=event_service.CreateClientEventRequest.serialize, + response_deserializer=event.ClientEvent.deserialize, + ) + return self._stubs['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" + + +__all__ = ( + 'EventServiceGrpcTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py new file mode 100644 index 00000000..8cc3a7ba --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py @@ -0,0 +1,289 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4beta1.types import event +from google.cloud.talent_v4beta1.types import event_service +from google.longrunning import operations_pb2 +from .base import EventServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import EventServiceGrpcTransport + + +class EventServiceGrpcAsyncIOTransport(EventServiceTransport): + """gRPC AsyncIO backend transport for EventService. + + A service handles client event report. + + 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_client_event(self) -> Callable[ + [event_service.CreateClientEventRequest], + Awaitable[event.ClientEvent]]: + r"""Return a callable for the create client event method over gRPC. + + Report events issued when end user interacts with customer's + application that uses Cloud Talent Solution. You may inspect the + created events in `self service + tools `__. + `Learn + more `__ + about self service tools. + + Returns: + Callable[[~.CreateClientEventRequest], + Awaitable[~.ClientEvent]]: + 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_client_event' not in self._stubs: + self._stubs['create_client_event'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.EventService/CreateClientEvent', + request_serializer=event_service.CreateClientEventRequest.serialize, + response_deserializer=event.ClientEvent.deserialize, + ) + return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/__init__.py new file mode 100644 index 00000000..3a5ccd23 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import JobServiceClient +from .async_client import JobServiceAsyncClient + +__all__ = ( + 'JobServiceClient', + 'JobServiceAsyncClient', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/async_client.py new file mode 100644 index 00000000..574fa878 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/async_client.py @@ -0,0 +1,1476 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.talent_v4beta1.services.job_service import pagers +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import job +from google.cloud.talent_v4beta1.types import job as gct_job +from google.cloud.talent_v4beta1.types import job_service +from google.longrunning import operations_pb2 +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport +from .client import JobServiceClient + + +class JobServiceAsyncClient: + """A service handles job management, including job CRUD, + enumeration and search. + """ + + _client: JobServiceClient + + DEFAULT_ENDPOINT = JobServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = JobServiceClient.DEFAULT_MTLS_ENDPOINT + + company_path = staticmethod(JobServiceClient.company_path) + parse_company_path = staticmethod(JobServiceClient.parse_company_path) + job_path = staticmethod(JobServiceClient.job_path) + parse_job_path = staticmethod(JobServiceClient.parse_job_path) + common_billing_account_path = staticmethod(JobServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(JobServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(JobServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(JobServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(JobServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(JobServiceClient.parse_common_organization_path) + common_project_path = staticmethod(JobServiceClient.common_project_path) + parse_common_project_path = staticmethod(JobServiceClient.parse_common_project_path) + common_location_path = staticmethod(JobServiceClient.common_location_path) + parse_common_location_path = staticmethod(JobServiceClient.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: + JobServiceAsyncClient: The constructed client. + """ + return JobServiceClient.from_service_account_info.__func__(JobServiceAsyncClient, 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: + JobServiceAsyncClient: The constructed client. + """ + return JobServiceClient.from_service_account_file.__func__(JobServiceAsyncClient, 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 JobServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> JobServiceTransport: + """Returns the transport used by the client instance. + + Returns: + JobServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(JobServiceClient).get_transport_class, type(JobServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, JobServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the job 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, ~.JobServiceTransport]): 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 = JobServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_job(self, + request: Union[job_service.CreateJobRequest, dict] = None, + *, + parent: str = None, + job: gct_job.Job = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_job.Job: + r"""Creates a new job. + Typically, the job becomes searchable within 10 seconds, + but it may take up to 5 minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_create_job(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + job = talent_v4beta1.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4beta1.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = await client.create_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CreateJobRequest, dict]): + The request object. Create job request. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + job (:class:`google.cloud.talent_v4beta1.types.Job`): + Required. The Job to be created. + This corresponds to the ``job`` 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.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4beta1.Company], which + is the hiring entity responsible for the job. + + """ + # 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, job]) + 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 = job_service.CreateJobRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if job is not None: + request.job = job + + # 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_job, + 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 batch_create_jobs(self, + request: Union[job_service.BatchCreateJobsRequest, dict] = None, + *, + parent: str = None, + jobs: Sequence[job.Job] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Begins executing a batch create jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_batch_create_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + jobs = talent_v4beta1.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4beta1.BatchCreateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_create_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.BatchCreateJobsRequest, dict]): + The request object. Request to create a batch of jobs. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + jobs (:class:`Sequence[google.cloud.talent_v4beta1.types.Job]`): + Required. The jobs to be created. + This corresponds to the ``jobs`` 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4beta1.types.JobOperationResult` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] or + [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] + APIs. It's used to replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, jobs]) + 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 = job_service.BatchCreateJobsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if jobs: + request.jobs.extend(jobs) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_create_jobs, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + job_service.JobOperationResult, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + async def get_job(self, + request: Union[job_service.GetJobRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> job.Job: + r"""Retrieves the specified job, whose status is OPEN or + recently EXPIRED within the last 90 days. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_get_job(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetJobRequest( + name="name_value", + ) + + # Make the request + response = await client.get_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.GetJobRequest, dict]): + The request object. Get job request. + name (:class:`str`): + Required. The resource name of the job to retrieve. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + If tenant id is unspecified, the default tenant is used. + For example, "projects/foo/jobs/bar". + + 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.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4beta1.Company], which + is the hiring entity responsible for the job. + + """ + # 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 = job_service.GetJobRequest(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_job, + 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_job(self, + request: Union[job_service.UpdateJobRequest, dict] = None, + *, + job: gct_job.Job = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_job.Job: + r"""Updates specified job. + Typically, updated contents become visible in search + results within 10 seconds, but it may take up to 5 + minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_update_job(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + job = talent_v4beta1.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4beta1.UpdateJobRequest( + job=job, + ) + + # Make the request + response = await client.update_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.UpdateJobRequest, dict]): + The request object. Update job request. + job (:class:`google.cloud.talent_v4beta1.types.Job`): + Required. The Job to be updated. + This corresponds to the ``job`` 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.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4beta1.Company], which + is the hiring entity responsible for the job. + + """ + # 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([job]) + 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 = job_service.UpdateJobRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if job is not None: + request.job = job + + # 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_job, + 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(( + ("job.name", request.job.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def batch_update_jobs(self, + request: Union[job_service.BatchUpdateJobsRequest, dict] = None, + *, + parent: str = None, + jobs: Sequence[job.Job] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Begins executing a batch update jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_batch_update_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + jobs = talent_v4beta1.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4beta1.BatchUpdateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_update_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.BatchUpdateJobsRequest, dict]): + The request object. Request to update a batch of jobs. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + jobs (:class:`Sequence[google.cloud.talent_v4beta1.types.Job]`): + Required. The jobs to be updated. + This corresponds to the ``jobs`` 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4beta1.types.JobOperationResult` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] or + [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] + APIs. It's used to replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, jobs]) + 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 = job_service.BatchUpdateJobsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if jobs: + request.jobs.extend(jobs) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_update_jobs, + 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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + job_service.JobOperationResult, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_job(self, + request: Union[job_service.DeleteJobRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes the specified job. + Typically, the job becomes unsearchable within 10 + seconds, but it may take up to 5 minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_delete_job(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteJobRequest( + name="name_value", + ) + + # Make the request + await client.delete_job(request=request) + + Args: + request (Union[google.cloud.talent_v4beta1.types.DeleteJobRequest, dict]): + The request object. Delete job request. + name (:class:`str`): + Required. The resource name of the job to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + If tenant id is unspecified, the default tenant is used. + For example, "projects/foo/jobs/bar". + + 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 = job_service.DeleteJobRequest(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_job, + 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 batch_delete_jobs(self, + request: Union[job_service.BatchDeleteJobsRequest, dict] = None, + *, + parent: str = None, + filter: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by + filter. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_batch_delete_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.BatchDeleteJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + await client.batch_delete_jobs(request=request) + + Args: + request (Union[google.cloud.talent_v4beta1.types.BatchDeleteJobsRequest, dict]): + The request object. Batch delete jobs request. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (:class:`str`): + Required. The filter string specifies the jobs to be + deleted. + + Supported operator: =, AND + + The fields eligible for filtering are: + + - ``companyName`` (Required) + - ``requisitionId`` (Required) + + Sample Query: companyName = "projects/foo/companies/bar" + AND requisitionId = "req-1" + + This corresponds to the ``filter`` 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([parent, filter]) + 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 = job_service.BatchDeleteJobsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_delete_jobs, + 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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def list_jobs(self, + request: Union[job_service.ListJobsRequest, dict] = None, + *, + parent: str = None, + filter: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListJobsAsyncPager: + r"""Lists jobs by filter. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_list_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.ListJobsRequest, dict]): + The request object. List jobs request. + parent (:class:`str`): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (:class:`str`): + Required. The filter string specifies the jobs to be + enumerated. + + Supported operator: =, AND + + The fields eligible for filtering are: + + - ``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" + - requisitionId = "req-1" + - requisitionId = "req-1" AND status = "EXPIRED" + + This corresponds to the ``filter`` 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.job_service.pagers.ListJobsAsyncPager: + List jobs response. + 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, filter]) + 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 = job_service.ListJobsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # 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_jobs, + 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.ListJobsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def search_jobs(self, + request: Union[job_service.SearchJobsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.SearchJobsAsyncPager: + r"""Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + + This call constrains the + [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + present in the database, and only returns jobs that the caller + has permission to search against. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_search_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.search_jobs(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.SearchJobsRequest, dict]): + The request object. The Request body of the `SearchJobs` + 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.job_service.pagers.SearchJobsAsyncPager: + Response for SearchJob method. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = job_service.SearchJobsRequest(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_jobs, + 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.SearchJobsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def search_jobs_for_alert(self, + request: Union[job_service.SearchJobsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.SearchJobsForAlertAsyncPager: + r"""Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + + This API call is intended for the use case of targeting passive + job seekers (for example, job seekers who have signed up to + receive email alerts about potential job opportunities), and has + different algorithmic adjustments that are targeted to passive + job seekers. + + This call constrains the + [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + present in the database, and only returns jobs the caller has + permission to search against. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_search_jobs_for_alert(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.search_jobs_for_alert(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.SearchJobsRequest, dict]): + The request object. The Request body of the `SearchJobs` + 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.job_service.pagers.SearchJobsForAlertAsyncPager: + Response for SearchJob method. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = job_service.SearchJobsRequest(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_jobs_for_alert, + 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.SearchJobsForAlertAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # 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 + + 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__ = ( + "JobServiceAsyncClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/client.py new file mode 100644 index 00000000..c4105c09 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/client.py @@ -0,0 +1,1668 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.talent_v4beta1.services.job_service import pagers +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import job +from google.cloud.talent_v4beta1.types import job as gct_job +from google.cloud.talent_v4beta1.types import job_service +from google.longrunning import operations_pb2 +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import JobServiceGrpcTransport +from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport + + +class JobServiceClientMeta(type): + """Metaclass for the JobService 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[JobServiceTransport]] + _transport_registry["grpc"] = JobServiceGrpcTransport + _transport_registry["grpc_asyncio"] = JobServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[JobServiceTransport]: + """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 JobServiceClient(metaclass=JobServiceClientMeta): + """A service handles job management, including job 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: + JobServiceClient: 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: + JobServiceClient: 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) -> JobServiceTransport: + """Returns the transport used by the client instance. + + Returns: + JobServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @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 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, JobServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the job 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, JobServiceTransport]): 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, JobServiceTransport): + # transport is a JobServiceTransport 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, + api_audience=client_options.api_audience, + ) + + def create_job(self, + request: Union[job_service.CreateJobRequest, dict] = None, + *, + parent: str = None, + job: gct_job.Job = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_job.Job: + r"""Creates a new job. + Typically, the job becomes searchable within 10 seconds, + but it may take up to 5 minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_create_job(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + job = talent_v4beta1.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4beta1.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = client.create_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CreateJobRequest, dict]): + The request object. Create job request. + parent (str): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + job (google.cloud.talent_v4beta1.types.Job): + Required. The Job to be created. + This corresponds to the ``job`` 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.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4beta1.Company], which + is the hiring entity responsible for the job. + + """ + # 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, job]) + 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 job_service.CreateJobRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.CreateJobRequest): + request = job_service.CreateJobRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if job is not None: + request.job = job + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_job] + + # 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 batch_create_jobs(self, + request: Union[job_service.BatchCreateJobsRequest, dict] = None, + *, + parent: str = None, + jobs: Sequence[job.Job] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Begins executing a batch create jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_batch_create_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + jobs = talent_v4beta1.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4beta1.BatchCreateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_create_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.BatchCreateJobsRequest, dict]): + The request object. Request to create a batch of jobs. + parent (str): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): + Required. The jobs to be created. + This corresponds to the ``jobs`` 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4beta1.types.JobOperationResult` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] or + [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] + APIs. It's used to replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, jobs]) + 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 job_service.BatchCreateJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.BatchCreateJobsRequest): + request = job_service.BatchCreateJobsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if jobs is not None: + request.jobs = jobs + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_create_jobs] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + job_service.JobOperationResult, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + def get_job(self, + request: Union[job_service.GetJobRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> job.Job: + r"""Retrieves the specified job, whose status is OPEN or + recently EXPIRED within the last 90 days. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_get_job(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetJobRequest( + name="name_value", + ) + + # Make the request + response = client.get_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.GetJobRequest, dict]): + The request object. Get job request. + name (str): + Required. The resource name of the job to retrieve. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + If tenant id is unspecified, the default tenant is used. + For example, "projects/foo/jobs/bar". + + 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.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4beta1.Company], which + is the hiring entity responsible for the job. + + """ + # 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 job_service.GetJobRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.GetJobRequest): + request = job_service.GetJobRequest(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_job] + + # 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_job(self, + request: Union[job_service.UpdateJobRequest, dict] = None, + *, + job: gct_job.Job = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_job.Job: + r"""Updates specified job. + Typically, updated contents become visible in search + results within 10 seconds, but it may take up to 5 + minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_update_job(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + job = talent_v4beta1.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4beta1.UpdateJobRequest( + job=job, + ) + + # Make the request + response = client.update_job(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.UpdateJobRequest, dict]): + The request object. Update job request. + job (google.cloud.talent_v4beta1.types.Job): + Required. The Job to be updated. + This corresponds to the ``job`` 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.Job: + A Job resource represents a job posting (also referred to as a "job listing" + or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4beta1.Company], which + is the hiring entity responsible for the job. + + """ + # 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([job]) + 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 job_service.UpdateJobRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.UpdateJobRequest): + request = job_service.UpdateJobRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if job is not None: + request.job = job + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_job] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("job.name", request.job.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def batch_update_jobs(self, + request: Union[job_service.BatchUpdateJobsRequest, dict] = None, + *, + parent: str = None, + jobs: Sequence[job.Job] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Begins executing a batch update jobs operation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_batch_update_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + jobs = talent_v4beta1.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4beta1.BatchUpdateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_update_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.BatchUpdateJobsRequest, dict]): + The request object. Request to update a batch of jobs. + parent (str): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): + Required. The jobs to be updated. + This corresponds to the ``jobs`` 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.talent_v4beta1.types.JobOperationResult` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] or + [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] + APIs. It's used to replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + """ + # 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, jobs]) + 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 job_service.BatchUpdateJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.BatchUpdateJobsRequest): + request = job_service.BatchUpdateJobsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if jobs is not None: + request.jobs = jobs + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_update_jobs] + + # 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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + job_service.JobOperationResult, + metadata_type=common.BatchOperationMetadata, + ) + + # Done; return the response. + return response + + def delete_job(self, + request: Union[job_service.DeleteJobRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes the specified job. + Typically, the job becomes unsearchable within 10 + seconds, but it may take up to 5 minutes. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_delete_job(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteJobRequest( + name="name_value", + ) + + # Make the request + client.delete_job(request=request) + + Args: + request (Union[google.cloud.talent_v4beta1.types.DeleteJobRequest, dict]): + The request object. Delete job request. + name (str): + Required. The resource name of the job to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + If tenant id is unspecified, the default tenant is used. + For example, "projects/foo/jobs/bar". + + 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 job_service.DeleteJobRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.DeleteJobRequest): + request = job_service.DeleteJobRequest(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_job] + + # 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 batch_delete_jobs(self, + request: Union[job_service.BatchDeleteJobsRequest, dict] = None, + *, + parent: str = None, + filter: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by + filter. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_batch_delete_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.BatchDeleteJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + client.batch_delete_jobs(request=request) + + Args: + request (Union[google.cloud.talent_v4beta1.types.BatchDeleteJobsRequest, dict]): + The request object. Batch delete jobs request. + parent (str): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (str): + Required. The filter string specifies the jobs to be + deleted. + + Supported operator: =, AND + + The fields eligible for filtering are: + + - ``companyName`` (Required) + - ``requisitionId`` (Required) + + Sample Query: companyName = "projects/foo/companies/bar" + AND requisitionId = "req-1" + + This corresponds to the ``filter`` 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([parent, filter]) + 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 job_service.BatchDeleteJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.BatchDeleteJobsRequest): + request = job_service.BatchDeleteJobsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_delete_jobs] + + # 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. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def list_jobs(self, + request: Union[job_service.ListJobsRequest, dict] = None, + *, + parent: str = None, + filter: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListJobsPager: + r"""Lists jobs by filter. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_list_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.ListJobsRequest, dict]): + The request object. List jobs request. + parent (str): + Required. The resource name of the tenant under which + the job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}". For + example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (str): + Required. The filter string specifies the jobs to be + enumerated. + + Supported operator: =, AND + + The fields eligible for filtering are: + + - ``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" + - requisitionId = "req-1" + - requisitionId = "req-1" AND status = "EXPIRED" + + This corresponds to the ``filter`` 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.job_service.pagers.ListJobsPager: + List jobs response. + 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, filter]) + 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 job_service.ListJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.ListJobsRequest): + request = job_service.ListJobsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_jobs] + + # 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.ListJobsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def search_jobs(self, + request: Union[job_service.SearchJobsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.SearchJobsPager: + r"""Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + + This call constrains the + [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + present in the database, and only returns jobs that the caller + has permission to search against. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_search_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.search_jobs(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.SearchJobsRequest, dict]): + The request object. The Request body of the `SearchJobs` + 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.job_service.pagers.SearchJobsPager: + Response for SearchJob 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 job_service.SearchJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.SearchJobsRequest): + request = job_service.SearchJobsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.search_jobs] + + # 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.SearchJobsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def search_jobs_for_alert(self, + request: Union[job_service.SearchJobsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.SearchJobsForAlertPager: + r"""Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + + This API call is intended for the use case of targeting passive + job seekers (for example, job seekers who have signed up to + receive email alerts about potential job opportunities), and has + different algorithmic adjustments that are targeted to passive + job seekers. + + This call constrains the + [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + present in the database, and only returns jobs the caller has + permission to search against. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_search_jobs_for_alert(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.search_jobs_for_alert(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.SearchJobsRequest, dict]): + The request object. The Request body of the `SearchJobs` + 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.job_service.pagers.SearchJobsForAlertPager: + Response for SearchJob 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 job_service.SearchJobsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, job_service.SearchJobsRequest): + request = job_service.SearchJobsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.search_jobs_for_alert] + + # 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.SearchJobsForAlertPager( + 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() + + 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( + gapic_version=pkg_resources.get_distribution( + "google-cloud-talent", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "JobServiceClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/pagers.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/pagers.py new file mode 100644 index 00000000..ae70ac5b --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/pagers.py @@ -0,0 +1,382 @@ +# -*- 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, Sequence, Tuple, Optional, Iterator + +from google.cloud.talent_v4beta1.types import job +from google.cloud.talent_v4beta1.types import job_service + + +class ListJobsPager: + """A pager for iterating through ``list_jobs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.ListJobsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``jobs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListJobs`` requests and continue to iterate + through the ``jobs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.ListJobsResponse` + 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[..., job_service.ListJobsResponse], + request: job_service.ListJobsRequest, + response: job_service.ListJobsResponse, + *, + 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.ListJobsRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.ListJobsResponse): + 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 = job_service.ListJobsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[job_service.ListJobsResponse]: + 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[job.Job]: + for page in self.pages: + yield from page.jobs + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListJobsAsyncPager: + """A pager for iterating through ``list_jobs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.ListJobsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``jobs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListJobs`` requests and continue to iterate + through the ``jobs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.ListJobsResponse` + 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[job_service.ListJobsResponse]], + request: job_service.ListJobsRequest, + response: job_service.ListJobsResponse, + *, + 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.ListJobsRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.ListJobsResponse): + 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 = job_service.ListJobsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[job_service.ListJobsResponse]: + 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[job.Job]: + async def async_generator(): + async for page in self.pages: + for response in page.jobs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class SearchJobsPager: + """A pager for iterating through ``search_jobs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``matching_jobs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``SearchJobs`` requests and continue to iterate + through the ``matching_jobs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` + 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[..., job_service.SearchJobsResponse], + request: job_service.SearchJobsRequest, + response: job_service.SearchJobsResponse, + *, + 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.SearchJobsRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.SearchJobsResponse): + 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 = job_service.SearchJobsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[job_service.SearchJobsResponse]: + 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[job_service.SearchJobsResponse.MatchingJob]: + for page in self.pages: + yield from page.matching_jobs + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class SearchJobsAsyncPager: + """A pager for iterating through ``search_jobs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``matching_jobs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``SearchJobs`` requests and continue to iterate + through the ``matching_jobs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` + 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[job_service.SearchJobsResponse]], + request: job_service.SearchJobsRequest, + response: job_service.SearchJobsResponse, + *, + 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.SearchJobsRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.SearchJobsResponse): + 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 = job_service.SearchJobsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[job_service.SearchJobsResponse]: + 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[job_service.SearchJobsResponse.MatchingJob]: + async def async_generator(): + async for page in self.pages: + for response in page.matching_jobs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class SearchJobsForAlertPager: + """A pager for iterating through ``search_jobs_for_alert`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``matching_jobs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``SearchJobsForAlert`` requests and continue to iterate + through the ``matching_jobs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` + 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[..., job_service.SearchJobsResponse], + request: job_service.SearchJobsRequest, + response: job_service.SearchJobsResponse, + *, + 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.SearchJobsRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.SearchJobsResponse): + 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 = job_service.SearchJobsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[job_service.SearchJobsResponse]: + 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[job_service.SearchJobsResponse.MatchingJob]: + for page in self.pages: + yield from page.matching_jobs + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class SearchJobsForAlertAsyncPager: + """A pager for iterating through ``search_jobs_for_alert`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``matching_jobs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``SearchJobsForAlert`` requests and continue to iterate + through the ``matching_jobs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` + 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[job_service.SearchJobsResponse]], + request: job_service.SearchJobsRequest, + response: job_service.SearchJobsResponse, + *, + 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.SearchJobsRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.SearchJobsResponse): + 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 = job_service.SearchJobsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[job_service.SearchJobsResponse]: + 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[job_service.SearchJobsResponse.MatchingJob]: + async def async_generator(): + async for page in self.pages: + for response in page.matching_jobs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py new file mode 100644 index 00000000..05345304 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 JobServiceTransport +from .grpc import JobServiceGrpcTransport +from .grpc_asyncio import JobServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[JobServiceTransport]] +_transport_registry['grpc'] = JobServiceGrpcTransport +_transport_registry['grpc_asyncio'] = JobServiceGrpcAsyncIOTransport + +__all__ = ( + 'JobServiceTransport', + 'JobServiceGrpcTransport', + 'JobServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/base.py new file mode 100644 index 00000000..383fda71 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/base.py @@ -0,0 +1,322 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4beta1.types import job +from google.cloud.talent_v4beta1.types import job as gct_job +from google.cloud.talent_v4beta1.types import job_service +from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore + +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 JobServiceTransport(abc.ABC): + """Abstract transport class for JobService.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.create_job: gapic_v1.method.wrap_method( + self.create_job, + default_timeout=30.0, + client_info=client_info, + ), + self.batch_create_jobs: gapic_v1.method.wrap_method( + self.batch_create_jobs, + default_timeout=30.0, + client_info=client_info, + ), + self.get_job: gapic_v1.method.wrap_method( + self.get_job, + 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_job: gapic_v1.method.wrap_method( + self.update_job, + default_timeout=30.0, + client_info=client_info, + ), + self.batch_update_jobs: gapic_v1.method.wrap_method( + self.batch_update_jobs, + default_timeout=30.0, + client_info=client_info, + ), + self.delete_job: gapic_v1.method.wrap_method( + self.delete_job, + 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.batch_delete_jobs: gapic_v1.method.wrap_method( + self.batch_delete_jobs, + default_timeout=30.0, + client_info=client_info, + ), + self.list_jobs: gapic_v1.method.wrap_method( + self.list_jobs, + 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_jobs: gapic_v1.method.wrap_method( + self.search_jobs, + default_timeout=30.0, + client_info=client_info, + ), + self.search_jobs_for_alert: gapic_v1.method.wrap_method( + self.search_jobs_for_alert, + 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 operations_client(self): + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def create_job(self) -> Callable[ + [job_service.CreateJobRequest], + Union[ + gct_job.Job, + Awaitable[gct_job.Job] + ]]: + raise NotImplementedError() + + @property + def batch_create_jobs(self) -> Callable[ + [job_service.BatchCreateJobsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_job(self) -> Callable[ + [job_service.GetJobRequest], + Union[ + job.Job, + Awaitable[job.Job] + ]]: + raise NotImplementedError() + + @property + def update_job(self) -> Callable[ + [job_service.UpdateJobRequest], + Union[ + gct_job.Job, + Awaitable[gct_job.Job] + ]]: + raise NotImplementedError() + + @property + def batch_update_jobs(self) -> Callable[ + [job_service.BatchUpdateJobsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_job(self) -> Callable[ + [job_service.DeleteJobRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def batch_delete_jobs(self) -> Callable[ + [job_service.BatchDeleteJobsRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def list_jobs(self) -> Callable[ + [job_service.ListJobsRequest], + Union[ + job_service.ListJobsResponse, + Awaitable[job_service.ListJobsResponse] + ]]: + raise NotImplementedError() + + @property + def search_jobs(self) -> Callable[ + [job_service.SearchJobsRequest], + Union[ + job_service.SearchJobsResponse, + Awaitable[job_service.SearchJobsResponse] + ]]: + raise NotImplementedError() + + @property + def search_jobs_for_alert(self) -> Callable[ + [job_service.SearchJobsRequest], + Union[ + job_service.SearchJobsResponse, + Awaitable[job_service.SearchJobsResponse] + ]]: + 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() + + +__all__ = ( + 'JobServiceTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py new file mode 100644 index 00000000..e377d5ff --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py @@ -0,0 +1,567 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4beta1.types import job +from google.cloud.talent_v4beta1.types import job as gct_job +from google.cloud.talent_v4beta1.types import job_service +from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import JobServiceTransport, DEFAULT_CLIENT_INFO + + +class JobServiceGrpcTransport(JobServiceTransport): + """gRPC backend transport for JobService. + + A service handles job management, including job 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, + api_audience: Optional[str] = None, + ) -> 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] = {} + self._operations_client: Optional[operations_v1.OperationsClient] = None + + 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, + api_audience=api_audience, + ) + + 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 operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Quick check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_job(self) -> Callable[ + [job_service.CreateJobRequest], + gct_job.Job]: + r"""Return a callable for the create job method over gRPC. + + Creates a new job. + Typically, the job becomes searchable within 10 seconds, + but it may take up to 5 minutes. + + Returns: + Callable[[~.CreateJobRequest], + ~.Job]: + 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_job' not in self._stubs: + self._stubs['create_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/CreateJob', + request_serializer=job_service.CreateJobRequest.serialize, + response_deserializer=gct_job.Job.deserialize, + ) + return self._stubs['create_job'] + + @property + def batch_create_jobs(self) -> Callable[ + [job_service.BatchCreateJobsRequest], + operations_pb2.Operation]: + r"""Return a callable for the batch create jobs method over gRPC. + + Begins executing a batch create jobs operation. + + Returns: + Callable[[~.BatchCreateJobsRequest], + ~.Operation]: + 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 'batch_create_jobs' not in self._stubs: + self._stubs['batch_create_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/BatchCreateJobs', + request_serializer=job_service.BatchCreateJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_create_jobs'] + + @property + def get_job(self) -> Callable[ + [job_service.GetJobRequest], + job.Job]: + r"""Return a callable for the get job method over gRPC. + + Retrieves the specified job, whose status is OPEN or + recently EXPIRED within the last 90 days. + + Returns: + Callable[[~.GetJobRequest], + ~.Job]: + 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_job' not in self._stubs: + self._stubs['get_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/GetJob', + request_serializer=job_service.GetJobRequest.serialize, + response_deserializer=job.Job.deserialize, + ) + return self._stubs['get_job'] + + @property + def update_job(self) -> Callable[ + [job_service.UpdateJobRequest], + gct_job.Job]: + r"""Return a callable for the update job method over gRPC. + + Updates specified job. + Typically, updated contents become visible in search + results within 10 seconds, but it may take up to 5 + minutes. + + Returns: + Callable[[~.UpdateJobRequest], + ~.Job]: + 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_job' not in self._stubs: + self._stubs['update_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/UpdateJob', + request_serializer=job_service.UpdateJobRequest.serialize, + response_deserializer=gct_job.Job.deserialize, + ) + return self._stubs['update_job'] + + @property + def batch_update_jobs(self) -> Callable[ + [job_service.BatchUpdateJobsRequest], + operations_pb2.Operation]: + r"""Return a callable for the batch update jobs method over gRPC. + + Begins executing a batch update jobs operation. + + Returns: + Callable[[~.BatchUpdateJobsRequest], + ~.Operation]: + 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 'batch_update_jobs' not in self._stubs: + self._stubs['batch_update_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/BatchUpdateJobs', + request_serializer=job_service.BatchUpdateJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_update_jobs'] + + @property + def delete_job(self) -> Callable[ + [job_service.DeleteJobRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete job method over gRPC. + + Deletes the specified job. + Typically, the job becomes unsearchable within 10 + seconds, but it may take up to 5 minutes. + + Returns: + Callable[[~.DeleteJobRequest], + ~.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_job' not in self._stubs: + self._stubs['delete_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/DeleteJob', + request_serializer=job_service.DeleteJobRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_job'] + + @property + def batch_delete_jobs(self) -> Callable[ + [job_service.BatchDeleteJobsRequest], + empty_pb2.Empty]: + r"""Return a callable for the batch delete jobs method over gRPC. + + Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by + filter. + + Returns: + Callable[[~.BatchDeleteJobsRequest], + ~.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 'batch_delete_jobs' not in self._stubs: + self._stubs['batch_delete_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/BatchDeleteJobs', + request_serializer=job_service.BatchDeleteJobsRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['batch_delete_jobs'] + + @property + def list_jobs(self) -> Callable[ + [job_service.ListJobsRequest], + job_service.ListJobsResponse]: + r"""Return a callable for the list jobs method over gRPC. + + Lists jobs by filter. + + Returns: + Callable[[~.ListJobsRequest], + ~.ListJobsResponse]: + 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_jobs' not in self._stubs: + self._stubs['list_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/ListJobs', + request_serializer=job_service.ListJobsRequest.serialize, + response_deserializer=job_service.ListJobsResponse.deserialize, + ) + return self._stubs['list_jobs'] + + @property + def search_jobs(self) -> Callable[ + [job_service.SearchJobsRequest], + job_service.SearchJobsResponse]: + r"""Return a callable for the search jobs method over gRPC. + + Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + + This call constrains the + [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + present in the database, and only returns jobs that the caller + has permission to search against. + + Returns: + Callable[[~.SearchJobsRequest], + ~.SearchJobsResponse]: + 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_jobs' not in self._stubs: + self._stubs['search_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/SearchJobs', + request_serializer=job_service.SearchJobsRequest.serialize, + response_deserializer=job_service.SearchJobsResponse.deserialize, + ) + return self._stubs['search_jobs'] + + @property + def search_jobs_for_alert(self) -> Callable[ + [job_service.SearchJobsRequest], + job_service.SearchJobsResponse]: + r"""Return a callable for the search jobs for alert method over gRPC. + + Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + + This API call is intended for the use case of targeting passive + job seekers (for example, job seekers who have signed up to + receive email alerts about potential job opportunities), and has + different algorithmic adjustments that are targeted to passive + job seekers. + + This call constrains the + [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + present in the database, and only returns jobs the caller has + permission to search against. + + Returns: + Callable[[~.SearchJobsRequest], + ~.SearchJobsResponse]: + 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_jobs_for_alert' not in self._stubs: + self._stubs['search_jobs_for_alert'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/SearchJobsForAlert', + request_serializer=job_service.SearchJobsRequest.serialize, + response_deserializer=job_service.SearchJobsResponse.deserialize, + ) + return self._stubs['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" + + +__all__ = ( + 'JobServiceGrpcTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py new file mode 100644 index 00000000..fd10406e --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py @@ -0,0 +1,566 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4beta1.types import job +from google.cloud.talent_v4beta1.types import job as gct_job +from google.cloud.talent_v4beta1.types import job_service +from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import JobServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import JobServiceGrpcTransport + + +class JobServiceGrpcAsyncIOTransport(JobServiceTransport): + """gRPC AsyncIO backend transport for JobService. + + A service handles job management, including job 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, + api_audience: Optional[str] = None, + ) -> 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] = {} + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None + + 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, + api_audience=api_audience, + ) + + 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 operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Quick check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_job(self) -> Callable[ + [job_service.CreateJobRequest], + Awaitable[gct_job.Job]]: + r"""Return a callable for the create job method over gRPC. + + Creates a new job. + Typically, the job becomes searchable within 10 seconds, + but it may take up to 5 minutes. + + Returns: + Callable[[~.CreateJobRequest], + Awaitable[~.Job]]: + 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_job' not in self._stubs: + self._stubs['create_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/CreateJob', + request_serializer=job_service.CreateJobRequest.serialize, + response_deserializer=gct_job.Job.deserialize, + ) + return self._stubs['create_job'] + + @property + def batch_create_jobs(self) -> Callable[ + [job_service.BatchCreateJobsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the batch create jobs method over gRPC. + + Begins executing a batch create jobs operation. + + Returns: + Callable[[~.BatchCreateJobsRequest], + Awaitable[~.Operation]]: + 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 'batch_create_jobs' not in self._stubs: + self._stubs['batch_create_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/BatchCreateJobs', + request_serializer=job_service.BatchCreateJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_create_jobs'] + + @property + def get_job(self) -> Callable[ + [job_service.GetJobRequest], + Awaitable[job.Job]]: + r"""Return a callable for the get job method over gRPC. + + Retrieves the specified job, whose status is OPEN or + recently EXPIRED within the last 90 days. + + Returns: + Callable[[~.GetJobRequest], + Awaitable[~.Job]]: + 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_job' not in self._stubs: + self._stubs['get_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/GetJob', + request_serializer=job_service.GetJobRequest.serialize, + response_deserializer=job.Job.deserialize, + ) + return self._stubs['get_job'] + + @property + def update_job(self) -> Callable[ + [job_service.UpdateJobRequest], + Awaitable[gct_job.Job]]: + r"""Return a callable for the update job method over gRPC. + + Updates specified job. + Typically, updated contents become visible in search + results within 10 seconds, but it may take up to 5 + minutes. + + Returns: + Callable[[~.UpdateJobRequest], + Awaitable[~.Job]]: + 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_job' not in self._stubs: + self._stubs['update_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/UpdateJob', + request_serializer=job_service.UpdateJobRequest.serialize, + response_deserializer=gct_job.Job.deserialize, + ) + return self._stubs['update_job'] + + @property + def batch_update_jobs(self) -> Callable[ + [job_service.BatchUpdateJobsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the batch update jobs method over gRPC. + + Begins executing a batch update jobs operation. + + Returns: + Callable[[~.BatchUpdateJobsRequest], + Awaitable[~.Operation]]: + 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 'batch_update_jobs' not in self._stubs: + self._stubs['batch_update_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/BatchUpdateJobs', + request_serializer=job_service.BatchUpdateJobsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['batch_update_jobs'] + + @property + def delete_job(self) -> Callable[ + [job_service.DeleteJobRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete job method over gRPC. + + Deletes the specified job. + Typically, the job becomes unsearchable within 10 + seconds, but it may take up to 5 minutes. + + Returns: + Callable[[~.DeleteJobRequest], + 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_job' not in self._stubs: + self._stubs['delete_job'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/DeleteJob', + request_serializer=job_service.DeleteJobRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_job'] + + @property + def batch_delete_jobs(self) -> Callable[ + [job_service.BatchDeleteJobsRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the batch delete jobs method over gRPC. + + Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by + filter. + + Returns: + Callable[[~.BatchDeleteJobsRequest], + 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 'batch_delete_jobs' not in self._stubs: + self._stubs['batch_delete_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/BatchDeleteJobs', + request_serializer=job_service.BatchDeleteJobsRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['batch_delete_jobs'] + + @property + def list_jobs(self) -> Callable[ + [job_service.ListJobsRequest], + Awaitable[job_service.ListJobsResponse]]: + r"""Return a callable for the list jobs method over gRPC. + + Lists jobs by filter. + + Returns: + Callable[[~.ListJobsRequest], + Awaitable[~.ListJobsResponse]]: + 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_jobs' not in self._stubs: + self._stubs['list_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/ListJobs', + request_serializer=job_service.ListJobsRequest.serialize, + response_deserializer=job_service.ListJobsResponse.deserialize, + ) + return self._stubs['list_jobs'] + + @property + def search_jobs(self) -> Callable[ + [job_service.SearchJobsRequest], + Awaitable[job_service.SearchJobsResponse]]: + r"""Return a callable for the search jobs method over gRPC. + + Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + + This call constrains the + [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + present in the database, and only returns jobs that the caller + has permission to search against. + + Returns: + Callable[[~.SearchJobsRequest], + Awaitable[~.SearchJobsResponse]]: + 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_jobs' not in self._stubs: + self._stubs['search_jobs'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/SearchJobs', + request_serializer=job_service.SearchJobsRequest.serialize, + response_deserializer=job_service.SearchJobsResponse.deserialize, + ) + return self._stubs['search_jobs'] + + @property + def search_jobs_for_alert(self) -> Callable[ + [job_service.SearchJobsRequest], + Awaitable[job_service.SearchJobsResponse]]: + r"""Return a callable for the search jobs for alert method over gRPC. + + Searches for jobs using the provided + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + + This API call is intended for the use case of targeting passive + job seekers (for example, job seekers who have signed up to + receive email alerts about potential job opportunities), and has + different algorithmic adjustments that are targeted to passive + job seekers. + + This call constrains the + [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + present in the database, and only returns jobs the caller has + permission to search against. + + Returns: + Callable[[~.SearchJobsRequest], + Awaitable[~.SearchJobsResponse]]: + 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_jobs_for_alert' not in self._stubs: + self._stubs['search_jobs_for_alert'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.JobService/SearchJobsForAlert', + request_serializer=job_service.SearchJobsRequest.serialize, + response_deserializer=job_service.SearchJobsResponse.deserialize, + ) + return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/__init__.py new file mode 100644 index 00000000..03b84ddf --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 .client import TenantServiceClient +from .async_client import TenantServiceAsyncClient + +__all__ = ( + 'TenantServiceClient', + 'TenantServiceAsyncClient', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/async_client.py new file mode 100644 index 00000000..07a22384 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/async_client.py @@ -0,0 +1,829 @@ +# -*- 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 +import pkg_resources + +from google.api_core.client_options import ClientOptions +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.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +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 +from google.cloud.talent_v4beta1.types import tenant_service +from google.longrunning import operations_pb2 +from .transports.base import TenantServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport +from .client import TenantServiceClient + + +class TenantServiceAsyncClient: + """A service that handles tenant management, including CRUD and + enumeration. + """ + + _client: TenantServiceClient + + DEFAULT_ENDPOINT = TenantServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = TenantServiceClient.DEFAULT_MTLS_ENDPOINT + + tenant_path = staticmethod(TenantServiceClient.tenant_path) + parse_tenant_path = staticmethod(TenantServiceClient.parse_tenant_path) + common_billing_account_path = staticmethod(TenantServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(TenantServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(TenantServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(TenantServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(TenantServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(TenantServiceClient.parse_common_organization_path) + common_project_path = staticmethod(TenantServiceClient.common_project_path) + parse_common_project_path = staticmethod(TenantServiceClient.parse_common_project_path) + common_location_path = staticmethod(TenantServiceClient.common_location_path) + parse_common_location_path = staticmethod(TenantServiceClient.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: + TenantServiceAsyncClient: The constructed client. + """ + return TenantServiceClient.from_service_account_info.__func__(TenantServiceAsyncClient, 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: + TenantServiceAsyncClient: The constructed client. + """ + return TenantServiceClient.from_service_account_file.__func__(TenantServiceAsyncClient, 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 TenantServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> TenantServiceTransport: + """Returns the transport used by the client instance. + + Returns: + TenantServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(TenantServiceClient).get_transport_class, type(TenantServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, TenantServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the tenant 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, ~.TenantServiceTransport]): 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 = TenantServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_tenant(self, + request: Union[tenant_service.CreateTenantRequest, dict] = None, + *, + parent: str = None, + tenant: gct_tenant.Tenant = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_tenant.Tenant: + r"""Creates a new tenant entity. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_create_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + tenant = talent_v4beta1.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4beta1.CreateTenantRequest( + parent="parent_value", + tenant=tenant, + ) + + # Make the request + response = await client.create_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CreateTenantRequest, dict]): + The request object. The Request of the CreateTenant + method. + parent (:class:`str`): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tenant (:class:`google.cloud.talent_v4beta1.types.Tenant`): + Required. The tenant to be created. + This corresponds to the ``tenant`` 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.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + profiles. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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, tenant]) + 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 = tenant_service.CreateTenantRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if tenant is not None: + request.tenant = tenant + + # 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_tenant, + 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_tenant(self, + request: Union[tenant_service.GetTenantRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tenant.Tenant: + r"""Retrieves specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_get_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetTenantRequest( + name="name_value", + ) + + # Make the request + response = await client.get_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.GetTenantRequest, dict]): + The request object. Request for getting a tenant by + name. + name (:class:`str`): + Required. The resource name of the tenant to be + retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenants/bar". + + 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.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + profiles. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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 = tenant_service.GetTenantRequest(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_tenant, + 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_tenant(self, + request: Union[tenant_service.UpdateTenantRequest, dict] = None, + *, + tenant: gct_tenant.Tenant = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_tenant.Tenant: + r"""Updates specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_update_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + tenant = talent_v4beta1.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4beta1.UpdateTenantRequest( + tenant=tenant, + ) + + # Make the request + response = await client.update_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.UpdateTenantRequest, dict]): + The request object. Request for updating a specified + tenant. + tenant (:class:`google.cloud.talent_v4beta1.types.Tenant`): + Required. The tenant resource to + replace the current resource in the + system. + + This corresponds to the ``tenant`` 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.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + profiles. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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([tenant]) + 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 = tenant_service.UpdateTenantRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if tenant is not None: + request.tenant = tenant + + # 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_tenant, + 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(( + ("tenant.name", request.tenant.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_tenant(self, + request: Union[tenant_service.DeleteTenantRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_delete_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteTenantRequest( + name="name_value", + ) + + # Make the request + await client.delete_tenant(request=request) + + Args: + request (Union[google.cloud.talent_v4beta1.types.DeleteTenantRequest, dict]): + The request object. Request to delete a tenant. + name (:class:`str`): + Required. The resource name of the tenant to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenants/bar". + + 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 = tenant_service.DeleteTenantRequest(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_tenant, + 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_tenants(self, + request: Union[tenant_service.ListTenantsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTenantsAsyncPager: + r"""Lists all tenants associated with the project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + async def sample_list_tenants(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListTenantsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tenants(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.ListTenantsRequest, dict]): + The request object. List tenants for which the client + has ACL visibility. + parent (:class:`str`): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + + 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.tenant_service.pagers.ListTenantsAsyncPager: + The List tenants 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 = tenant_service.ListTenantsRequest(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_tenants, + 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.ListTenantsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # 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 + + 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__ = ( + "TenantServiceAsyncClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/client.py new file mode 100644 index 00000000..0e971a2e --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/client.py @@ -0,0 +1,1010 @@ +# -*- 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 +import pkg_resources + +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.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +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 +from google.cloud.talent_v4beta1.types import tenant_service +from google.longrunning import operations_pb2 +from .transports.base import TenantServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import TenantServiceGrpcTransport +from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport + + +class TenantServiceClientMeta(type): + """Metaclass for the TenantService 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[TenantServiceTransport]] + _transport_registry["grpc"] = TenantServiceGrpcTransport + _transport_registry["grpc_asyncio"] = TenantServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[TenantServiceTransport]: + """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 TenantServiceClient(metaclass=TenantServiceClientMeta): + """A service that handles tenant 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: + TenantServiceClient: 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: + TenantServiceClient: 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) -> TenantServiceTransport: + """Returns the transport used by the client instance. + + Returns: + TenantServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @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, TenantServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the tenant 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, TenantServiceTransport]): 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, TenantServiceTransport): + # transport is a TenantServiceTransport 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, + api_audience=client_options.api_audience, + ) + + def create_tenant(self, + request: Union[tenant_service.CreateTenantRequest, dict] = None, + *, + parent: str = None, + tenant: gct_tenant.Tenant = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_tenant.Tenant: + r"""Creates a new tenant entity. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_create_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + tenant = talent_v4beta1.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4beta1.CreateTenantRequest( + parent="parent_value", + tenant=tenant, + ) + + # Make the request + response = client.create_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.CreateTenantRequest, dict]): + The request object. The Request of the CreateTenant + method. + parent (str): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tenant (google.cloud.talent_v4beta1.types.Tenant): + Required. The tenant to be created. + This corresponds to the ``tenant`` 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.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + profiles. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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, tenant]) + 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 tenant_service.CreateTenantRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.CreateTenantRequest): + request = tenant_service.CreateTenantRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if tenant is not None: + request.tenant = tenant + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_tenant] + + # 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_tenant(self, + request: Union[tenant_service.GetTenantRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tenant.Tenant: + r"""Retrieves specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_get_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetTenantRequest( + name="name_value", + ) + + # Make the request + response = client.get_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.GetTenantRequest, dict]): + The request object. Request for getting a tenant by + name. + name (str): + Required. The resource name of the tenant to be + retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenants/bar". + + 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.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + profiles. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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 tenant_service.GetTenantRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.GetTenantRequest): + request = tenant_service.GetTenantRequest(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_tenant] + + # 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_tenant(self, + request: Union[tenant_service.UpdateTenantRequest, dict] = None, + *, + tenant: gct_tenant.Tenant = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gct_tenant.Tenant: + r"""Updates specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_update_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + tenant = talent_v4beta1.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4beta1.UpdateTenantRequest( + tenant=tenant, + ) + + # Make the request + response = client.update_tenant(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.UpdateTenantRequest, dict]): + The request object. Request for updating a specified + tenant. + tenant (google.cloud.talent_v4beta1.types.Tenant): + Required. The tenant resource to + replace the current resource in the + system. + + This corresponds to the ``tenant`` 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.Tenant: + A Tenant resource represents a tenant + in the service. A tenant is a group or + entity that shares common access with + specific privileges for resources like + profiles. Customer may create multiple + tenants to provide data isolation for + different groups. + + """ + # 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([tenant]) + 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 tenant_service.UpdateTenantRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.UpdateTenantRequest): + request = tenant_service.UpdateTenantRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if tenant is not None: + request.tenant = tenant + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_tenant] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("tenant.name", request.tenant.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_tenant(self, + request: Union[tenant_service.DeleteTenantRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes specified tenant. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_delete_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteTenantRequest( + name="name_value", + ) + + # Make the request + client.delete_tenant(request=request) + + Args: + request (Union[google.cloud.talent_v4beta1.types.DeleteTenantRequest, dict]): + The request object. Request to delete a tenant. + name (str): + Required. The resource name of the tenant to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}", for + example, "projects/foo/tenants/bar". + + 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 tenant_service.DeleteTenantRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.DeleteTenantRequest): + request = tenant_service.DeleteTenantRequest(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_tenant] + + # 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_tenants(self, + request: Union[tenant_service.ListTenantsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTenantsPager: + r"""Lists all tenants associated with the project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import talent_v4beta1 + + def sample_list_tenants(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListTenantsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tenants(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.talent_v4beta1.types.ListTenantsRequest, dict]): + The request object. List tenants for which the client + has ACL visibility. + parent (str): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + + 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.tenant_service.pagers.ListTenantsPager: + The List tenants 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 tenant_service.ListTenantsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, tenant_service.ListTenantsRequest): + request = tenant_service.ListTenantsRequest(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_tenants] + + # 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.ListTenantsPager( + 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() + + 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( + gapic_version=pkg_resources.get_distribution( + "google-cloud-talent", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "TenantServiceClient", +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/pagers.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/pagers.py new file mode 100644 index 00000000..a130d1f4 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/pagers.py @@ -0,0 +1,140 @@ +# -*- 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, Sequence, Tuple, Optional, Iterator + +from google.cloud.talent_v4beta1.types import tenant +from google.cloud.talent_v4beta1.types import tenant_service + + +class ListTenantsPager: + """A pager for iterating through ``list_tenants`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.ListTenantsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``tenants`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListTenants`` requests and continue to iterate + through the ``tenants`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.ListTenantsResponse` + 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[..., tenant_service.ListTenantsResponse], + request: tenant_service.ListTenantsRequest, + response: tenant_service.ListTenantsResponse, + *, + 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.ListTenantsRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.ListTenantsResponse): + 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 = tenant_service.ListTenantsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[tenant_service.ListTenantsResponse]: + 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[tenant.Tenant]: + for page in self.pages: + yield from page.tenants + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListTenantsAsyncPager: + """A pager for iterating through ``list_tenants`` requests. + + This class thinly wraps an initial + :class:`google.cloud.talent_v4beta1.types.ListTenantsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``tenants`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListTenants`` requests and continue to iterate + through the ``tenants`` field on the + corresponding responses. + + All the usual :class:`google.cloud.talent_v4beta1.types.ListTenantsResponse` + 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[tenant_service.ListTenantsResponse]], + request: tenant_service.ListTenantsRequest, + response: tenant_service.ListTenantsResponse, + *, + 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.ListTenantsRequest): + The initial request object. + response (google.cloud.talent_v4beta1.types.ListTenantsResponse): + 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 = tenant_service.ListTenantsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[tenant_service.ListTenantsResponse]: + 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[tenant.Tenant]: + async def async_generator(): + async for page in self.pages: + for response in page.tenants: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py new file mode 100644 index 00000000..59edc02c --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- 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 TenantServiceTransport +from .grpc import TenantServiceGrpcTransport +from .grpc_asyncio import TenantServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[TenantServiceTransport]] +_transport_registry['grpc'] = TenantServiceGrpcTransport +_transport_registry['grpc_asyncio'] = TenantServiceGrpcAsyncIOTransport + +__all__ = ( + 'TenantServiceTransport', + 'TenantServiceGrpcTransport', + 'TenantServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py new file mode 100644 index 00000000..2c972f1e --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py @@ -0,0 +1,245 @@ +# -*- 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 pkg_resources + +import google.auth # type: ignore +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 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.talent_v4beta1.types import tenant +from google.cloud.talent_v4beta1.types import tenant as gct_tenant +from google.cloud.talent_v4beta1.types import tenant_service +from google.longrunning import operations_pb2 +from google.protobuf import empty_pb2 # type: ignore + +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 TenantServiceTransport(abc.ABC): + """Abstract transport class for TenantService.""" + + 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, + api_audience: Optional[str] = None, + **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. + """ + + 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) + # 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 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 + + # 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 = { + self.create_tenant: gapic_v1.method.wrap_method( + self.create_tenant, + default_timeout=30.0, + client_info=client_info, + ), + self.get_tenant: gapic_v1.method.wrap_method( + self.get_tenant, + 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_tenant: gapic_v1.method.wrap_method( + self.update_tenant, + default_timeout=30.0, + client_info=client_info, + ), + self.delete_tenant: gapic_v1.method.wrap_method( + self.delete_tenant, + 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_tenants: gapic_v1.method.wrap_method( + self.list_tenants, + 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_tenant(self) -> Callable[ + [tenant_service.CreateTenantRequest], + Union[ + gct_tenant.Tenant, + Awaitable[gct_tenant.Tenant] + ]]: + raise NotImplementedError() + + @property + def get_tenant(self) -> Callable[ + [tenant_service.GetTenantRequest], + Union[ + tenant.Tenant, + Awaitable[tenant.Tenant] + ]]: + raise NotImplementedError() + + @property + def update_tenant(self) -> Callable[ + [tenant_service.UpdateTenantRequest], + Union[ + gct_tenant.Tenant, + Awaitable[gct_tenant.Tenant] + ]]: + raise NotImplementedError() + + @property + def delete_tenant(self) -> Callable[ + [tenant_service.DeleteTenantRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def list_tenants(self) -> Callable[ + [tenant_service.ListTenantsRequest], + Union[ + tenant_service.ListTenantsResponse, + Awaitable[tenant_service.ListTenantsResponse] + ]]: + 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() + + +__all__ = ( + 'TenantServiceTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py new file mode 100644 index 00000000..89f69c3a --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py @@ -0,0 +1,391 @@ +# -*- 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.talent_v4beta1.types import tenant +from google.cloud.talent_v4beta1.types import tenant as gct_tenant +from google.cloud.talent_v4beta1.types import tenant_service +from google.longrunning import operations_pb2 +from google.protobuf import empty_pb2 # type: ignore +from .base import TenantServiceTransport, DEFAULT_CLIENT_INFO + + +class TenantServiceGrpcTransport(TenantServiceTransport): + """gRPC backend transport for TenantService. + + A service that handles tenant 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_tenant(self) -> Callable[ + [tenant_service.CreateTenantRequest], + gct_tenant.Tenant]: + r"""Return a callable for the create tenant method over gRPC. + + Creates a new tenant entity. + + Returns: + Callable[[~.CreateTenantRequest], + ~.Tenant]: + 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_tenant' not in self._stubs: + self._stubs['create_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/CreateTenant', + request_serializer=tenant_service.CreateTenantRequest.serialize, + response_deserializer=gct_tenant.Tenant.deserialize, + ) + return self._stubs['create_tenant'] + + @property + def get_tenant(self) -> Callable[ + [tenant_service.GetTenantRequest], + tenant.Tenant]: + r"""Return a callable for the get tenant method over gRPC. + + Retrieves specified tenant. + + Returns: + Callable[[~.GetTenantRequest], + ~.Tenant]: + 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_tenant' not in self._stubs: + self._stubs['get_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/GetTenant', + request_serializer=tenant_service.GetTenantRequest.serialize, + response_deserializer=tenant.Tenant.deserialize, + ) + return self._stubs['get_tenant'] + + @property + def update_tenant(self) -> Callable[ + [tenant_service.UpdateTenantRequest], + gct_tenant.Tenant]: + r"""Return a callable for the update tenant method over gRPC. + + Updates specified tenant. + + Returns: + Callable[[~.UpdateTenantRequest], + ~.Tenant]: + 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_tenant' not in self._stubs: + self._stubs['update_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/UpdateTenant', + request_serializer=tenant_service.UpdateTenantRequest.serialize, + response_deserializer=gct_tenant.Tenant.deserialize, + ) + return self._stubs['update_tenant'] + + @property + def delete_tenant(self) -> Callable[ + [tenant_service.DeleteTenantRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete tenant method over gRPC. + + Deletes specified tenant. + + Returns: + Callable[[~.DeleteTenantRequest], + ~.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_tenant' not in self._stubs: + self._stubs['delete_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/DeleteTenant', + request_serializer=tenant_service.DeleteTenantRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_tenant'] + + @property + def list_tenants(self) -> Callable[ + [tenant_service.ListTenantsRequest], + tenant_service.ListTenantsResponse]: + r"""Return a callable for the list tenants method over gRPC. + + Lists all tenants associated with the project. + + Returns: + Callable[[~.ListTenantsRequest], + ~.ListTenantsResponse]: + 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_tenants' not in self._stubs: + self._stubs['list_tenants'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/ListTenants', + request_serializer=tenant_service.ListTenantsRequest.serialize, + response_deserializer=tenant_service.ListTenantsResponse.deserialize, + ) + return self._stubs['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" + + +__all__ = ( + 'TenantServiceGrpcTransport', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py new file mode 100644 index 00000000..826d2a17 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py @@ -0,0 +1,390 @@ +# -*- 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.talent_v4beta1.types import tenant +from google.cloud.talent_v4beta1.types import tenant as gct_tenant +from google.cloud.talent_v4beta1.types import tenant_service +from google.longrunning import operations_pb2 +from google.protobuf import empty_pb2 # type: ignore +from .base import TenantServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import TenantServiceGrpcTransport + + +class TenantServiceGrpcAsyncIOTransport(TenantServiceTransport): + """gRPC AsyncIO backend transport for TenantService. + + A service that handles tenant 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, + api_audience: Optional[str] = None, + ) -> 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, + api_audience=api_audience, + ) + + 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_tenant(self) -> Callable[ + [tenant_service.CreateTenantRequest], + Awaitable[gct_tenant.Tenant]]: + r"""Return a callable for the create tenant method over gRPC. + + Creates a new tenant entity. + + Returns: + Callable[[~.CreateTenantRequest], + Awaitable[~.Tenant]]: + 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_tenant' not in self._stubs: + self._stubs['create_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/CreateTenant', + request_serializer=tenant_service.CreateTenantRequest.serialize, + response_deserializer=gct_tenant.Tenant.deserialize, + ) + return self._stubs['create_tenant'] + + @property + def get_tenant(self) -> Callable[ + [tenant_service.GetTenantRequest], + Awaitable[tenant.Tenant]]: + r"""Return a callable for the get tenant method over gRPC. + + Retrieves specified tenant. + + Returns: + Callable[[~.GetTenantRequest], + Awaitable[~.Tenant]]: + 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_tenant' not in self._stubs: + self._stubs['get_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/GetTenant', + request_serializer=tenant_service.GetTenantRequest.serialize, + response_deserializer=tenant.Tenant.deserialize, + ) + return self._stubs['get_tenant'] + + @property + def update_tenant(self) -> Callable[ + [tenant_service.UpdateTenantRequest], + Awaitable[gct_tenant.Tenant]]: + r"""Return a callable for the update tenant method over gRPC. + + Updates specified tenant. + + Returns: + Callable[[~.UpdateTenantRequest], + Awaitable[~.Tenant]]: + 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_tenant' not in self._stubs: + self._stubs['update_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/UpdateTenant', + request_serializer=tenant_service.UpdateTenantRequest.serialize, + response_deserializer=gct_tenant.Tenant.deserialize, + ) + return self._stubs['update_tenant'] + + @property + def delete_tenant(self) -> Callable[ + [tenant_service.DeleteTenantRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete tenant method over gRPC. + + Deletes specified tenant. + + Returns: + Callable[[~.DeleteTenantRequest], + 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_tenant' not in self._stubs: + self._stubs['delete_tenant'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/DeleteTenant', + request_serializer=tenant_service.DeleteTenantRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_tenant'] + + @property + def list_tenants(self) -> Callable[ + [tenant_service.ListTenantsRequest], + Awaitable[tenant_service.ListTenantsResponse]]: + r"""Return a callable for the list tenants method over gRPC. + + Lists all tenants associated with the project. + + Returns: + Callable[[~.ListTenantsRequest], + Awaitable[~.ListTenantsResponse]]: + 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_tenants' not in self._stubs: + self._stubs['list_tenants'] = self.grpc_channel.unary_unary( + '/google.cloud.talent.v4beta1.TenantService/ListTenants', + request_serializer=tenant_service.ListTenantsRequest.serialize, + response_deserializer=tenant_service.ListTenantsResponse.deserialize, + ) + return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/__init__.py new file mode 100644 index 00000000..bf3c4eac --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/__init__.py @@ -0,0 +1,158 @@ +# -*- 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 .common import ( + BatchOperationMetadata, + CompensationInfo, + CustomAttribute, + DeviceInfo, + Location, + RequestMetadata, + ResponseMetadata, + SpellingCorrection, + TimestampRange, + CommuteMethod, + CompanySize, + DegreeType, + EmploymentType, + HtmlSanitization, + JobBenefit, + JobCategory, + JobLevel, + PostingRegion, + Visibility, +) +from .company import ( + Company, +) +from .company_service import ( + CreateCompanyRequest, + DeleteCompanyRequest, + GetCompanyRequest, + ListCompaniesRequest, + ListCompaniesResponse, + UpdateCompanyRequest, +) +from .completion_service import ( + CompleteQueryRequest, + CompleteQueryResponse, +) +from .event import ( + ClientEvent, + JobEvent, +) +from .event_service import ( + CreateClientEventRequest, +) +from .filters import ( + CommuteFilter, + CompensationFilter, + JobQuery, + LocationFilter, +) +from .histogram import ( + HistogramQuery, + HistogramQueryResult, +) +from .job import ( + Job, +) +from .job_service import ( + BatchCreateJobsRequest, + BatchDeleteJobsRequest, + BatchUpdateJobsRequest, + CreateJobRequest, + DeleteJobRequest, + GetJobRequest, + JobOperationResult, + ListJobsRequest, + ListJobsResponse, + SearchJobsRequest, + SearchJobsResponse, + UpdateJobRequest, + JobView, +) +from .tenant import ( + Tenant, +) +from .tenant_service import ( + CreateTenantRequest, + DeleteTenantRequest, + GetTenantRequest, + ListTenantsRequest, + ListTenantsResponse, + UpdateTenantRequest, +) + +__all__ = ( + 'BatchOperationMetadata', + 'CompensationInfo', + 'CustomAttribute', + 'DeviceInfo', + 'Location', + 'RequestMetadata', + 'ResponseMetadata', + 'SpellingCorrection', + 'TimestampRange', + 'CommuteMethod', + 'CompanySize', + 'DegreeType', + 'EmploymentType', + 'HtmlSanitization', + 'JobBenefit', + 'JobCategory', + 'JobLevel', + 'PostingRegion', + 'Visibility', + 'Company', + 'CreateCompanyRequest', + 'DeleteCompanyRequest', + 'GetCompanyRequest', + 'ListCompaniesRequest', + 'ListCompaniesResponse', + 'UpdateCompanyRequest', + 'CompleteQueryRequest', + 'CompleteQueryResponse', + 'ClientEvent', + 'JobEvent', + 'CreateClientEventRequest', + 'CommuteFilter', + 'CompensationFilter', + 'JobQuery', + 'LocationFilter', + 'HistogramQuery', + 'HistogramQueryResult', + 'Job', + 'BatchCreateJobsRequest', + 'BatchDeleteJobsRequest', + 'BatchUpdateJobsRequest', + 'CreateJobRequest', + 'DeleteJobRequest', + 'GetJobRequest', + 'JobOperationResult', + 'ListJobsRequest', + 'ListJobsResponse', + 'SearchJobsRequest', + 'SearchJobsResponse', + 'UpdateJobRequest', + 'JobView', + 'Tenant', + 'CreateTenantRequest', + 'DeleteTenantRequest', + 'GetTenantRequest', + 'ListTenantsRequest', + 'ListTenantsResponse', + 'UpdateTenantRequest', +) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/batch.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/batch.py new file mode 100644 index 00000000..160692d0 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/batch.py @@ -0,0 +1,25 @@ +# -*- 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. +# + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + }, +) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/common.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/common.py new file mode 100644 index 00000000..247003ff --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/common.py @@ -0,0 +1,846 @@ +# -*- 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 proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_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 + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'CompanySize', + 'JobBenefit', + 'DegreeType', + 'EmploymentType', + 'JobLevel', + 'JobCategory', + 'PostingRegion', + 'Visibility', + 'HtmlSanitization', + 'CommuteMethod', + 'TimestampRange', + 'Location', + 'RequestMetadata', + 'ResponseMetadata', + 'DeviceInfo', + 'CustomAttribute', + 'SpellingCorrection', + 'CompensationInfo', + 'BatchOperationMetadata', + }, +) + + +class CompanySize(proto.Enum): + r"""An enum that represents the size of the company.""" + COMPANY_SIZE_UNSPECIFIED = 0 + MINI = 1 + SMALL = 2 + SMEDIUM = 3 + MEDIUM = 4 + BIG = 5 + BIGGER = 6 + GIANT = 7 + + +class JobBenefit(proto.Enum): + r"""An enum that represents employee benefits included with the + job. + """ + JOB_BENEFIT_UNSPECIFIED = 0 + CHILD_CARE = 1 + DENTAL = 2 + DOMESTIC_PARTNER = 3 + FLEXIBLE_HOURS = 4 + MEDICAL = 5 + LIFE_INSURANCE = 6 + PARENTAL_LEAVE = 7 + RETIREMENT_PLAN = 8 + SICK_DAYS = 9 + VACATION = 10 + VISION = 11 + + +class DegreeType(proto.Enum): + r"""Educational degree level defined in International Standard + Classification of Education (ISCED). + """ + DEGREE_TYPE_UNSPECIFIED = 0 + PRIMARY_EDUCATION = 1 + LOWER_SECONDARY_EDUCATION = 2 + UPPER_SECONDARY_EDUCATION = 3 + ADULT_REMEDIAL_EDUCATION = 4 + ASSOCIATES_OR_EQUIVALENT = 5 + BACHELORS_OR_EQUIVALENT = 6 + MASTERS_OR_EQUIVALENT = 7 + DOCTORAL_OR_EQUIVALENT = 8 + + +class EmploymentType(proto.Enum): + r"""An enum that represents the employment type of a job.""" + EMPLOYMENT_TYPE_UNSPECIFIED = 0 + FULL_TIME = 1 + PART_TIME = 2 + CONTRACTOR = 3 + CONTRACT_TO_HIRE = 4 + TEMPORARY = 5 + INTERN = 6 + VOLUNTEER = 7 + PER_DIEM = 8 + FLY_IN_FLY_OUT = 9 + OTHER_EMPLOYMENT_TYPE = 10 + + +class JobLevel(proto.Enum): + r"""An enum that represents the required experience level + required for the job. + """ + JOB_LEVEL_UNSPECIFIED = 0 + ENTRY_LEVEL = 1 + EXPERIENCED = 2 + MANAGER = 3 + DIRECTOR = 4 + EXECUTIVE = 5 + + +class JobCategory(proto.Enum): + r"""An enum that represents the categorization or primary focus + of specific role. This value is different than the "industry" + associated with a role, which is related to the categorization + of the company listing the job. + """ + JOB_CATEGORY_UNSPECIFIED = 0 + ACCOUNTING_AND_FINANCE = 1 + ADMINISTRATIVE_AND_OFFICE = 2 + ADVERTISING_AND_MARKETING = 3 + ANIMAL_CARE = 4 + ART_FASHION_AND_DESIGN = 5 + BUSINESS_OPERATIONS = 6 + CLEANING_AND_FACILITIES = 7 + COMPUTER_AND_IT = 8 + CONSTRUCTION = 9 + CUSTOMER_SERVICE = 10 + EDUCATION = 11 + ENTERTAINMENT_AND_TRAVEL = 12 + FARMING_AND_OUTDOORS = 13 + HEALTHCARE = 14 + HUMAN_RESOURCES = 15 + INSTALLATION_MAINTENANCE_AND_REPAIR = 16 + LEGAL = 17 + MANAGEMENT = 18 + MANUFACTURING_AND_WAREHOUSE = 19 + MEDIA_COMMUNICATIONS_AND_WRITING = 20 + OIL_GAS_AND_MINING = 21 + PERSONAL_CARE_AND_SERVICES = 22 + PROTECTIVE_SERVICES = 23 + REAL_ESTATE = 24 + RESTAURANT_AND_HOSPITALITY = 25 + SALES_AND_RETAIL = 26 + SCIENCE_AND_ENGINEERING = 27 + SOCIAL_SERVICES_AND_NON_PROFIT = 28 + SPORTS_FITNESS_AND_RECREATION = 29 + TRANSPORTATION_AND_LOGISTICS = 30 + + +class PostingRegion(proto.Enum): + r"""An enum that represents the job posting region. In most + cases, job postings don't need to specify a region. If a region + is given, jobs are eligible for searches in the specified + region. + """ + POSTING_REGION_UNSPECIFIED = 0 + ADMINISTRATIVE_AREA = 1 + NATION = 2 + TELECOMMUTE = 3 + + +class Visibility(proto.Enum): + r"""Deprecated. All resources are only visible to the owner. + An enum that represents who has view access to the resource. + """ + _pb_options = {'deprecated': True} + VISIBILITY_UNSPECIFIED = 0 + ACCOUNT_ONLY = 1 + SHARED_WITH_GOOGLE = 2 + SHARED_WITH_PUBLIC = 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 + determine whether and how sanitization is performed on these + fields. + """ + HTML_SANITIZATION_UNSPECIFIED = 0 + HTML_SANITIZATION_DISABLED = 1 + SIMPLE_FORMATTING_ONLY = 2 + + +class CommuteMethod(proto.Enum): + r"""Method for commute.""" + COMMUTE_METHOD_UNSPECIFIED = 0 + DRIVING = 1 + TRANSIT = 2 + WALKING = 3 + CYCLING = 4 + + +class TimestampRange(proto.Message): + r"""Message representing a period of time between two timestamps. + + Attributes: + start_time (google.protobuf.timestamp_pb2.Timestamp): + Begin of the period (inclusive). + end_time (google.protobuf.timestamp_pb2.Timestamp): + End of the period (exclusive). + """ + + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + + +class Location(proto.Message): + r"""A resource that represents a location with full geographic + information. + + Attributes: + location_type (google.cloud.talent_v4beta1.types.Location.LocationType): + The type of a location, which corresponds to the address + lines field of + [google.type.PostalAddress][google.type.PostalAddress]. For + example, "Downtown, Atlanta, GA, USA" has a type of + [LocationType.NEIGHBORHOOD][google.cloud.talent.v4beta1.Location.LocationType.NEIGHBORHOOD], + and "Kansas City, KS, USA" has a type of + [LocationType.LOCALITY][google.cloud.talent.v4beta1.Location.LocationType.LOCALITY]. + postal_address (google.type.postal_address_pb2.PostalAddress): + Postal address of the location that includes + human readable information, such as postal + delivery and payments addresses. Given a postal + address, a postal service can deliver items to a + premises, P.O. Box, or other delivery location. + lat_lng (google.type.latlng_pb2.LatLng): + An object representing a latitude/longitude + pair. + radius_miles (float): + Radius in miles of the job location. This value is derived + from the location bounding box in which a circle with the + specified radius centered from + [google.type.LatLng][google.type.LatLng] covers the area + associated with the job location. For example, currently, + "Mountain View, CA, USA" has a radius of 6.17 miles. + """ + class LocationType(proto.Enum): + r"""An enum which represents the type of a location.""" + LOCATION_TYPE_UNSPECIFIED = 0 + COUNTRY = 1 + ADMINISTRATIVE_AREA = 2 + SUB_ADMINISTRATIVE_AREA = 3 + LOCALITY = 4 + POSTAL_CODE = 5 + SUB_LOCALITY = 6 + SUB_LOCALITY_1 = 7 + SUB_LOCALITY_2 = 8 + NEIGHBORHOOD = 9 + STREET_ADDRESS = 10 + + location_type = proto.Field( + proto.ENUM, + number=1, + enum=LocationType, + ) + postal_address = proto.Field( + proto.MESSAGE, + number=2, + message=postal_address_pb2.PostalAddress, + ) + lat_lng = proto.Field( + proto.MESSAGE, + number=3, + message=latlng_pb2.LatLng, + ) + radius_miles = proto.Field( + proto.DOUBLE, + number=4, + ) + + +class RequestMetadata(proto.Message): + r"""Meta information related to the job searcher or entity + conducting the job search. This information is used to improve + the performance of the service. + + Attributes: + domain (str): + Required if + [allow_missing_ids][google.cloud.talent.v4beta1.RequestMetadata.allow_missing_ids] + is unset or ``false``. + + The client-defined scope or source of the service call, + which typically is the domain on which the service has been + implemented and is currently being run. + + For example, if the service is being run by client Foo, + Inc., on job board www.foo.com and career site www.bar.com, + then this field is set to "foo.com" for use on the job + board, and "bar.com" for use on the career site. + + Note that any improvements to the model for a particular + tenant site rely on this field being set correctly to a + unique domain. + + The maximum number of allowed characters is 255. + session_id (str): + Required if + [allow_missing_ids][google.cloud.talent.v4beta1.RequestMetadata.allow_missing_ids] + is unset or ``false``. + + A unique session identification string. A session is defined + as the duration of an end user's interaction with the + service over a certain period. Obfuscate this field for + privacy concerns before providing it to the service. + + Note that any improvements to the model for a particular + tenant site rely on this field being set correctly to a + unique session ID. + + The maximum number of allowed characters is 255. + user_id (str): + Required if + [allow_missing_ids][google.cloud.talent.v4beta1.RequestMetadata.allow_missing_ids] + is unset or ``false``. + + A unique user identification string, as determined by the + client. To have the strongest positive impact on search + quality make sure the client-level is unique. Obfuscate this + field for privacy concerns before providing it to the + service. + + Note that any improvements to the model for a particular + tenant site rely on this field being set correctly to a + unique user ID. + + The maximum number of allowed characters is 255. + allow_missing_ids (bool): + Only set when any of + [domain][google.cloud.talent.v4beta1.RequestMetadata.domain], + [session_id][google.cloud.talent.v4beta1.RequestMetadata.session_id] + and + [user_id][google.cloud.talent.v4beta1.RequestMetadata.user_id] + isn't available for some reason. It is highly recommended + not to set this field and provide accurate + [domain][google.cloud.talent.v4beta1.RequestMetadata.domain], + [session_id][google.cloud.talent.v4beta1.RequestMetadata.session_id] + and + [user_id][google.cloud.talent.v4beta1.RequestMetadata.user_id] + for the best service experience. + device_info (google.cloud.talent_v4beta1.types.DeviceInfo): + The type of device used by the job seeker at + the time of the call to the service. + """ + + domain = proto.Field( + proto.STRING, + number=1, + ) + session_id = proto.Field( + proto.STRING, + number=2, + ) + user_id = proto.Field( + proto.STRING, + number=3, + ) + allow_missing_ids = proto.Field( + proto.BOOL, + number=4, + ) + device_info = proto.Field( + proto.MESSAGE, + number=5, + message='DeviceInfo', + ) + + +class ResponseMetadata(proto.Message): + r"""Additional information returned to client, such as debugging + information. + + Attributes: + request_id (str): + A unique id associated with this call. + This id is logged for tracking purposes. + """ + + request_id = proto.Field( + proto.STRING, + number=1, + ) + + +class DeviceInfo(proto.Message): + r"""Device information collected from the job seeker, candidate, + or other entity conducting the job search. Providing this + information improves the quality of the search results across + devices. + + Attributes: + device_type (google.cloud.talent_v4beta1.types.DeviceInfo.DeviceType): + Type of the device. + id (str): + A device-specific ID. The ID must be a unique + identifier that distinguishes the device from + other devices. + """ + class DeviceType(proto.Enum): + r"""An enumeration describing an API access portal and exposure + mechanism. + """ + DEVICE_TYPE_UNSPECIFIED = 0 + WEB = 1 + MOBILE_WEB = 2 + ANDROID = 3 + IOS = 4 + BOT = 5 + OTHER = 6 + + device_type = proto.Field( + proto.ENUM, + number=1, + enum=DeviceType, + ) + id = proto.Field( + proto.STRING, + number=2, + ) + + +class CustomAttribute(proto.Message): + r"""Custom attribute values that are either filterable or + non-filterable. + + Attributes: + string_values (Sequence[str]): + Exactly one of + [string_values][google.cloud.talent.v4beta1.CustomAttribute.string_values] + or + [long_values][google.cloud.talent.v4beta1.CustomAttribute.long_values] + must be specified. + + This field is used to perform a string match + (``CASE_SENSITIVE_MATCH`` or ``CASE_INSENSITIVE_MATCH``) + search. For filterable ``string_value``\ s, a maximum total + number of 200 values is allowed, with each ``string_value`` + has a byte size of no more than 500B. For unfilterable + ``string_values``, the maximum total byte size of + unfilterable ``string_values`` is 50KB. + + Empty string isn't allowed. + long_values (Sequence[int]): + Exactly one of + [string_values][google.cloud.talent.v4beta1.CustomAttribute.string_values] + or + [long_values][google.cloud.talent.v4beta1.CustomAttribute.long_values] + must be specified. + + This field is used to perform number range search. (``EQ``, + ``GT``, ``GE``, ``LE``, ``LT``) over filterable + ``long_value``. + + Currently at most 1 + [long_values][google.cloud.talent.v4beta1.CustomAttribute.long_values] + is supported. + filterable (bool): + 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. + """ + + string_values = proto.RepeatedField( + proto.STRING, + number=1, + ) + long_values = proto.RepeatedField( + proto.INT64, + number=2, + ) + filterable = proto.Field( + proto.BOOL, + number=3, + ) + keyword_searchable = proto.Field( + proto.BOOL, + number=4, + ) + + +class SpellingCorrection(proto.Message): + r"""Spell check result. + + Attributes: + corrected (bool): + Indicates if the query was corrected by the + spell checker. + corrected_text (str): + Correction output consisting of the corrected + keyword string. + corrected_html (str): + Corrected output with html tags to highlight + the corrected words. Corrected words are called + out with the "..." html tags. + For example, the user input query is "software + enginear", where the second word, "enginear," is + incorrect. It should be "engineer". When + spelling correction is enabled, this value is + "software engineer". + """ + + corrected = proto.Field( + proto.BOOL, + number=1, + ) + corrected_text = proto.Field( + proto.STRING, + number=2, + ) + corrected_html = proto.Field( + proto.STRING, + number=3, + ) + + +class CompensationInfo(proto.Message): + r"""Job compensation details. + + Attributes: + entries (Sequence[google.cloud.talent_v4beta1.types.CompensationInfo.CompensationEntry]): + Job compensation information. + + At most one entry can be of type + [CompensationInfo.CompensationType.BASE][google.cloud.talent.v4beta1.CompensationInfo.CompensationType.BASE], + which is referred as **base compensation entry** for the + job. + annualized_base_compensation_range (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationRange): + Output only. Annualized base compensation range. Computed as + base compensation entry's + [CompensationEntry.amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] + times + [CompensationEntry.expected_units_per_year][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.expected_units_per_year]. + + See + [CompensationEntry][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry] + for explanation on compensation annualization. + annualized_total_compensation_range (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationRange): + Output only. Annualized total compensation range. Computed + as all compensation entries' + [CompensationEntry.amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] + times + [CompensationEntry.expected_units_per_year][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.expected_units_per_year]. + + See + [CompensationEntry][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry] + for explanation on compensation annualization. + """ + class CompensationType(proto.Enum): + r"""The type of compensation. + + For compensation amounts specified in non-monetary amounts, describe + the compensation scheme in the + [CompensationEntry.description][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.description]. + + For example, tipping format is described in + [CompensationEntry.description][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.description] + (for example, "expect 15-20% tips based on customer bill.") and an + estimate of the tips provided in + [CompensationEntry.amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] + or + [CompensationEntry.range][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.range] + ($10 per hour). + + For example, equity is described in + [CompensationEntry.description][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.description] + (for example, "1% - 2% equity vesting over 4 years, 1 year cliff") + and value estimated in + [CompensationEntry.amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] + or + [CompensationEntry.range][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.range]. + If no value estimate is possible, units are + [CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED] + and then further clarified in + [CompensationEntry.description][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.description] + field. + """ + COMPENSATION_TYPE_UNSPECIFIED = 0 + BASE = 1 + BONUS = 2 + SIGNING_BONUS = 3 + EQUITY = 4 + PROFIT_SHARING = 5 + COMMISSIONS = 6 + TIPS = 7 + OTHER_COMPENSATION_TYPE = 8 + + class CompensationUnit(proto.Enum): + r"""Pay frequency.""" + COMPENSATION_UNIT_UNSPECIFIED = 0 + HOURLY = 1 + DAILY = 2 + WEEKLY = 3 + MONTHLY = 4 + YEARLY = 5 + ONE_TIME = 6 + OTHER_COMPENSATION_UNIT = 7 + + class CompensationEntry(proto.Message): + r"""A compensation entry that represents one component of compensation, + such as base pay, bonus, or other compensation type. + + Annualization: One compensation entry can be annualized if + + - it contains valid + [amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] + or + [range][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.range]. + - and its + [expected_units_per_year][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.expected_units_per_year] + is set or can be derived. Its annualized range is determined as + ([amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] + or + [range][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.range]) + times + [expected_units_per_year][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.expected_units_per_year]. + + 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: + type_ (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationType): + Compensation type. + + Default is + [CompensationType.COMPENSATION_TYPE_UNSPECIFIED][google.cloud.talent.v4beta1.CompensationInfo.CompensationType.COMPENSATION_TYPE_UNSPECIFIED]. + unit (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationUnit): + Frequency of the specified amount. + + Default is + [CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED]. + amount (google.type.money_pb2.Money): + Compensation amount. + + This field is a member of `oneof`_ ``compensation_amount``. + range_ (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationRange): + Compensation range. + + This field is a member of `oneof`_ ``compensation_amount``. + description (str): + Compensation description. For example, could + indicate equity terms or provide additional + context to an estimated bonus. + expected_units_per_year (google.protobuf.wrappers_pb2.DoubleValue): + Expected number of units paid each year. If not specified, + when + [Job.employment_types][google.cloud.talent.v4beta1.Job.employment_types] + is FULLTIME, a default value is inferred based on + [unit][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.unit]. + Default values: + + - HOURLY: 2080 + - DAILY: 260 + - WEEKLY: 52 + - MONTHLY: 12 + - ANNUAL: 1 + """ + + type_ = proto.Field( + proto.ENUM, + number=1, + enum='CompensationInfo.CompensationType', + ) + unit = proto.Field( + proto.ENUM, + number=2, + enum='CompensationInfo.CompensationUnit', + ) + amount = proto.Field( + proto.MESSAGE, + number=3, + oneof='compensation_amount', + message=money_pb2.Money, + ) + range_ = proto.Field( + proto.MESSAGE, + number=4, + oneof='compensation_amount', + message='CompensationInfo.CompensationRange', + ) + description = proto.Field( + proto.STRING, + number=5, + ) + expected_units_per_year = proto.Field( + proto.MESSAGE, + number=6, + message=wrappers_pb2.DoubleValue, + ) + + class CompensationRange(proto.Message): + r"""Compensation range. + + Attributes: + max_compensation (google.type.money_pb2.Money): + The maximum amount of compensation. If left empty, the value + is set to a maximal compensation value and the currency code + is set to match the [currency + code][google.type.Money.currency_code] of min_compensation. + min_compensation (google.type.money_pb2.Money): + The minimum amount of compensation. If left empty, the value + is set to zero and the currency code is set to match the + [currency code][google.type.Money.currency_code] of + max_compensation. + """ + + max_compensation = proto.Field( + proto.MESSAGE, + number=2, + message=money_pb2.Money, + ) + min_compensation = proto.Field( + proto.MESSAGE, + number=1, + message=money_pb2.Money, + ) + + entries = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=CompensationEntry, + ) + annualized_base_compensation_range = proto.Field( + proto.MESSAGE, + number=2, + message=CompensationRange, + ) + annualized_total_compensation_range = proto.Field( + proto.MESSAGE, + number=3, + message=CompensationRange, + ) + + +class BatchOperationMetadata(proto.Message): + r"""Metadata used for long running operations returned by CTS batch + APIs. It's used to replace + [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]. + + Attributes: + state (google.cloud.talent_v4beta1.types.BatchOperationMetadata.State): + The state of a long running operation. + state_description (str): + More detailed information about operation + state. + success_count (int): + Count of successful item(s) inside an + operation. + failure_count (int): + Count of failed item(s) inside an operation. + total_count (int): + Count of total item(s) inside an operation. + create_time (google.protobuf.timestamp_pb2.Timestamp): + The time when the batch operation is created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + The time when the batch operation status is updated. The + metadata and the + [update_time][google.cloud.talent.v4beta1.BatchOperationMetadata.update_time] + is refreshed every minute otherwise cached data is returned. + end_time (google.protobuf.timestamp_pb2.Timestamp): + The time when the batch operation is finished and + [google.longrunning.Operation.done][google.longrunning.Operation.done] + is set to ``true``. + """ + class State(proto.Enum): + r"""""" + STATE_UNSPECIFIED = 0 + INITIALIZING = 1 + PROCESSING = 2 + SUCCEEDED = 3 + FAILED = 4 + CANCELLING = 5 + CANCELLED = 6 + + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_description = proto.Field( + proto.STRING, + number=2, + ) + success_count = proto.Field( + proto.INT32, + number=3, + ) + failure_count = proto.Field( + proto.INT32, + number=4, + ) + total_count = proto.Field( + proto.INT32, + number=5, + ) + create_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company.py new file mode 100644 index 00000000..26f057fe --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company.py @@ -0,0 +1,178 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4beta1.types import common + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'Company', + }, +) + + +class Company(proto.Message): + r"""A Company resource represents a company in the service. A + company is the entity that owns job postings, that is, the + hiring entity responsible for employing applicants for the job + position. + + Attributes: + name (str): + Required during company update. + + The resource name for a company. This is generated by the + service when a company is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/baz". + + If tenant id is unspecified, the default tenant is used. For + example, "projects/foo/companies/bar". + display_name (str): + Required. The display name of the company, + for example, "Google LLC". + external_id (str): + Required. Client side company identifier, + used to uniquely identify the company. + + The maximum number of allowed characters is 255. + size (google.cloud.talent_v4beta1.types.CompanySize): + The employer's company size. + headquarters_address (str): + The street address of the company's main headquarters, which + may be different from the job location. The service attempts + to geolocate the provided address, and populates a more + specific location wherever possible in + [DerivedInfo.headquarters_location][google.cloud.talent.v4beta1.Company.DerivedInfo.headquarters_location]. + hiring_agency (bool): + Set to true if it is the hiring agency that + post jobs for other employers. + + Defaults to false if not provided. + eeo_text (str): + Equal Employment Opportunity legal disclaimer + text to be associated with all jobs, and + typically to be displayed in all roles. + + The maximum number of allowed characters is 500. + website_uri (str): + The URI representing the company's primary + web site or home page, for example, + "https://www.google.com". + The maximum number of allowed characters is 255. + career_site_uri (str): + The URI to employer's career site or careers + page on the employer's web site, for example, + "https://careers.google.com". + image_uri (str): + A URI that hosts the employer's company logo. + keyword_searchable_job_custom_attributes (Sequence[str]): + A list of keys of filterable + [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes], + whose corresponding ``string_values`` are used in keyword + searches. Jobs with ``string_values`` under these specified + field keys are returned if any of the values match the + search keyword. Custom field values with parenthesis, + brackets and special symbols are not searchable as-is, and + those keyword queries must be surrounded by quotes. + derived_info (google.cloud.talent_v4beta1.types.Company.DerivedInfo): + Output only. Derived details about the + company. + suspended (bool): + Output only. Indicates whether a company is + flagged to be suspended from public availability + by the service when job content appears + suspicious, abusive, or spammy. + """ + + class DerivedInfo(proto.Message): + r"""Derived details about the company. + + Attributes: + headquarters_location (google.cloud.talent_v4beta1.types.Location): + A structured headquarters location of the company, resolved + from + [Company.headquarters_address][google.cloud.talent.v4beta1.Company.headquarters_address] + if provided. + """ + + headquarters_location = proto.Field( + proto.MESSAGE, + number=1, + message=common.Location, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + external_id = proto.Field( + proto.STRING, + number=3, + ) + size = proto.Field( + proto.ENUM, + number=4, + enum=common.CompanySize, + ) + headquarters_address = proto.Field( + proto.STRING, + number=5, + ) + hiring_agency = proto.Field( + proto.BOOL, + number=6, + ) + eeo_text = proto.Field( + proto.STRING, + number=7, + ) + website_uri = proto.Field( + proto.STRING, + number=8, + ) + career_site_uri = proto.Field( + proto.STRING, + number=9, + ) + image_uri = proto.Field( + proto.STRING, + number=10, + ) + keyword_searchable_job_custom_attributes = proto.RepeatedField( + proto.STRING, + number=11, + ) + derived_info = proto.Field( + proto.MESSAGE, + number=12, + message=DerivedInfo, + ) + suspended = proto.Field( + proto.BOOL, + number=13, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company_service.py new file mode 100644 index 00000000..fc9527a3 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company_service.py @@ -0,0 +1,222 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import company as gct_company +from google.protobuf import field_mask_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'CreateCompanyRequest', + 'GetCompanyRequest', + 'UpdateCompanyRequest', + 'DeleteCompanyRequest', + 'ListCompaniesRequest', + 'ListCompaniesResponse', + }, +) + + +class CreateCompanyRequest(proto.Message): + r"""The Request of the CreateCompany method. + + Attributes: + parent (str): + Required. Resource name of the tenant under which the + company is created. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created, for example, + "projects/foo". + company (google.cloud.talent_v4beta1.types.Company): + Required. The company to be created. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + company = proto.Field( + proto.MESSAGE, + number=2, + message=gct_company.Company, + ) + + +class GetCompanyRequest(proto.Message): + r"""Request for getting a company by name. + + Attributes: + name (str): + Required. The resource name of the company to be retrieved. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, + "projects/api-test-project/tenants/foo/companies/bar". + + If tenant id is unspecified, the default tenant is used, for + example, "projects/api-test-project/companies/bar". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateCompanyRequest(proto.Message): + r"""Request for updating a specified company. + + Attributes: + company (google.cloud.talent_v4beta1.types.Company): + Required. The company 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.UpdateCompanyRequest.update_mask] + is provided, only the specified fields in + [company][google.cloud.talent.v4beta1.UpdateCompanyRequest.company] + are updated. Otherwise all the fields are updated. + + A field mask to specify the company fields to be updated. + Only top level fields of + [Company][google.cloud.talent.v4beta1.Company] are + supported. + """ + + company = proto.Field( + proto.MESSAGE, + number=1, + message=gct_company.Company, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteCompanyRequest(proto.Message): + r"""Request to delete a company. + + Attributes: + name (str): + Required. The resource name of the company to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/baz". + + If tenant id is unspecified, the default tenant is used, for + example, "projects/foo/companies/bar". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCompaniesRequest(proto.Message): + r"""List companies for which the client has ACL visibility. + + Attributes: + parent (str): + Required. Resource name of the tenant under which the + company is created. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenant/bar". + + If tenant id is unspecified, the default tenant will be + used, for example, "projects/foo". + page_token (str): + The starting indicator from which to return + results. + page_size (int): + The maximum number of companies to be + returned, at most 100. Default is 100 if a + non-positive number is provided. + require_open_jobs (bool): + Set to true if the companies requested must have open jobs. + + Defaults to false. + + If true, at most + [page_size][google.cloud.talent.v4beta1.ListCompaniesRequest.page_size] + of companies are fetched, among which only those with open + jobs are returned. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_token = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + require_open_jobs = proto.Field( + proto.BOOL, + number=4, + ) + + +class ListCompaniesResponse(proto.Message): + r"""The List companies response object. + + Attributes: + companies (Sequence[google.cloud.talent_v4beta1.types.Company]): + Companies 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 + + companies = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_company.Company, + ) + 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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/completion_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/completion_service.py new file mode 100644 index 00000000..d42e0b4e --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/completion_service.py @@ -0,0 +1,169 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4beta1.types import common + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'CompleteQueryRequest', + 'CompleteQueryResponse', + }, +) + + +class CompleteQueryRequest(proto.Message): + r"""Auto-complete parameters. + + Attributes: + parent (str): + Required. Resource name of tenant the completion is + performed within. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenant/bar". + + If tenant id is unspecified, the default tenant is used, for + example, "projects/foo". + query (str): + Required. The query used to generate + suggestions. + The maximum number of allowed characters is 255. + language_codes (Sequence[str]): + The list of languages of the query. This is the BCP-47 + language code, such as "en-US" or "sr-Latn". For more + information, see `Tags for Identifying + Languages `__. + + The maximum number of allowed characters is 255. + page_size (int): + Required. Completion result count. + The maximum allowed page size is 10. + company (str): + If provided, restricts completion to specified company. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", + for example, "projects/foo/tenants/bar/companies/baz". + + If tenant id is unspecified, the default tenant is used, for + example, "projects/foo". + scope (google.cloud.talent_v4beta1.types.CompleteQueryRequest.CompletionScope): + The scope of the completion. The defaults is + [CompletionScope.PUBLIC][google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionScope.PUBLIC]. + type_ (google.cloud.talent_v4beta1.types.CompleteQueryRequest.CompletionType): + The completion topic. The default is + [CompletionType.COMBINED][google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType.COMBINED]. + """ + class CompletionScope(proto.Enum): + r"""Enum to specify the scope of completion.""" + COMPLETION_SCOPE_UNSPECIFIED = 0 + TENANT = 1 + PUBLIC = 2 + + class CompletionType(proto.Enum): + r"""Enum to specify auto-completion topics.""" + COMPLETION_TYPE_UNSPECIFIED = 0 + JOB_TITLE = 1 + COMPANY_NAME = 2 + COMBINED = 3 + + parent = proto.Field( + proto.STRING, + number=1, + ) + query = proto.Field( + proto.STRING, + number=2, + ) + language_codes = proto.RepeatedField( + proto.STRING, + number=3, + ) + page_size = proto.Field( + proto.INT32, + number=4, + ) + company = proto.Field( + proto.STRING, + number=5, + ) + scope = proto.Field( + proto.ENUM, + number=6, + enum=CompletionScope, + ) + type_ = proto.Field( + proto.ENUM, + number=7, + enum=CompletionType, + ) + + +class CompleteQueryResponse(proto.Message): + r"""Response of auto-complete query. + + Attributes: + completion_results (Sequence[google.cloud.talent_v4beta1.types.CompleteQueryResponse.CompletionResult]): + Results of the matching job/company + candidates. + metadata (google.cloud.talent_v4beta1.types.ResponseMetadata): + Additional information for the API + invocation, such as the request tracking id. + """ + + class CompletionResult(proto.Message): + r"""Resource that represents completion results. + + Attributes: + suggestion (str): + The suggestion for the query. + type_ (google.cloud.talent_v4beta1.types.CompleteQueryRequest.CompletionType): + The completion topic. + image_uri (str): + The URI of the company image for + [COMPANY_NAME][google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType.COMPANY_NAME]. + """ + + suggestion = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum='CompleteQueryRequest.CompletionType', + ) + image_uri = proto.Field( + proto.STRING, + number=3, + ) + + completion_results = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=CompletionResult, + ) + metadata = proto.Field( + proto.MESSAGE, + number=2, + message=common.ResponseMetadata, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event.py new file mode 100644 index 00000000..f9e5faf8 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event.py @@ -0,0 +1,155 @@ +# -*- 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 proto # type: ignore + +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'ClientEvent', + 'JobEvent', + }, +) + + +class ClientEvent(proto.Message): + r"""An event issued when an end user interacts with the + application that implements Cloud Talent Solution. Providing + this information improves the quality of results for the API + clients, enabling the service to perform optimally. The number + of events sent must be consistent with other calls, such as job + searches, issued to the service by the client. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + request_id (str): + Strongly recommended for the best service experience. + + A unique ID generated in the API responses. It can be found + in + [ResponseMetadata.request_id][google.cloud.talent.v4beta1.ResponseMetadata.request_id]. + event_id (str): + Required. A unique identifier, generated by + the client application. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Required. The timestamp of the event. + job_event (google.cloud.talent_v4beta1.types.JobEvent): + An event issued when a job seeker 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 + or other users, for example, feedback on why a + profile was bookmarked. + """ + + request_id = proto.Field( + proto.STRING, + number=1, + ) + event_id = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + job_event = proto.Field( + proto.MESSAGE, + number=5, + oneof='event', + message='JobEvent', + ) + event_notes = proto.Field( + proto.STRING, + number=9, + ) + + +class JobEvent(proto.Message): + r"""An event issued when a job seeker interacts with the + application that implements Cloud Talent Solution. + + Attributes: + type_ (google.cloud.talent_v4beta1.types.JobEvent.JobEventType): + Required. The type of the event (see + [JobEventType][google.cloud.talent.v4beta1.JobEvent.JobEventType]). + jobs (Sequence[str]): + Required. The [job + name(s)][google.cloud.talent.v4beta1.Job.name] associated + with this event. For example, if this is an + [impression][google.cloud.talent.v4beta1.JobEvent.JobEventType.IMPRESSION] + event, this field contains the identifiers of all jobs shown + to the job seeker. If this was a + [view][google.cloud.talent.v4beta1.JobEvent.JobEventType.VIEW] + event, this field contains the identifier of the viewed job. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}", + for example, "projects/foo/tenants/bar/jobs/baz". + profile (str): + The [profile name][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". + """ + class JobEventType(proto.Enum): + r"""An enumeration of an event attributed to the behavior of the + end user, such as a job seeker. + """ + JOB_EVENT_TYPE_UNSPECIFIED = 0 + IMPRESSION = 1 + VIEW = 2 + VIEW_REDIRECT = 3 + APPLICATION_START = 4 + APPLICATION_FINISH = 5 + APPLICATION_QUICK_SUBMISSION = 6 + APPLICATION_REDIRECT = 7 + APPLICATION_START_FROM_SEARCH = 8 + APPLICATION_REDIRECT_FROM_SEARCH = 9 + APPLICATION_COMPANY_SUBMIT = 10 + BOOKMARK = 11 + NOTIFICATION = 12 + HIRED = 13 + SENT_CV = 14 + INTERVIEW_GRANTED = 15 + + type_ = proto.Field( + proto.ENUM, + number=1, + enum=JobEventType, + ) + jobs = proto.RepeatedField( + proto.STRING, + number=2, + ) + profile = proto.Field( + proto.STRING, + number=3, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event_service.py new file mode 100644 index 00000000..3d029ae4 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event_service.py @@ -0,0 +1,58 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4beta1.types import event + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'CreateClientEventRequest', + }, +) + + +class CreateClientEventRequest(proto.Message): + r"""The report event request. + + Attributes: + parent (str): + Required. Resource name of the tenant under which the event + is created. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created, for example, + "projects/foo". + client_event (google.cloud.talent_v4beta1.types.ClientEvent): + Required. Events issued when end user + interacts with customer's application that uses + Cloud Talent Solution. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + client_event = proto.Field( + proto.MESSAGE, + number=2, + message=event.ClientEvent, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/filters.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/filters.py new file mode 100644 index 00000000..72e5205e --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/filters.py @@ -0,0 +1,511 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4beta1.types import common +from google.protobuf import duration_pb2 # type: ignore +from google.type import latlng_pb2 # type: ignore +from google.type import timeofday_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'JobQuery', + 'LocationFilter', + 'CompensationFilter', + 'CommuteFilter', + }, +) + + +class JobQuery(proto.Message): + r"""The query required to perform a search query. + + Attributes: + query (str): + The query string that matches against the job + title, description, and location fields. + + The maximum number of allowed characters is 255. + query_language_code (str): + The language code of + [query][google.cloud.talent.v4beta1.JobQuery.query]. For + example, "en-US". This field helps to better interpret the + query. + + If a value isn't specified, the query language code is + automatically detected, which may not be accurate. + + Language code should be in BCP-47 format, such as "en-US" or + "sr-Latn". For more information, see `Tags for Identifying + Languages `__. + companies (Sequence[str]): + This filter specifies the company entities to search + against. + + If a value isn't specified, jobs are searched for against + all companies. + + If multiple values are specified, jobs are searched against + the companies specified. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". + For example, "projects/foo/tenants/bar/companies/baz". + + If tenant id is unspecified, the default tenant is used. For + example, "projects/foo/companies/bar". + + At most 20 company filters are allowed. + location_filters (Sequence[google.cloud.talent_v4beta1.types.LocationFilter]): + The location filter specifies geo-regions containing the + jobs to search against. See + [LocationFilter][google.cloud.talent.v4beta1.LocationFilter] + for more information. + + If a location value isn't specified, jobs fitting the other + search criteria are retrieved regardless of where they're + located. + + If multiple values are specified, jobs are retrieved from + any of the specified locations. If different values are + specified for the + [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] + parameter, the maximum provided distance is used for all + locations. + + At most 5 location filters are allowed. + job_categories (Sequence[google.cloud.talent_v4beta1.types.JobCategory]): + The category filter specifies the categories of jobs to + search against. See + [JobCategory][google.cloud.talent.v4beta1.JobCategory] for + more information. + + If a value isn't specified, jobs from any category are + searched against. + + If multiple values are specified, jobs from any of the + specified categories are searched against. + commute_filter (google.cloud.talent_v4beta1.types.CommuteFilter): + Allows filtering jobs by commute time with different travel + methods (for example, driving or public transit). + + Note: This only works when you specify a + [CommuteMethod][google.cloud.talent.v4beta1.CommuteMethod]. + In this case, + [location_filters][google.cloud.talent.v4beta1.JobQuery.location_filters] + is ignored. + + Currently we don't support sorting by commute time. + company_display_names (Sequence[str]): + This filter specifies the company + [Company.display_name][google.cloud.talent.v4beta1.Company.display_name] + 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. + + If multiple values are specified, jobs within the search + results may be associated with any of the specified + companies. + + At most 20 company display name filters are allowed. + compensation_filter (google.cloud.talent_v4beta1.types.CompensationFilter): + This search filter is applied only to + [Job.compensation_info][google.cloud.talent.v4beta1.Job.compensation_info]. + For example, if the filter is specified as "Hourly job with + per-hour compensation > $15", only jobs meeting these + criteria are searched. If a filter isn't defined, all open + jobs are searched. + custom_attribute_filter (str): + This filter specifies a structured syntax to match against + the + [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes] + marked as ``filterable``. + + The syntax for this expression is a subset of SQL syntax. + + Supported operators are: ``=``, ``!=``, ``<``, ``<=``, + ``>``, and ``>=`` where the left of the operator is a custom + field key and the right of the operator is a number or a + quoted string. You must escape backslash (\) and quote (") + characters. + + Supported functions are ``LOWER([field_name])`` to perform a + case insensitive match and ``EMPTY([field_name])`` 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"), a maximum of 100 comparisons or functions are + allowed in the expression. The expression must be < 10000 + bytes in length. + + Sample Query: + ``(LOWER(driving_license)="class \"a\"" OR EMPTY(driving_license)) AND driving_years > 10`` + 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". + Defaults to false: a spell check is performed. + employment_types (Sequence[google.cloud.talent_v4beta1.types.EmploymentType]): + The employment type filter specifies the employment type of + jobs to search against, such as + [EmploymentType.FULL_TIME][google.cloud.talent.v4beta1.EmploymentType.FULL_TIME]. + + If a value isn't specified, jobs in the search results + includes any employment type. + + If multiple values are specified, jobs in the search results + include any of the specified employment types. + language_codes (Sequence[str]): + This filter specifies the locale of jobs to search against, + for example, "en-US". + + If a value isn't specified, the search results can contain + jobs in any locale. + + Language codes should be in BCP-47 format, such as "en-US" + or "sr-Latn". For more information, see `Tags for + Identifying + Languages `__. + + At most 10 language code filters are allowed. + publish_time_range (google.cloud.talent_v4beta1.types.TimestampRange): + Jobs published within a range specified by + this filter are searched against. + excluded_jobs (Sequence[str]): + This filter specifies a list of job names to + be excluded during search. + At most 400 excluded job names are allowed. + """ + + query = proto.Field( + proto.STRING, + number=1, + ) + query_language_code = proto.Field( + proto.STRING, + number=14, + ) + companies = proto.RepeatedField( + proto.STRING, + number=2, + ) + location_filters = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='LocationFilter', + ) + job_categories = proto.RepeatedField( + proto.ENUM, + number=4, + enum=common.JobCategory, + ) + commute_filter = proto.Field( + proto.MESSAGE, + number=5, + message='CommuteFilter', + ) + company_display_names = proto.RepeatedField( + proto.STRING, + number=6, + ) + compensation_filter = proto.Field( + proto.MESSAGE, + number=7, + message='CompensationFilter', + ) + custom_attribute_filter = proto.Field( + proto.STRING, + number=8, + ) + disable_spell_check = proto.Field( + proto.BOOL, + number=9, + ) + employment_types = proto.RepeatedField( + proto.ENUM, + number=10, + enum=common.EmploymentType, + ) + language_codes = proto.RepeatedField( + proto.STRING, + number=11, + ) + publish_time_range = proto.Field( + proto.MESSAGE, + number=12, + message=common.TimestampRange, + ) + excluded_jobs = proto.RepeatedField( + proto.STRING, + number=13, + ) + + +class LocationFilter(proto.Message): + r"""Geographic region of the search. + + Attributes: + address (str): + The address name, such as "Mountain View" or + "Bay Area". + region_code (str): + 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://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 + provided. + distance_in_miles (float): + The distance_in_miles is applied when the location being + searched for is identified as a city or smaller. This field + is ignored if the location being searched for is a state or + larger. + 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). + [Job.posting_region][google.cloud.talent.v4beta1.Job.posting_region] + indicates if a job permits telecommuting. If this field is + set to + [TelecommutePreference.TELECOMMUTE_ALLOWED][google.cloud.talent.v4beta1.LocationFilter.TelecommutePreference.TELECOMMUTE_ALLOWED], + telecommuting jobs are searched, and + [address][google.cloud.talent.v4beta1.LocationFilter.address] + and + [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], + 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 + location filter to search for a combination of job + locations, such as "Mountain View" or "telecommuting" jobs. + However, when used in combination with other location + filters, telecommuting jobs can be treated as less relevant + than other jobs in the search response. + + This field is only used for job search requests. + negated (bool): + Whether to apply negation to the filter so + profiles matching the filter are excluded. + """ + class TelecommutePreference(proto.Enum): + r"""Specify whether to include telecommute jobs.""" + TELECOMMUTE_PREFERENCE_UNSPECIFIED = 0 + TELECOMMUTE_EXCLUDED = 1 + TELECOMMUTE_ALLOWED = 2 + TELECOMMUTE_JOBS_EXCLUDED = 3 + + address = proto.Field( + proto.STRING, + number=1, + ) + region_code = proto.Field( + proto.STRING, + number=2, + ) + lat_lng = proto.Field( + proto.MESSAGE, + number=3, + message=latlng_pb2.LatLng, + ) + distance_in_miles = proto.Field( + proto.DOUBLE, + number=4, + ) + telecommute_preference = proto.Field( + proto.ENUM, + number=5, + enum=TelecommutePreference, + ) + negated = proto.Field( + proto.BOOL, + number=6, + ) + + +class CompensationFilter(proto.Message): + r"""Filter on job compensation type and amount. + + Attributes: + type_ (google.cloud.talent_v4beta1.types.CompensationFilter.FilterType): + Required. Type of filter. + units (Sequence[google.cloud.talent_v4beta1.types.CompensationInfo.CompensationUnit]): + Required. Specify desired ``base compensation entry's`` + [CompensationInfo.CompensationUnit][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit]. + range_ (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationRange): + Compensation range. + include_jobs_with_unspecified_compensation_range (bool): + If set to true, jobs with unspecified + compensation range fields are included. + """ + class FilterType(proto.Enum): + r"""Specify the type of filtering.""" + FILTER_TYPE_UNSPECIFIED = 0 + UNIT_ONLY = 1 + UNIT_AND_AMOUNT = 2 + ANNUALIZED_BASE_AMOUNT = 3 + ANNUALIZED_TOTAL_AMOUNT = 4 + + type_ = proto.Field( + proto.ENUM, + number=1, + enum=FilterType, + ) + units = proto.RepeatedField( + proto.ENUM, + number=2, + enum=common.CompensationInfo.CompensationUnit, + ) + range_ = proto.Field( + proto.MESSAGE, + number=3, + message=common.CompensationInfo.CompensationRange, + ) + include_jobs_with_unspecified_compensation_range = proto.Field( + proto.BOOL, + number=4, + ) + + +class CommuteFilter(proto.Message): + r"""Parameters needed for commute search. + + 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: + commute_method (google.cloud.talent_v4beta1.types.CommuteMethod): + Required. The method of transportation to + calculate the commute time for. + start_coordinates (google.type.latlng_pb2.LatLng): + Required. The latitude and longitude of the + location to calculate the commute time from. + travel_duration (google.protobuf.duration_pb2.Duration): + Required. The maximum travel time in seconds. The maximum + allowed value is ``3600s`` (one hour). Format is ``123s``. + allow_imprecise_addresses (bool): + If ``true``, jobs without street level addresses may also be + returned. For city level addresses, the city center is used. + For state and coarser level addresses, text matching is + used. If this field is set to ``false`` or isn't specified, + only jobs that include street level addresses will be + returned by commute search. + road_traffic (google.cloud.talent_v4beta1.types.CommuteFilter.RoadTraffic): + Specifies the traffic density to use when + calculating commute time. + + This field is a member of `oneof`_ ``traffic_option``. + departure_time (google.type.timeofday_pb2.TimeOfDay): + The departure time used to calculate traffic impact, + represented as + [google.type.TimeOfDay][google.type.TimeOfDay] in local time + zone. + + Currently traffic model is restricted to hour level + resolution. + + This field is a member of `oneof`_ ``traffic_option``. + """ + class RoadTraffic(proto.Enum): + r"""The traffic density to use when calculating commute time.""" + ROAD_TRAFFIC_UNSPECIFIED = 0 + TRAFFIC_FREE = 1 + BUSY_HOUR = 2 + + commute_method = proto.Field( + proto.ENUM, + number=1, + enum=common.CommuteMethod, + ) + start_coordinates = proto.Field( + proto.MESSAGE, + number=2, + message=latlng_pb2.LatLng, + ) + travel_duration = proto.Field( + proto.MESSAGE, + number=3, + message=duration_pb2.Duration, + ) + allow_imprecise_addresses = proto.Field( + proto.BOOL, + number=4, + ) + road_traffic = proto.Field( + proto.ENUM, + number=5, + oneof='traffic_option', + enum=RoadTraffic, + ) + departure_time = proto.Field( + proto.MESSAGE, + number=6, + oneof='traffic_option', + message=timeofday_pb2.TimeOfDay, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/histogram.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/histogram.py new file mode 100644 index 00000000..a94682fe --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/histogram.py @@ -0,0 +1,84 @@ +# -*- 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 proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'HistogramQuery', + 'HistogramQueryResult', + }, +) + + +class HistogramQuery(proto.Message): + r"""The histogram request. + + Attributes: + histogram_query (str): + An expression specifies a histogram request against matching + resources (for example, jobs, profiles) for searches. + + See + [SearchJobsRequest.histogram_queries][google.cloud.talent.v4beta1.SearchJobsRequest.histogram_queries] + and + [SearchProfilesRequest.histogram_queries][google.cloud.talent.v4beta1.SearchProfilesRequest.histogram_queries] + for details about syntax. + """ + + histogram_query = proto.Field( + proto.STRING, + number=1, + ) + + +class HistogramQueryResult(proto.Message): + r"""Histogram result that matches + [HistogramQuery][google.cloud.talent.v4beta1.HistogramQuery] + specified in searches. + + Attributes: + histogram_query (str): + Requested histogram expression. + histogram (Mapping[str, int]): + A map from the values of the facet associated with distinct + values to the number of matching entries with corresponding + value. + + The key format is: + + - (for string histogram) string values stored in the field. + - (for named numeric bucket) name specified in ``bucket()`` + function, like for ``bucket(0, MAX, "non-negative")``, + the key will be ``non-negative``. + - (for anonymous numeric bucket) range formatted as + ``-``, for example, ``0-1000``, ``MIN-0``, and + ``0-MAX``. + """ + + histogram_query = proto.Field( + proto.STRING, + number=1, + ) + histogram = proto.MapField( + proto.STRING, + proto.INT64, + number=2, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job.py new file mode 100644 index 00000000..e6af27bb --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job.py @@ -0,0 +1,567 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4beta1.types import common +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'Job', + }, +) + + +class Job(proto.Message): + r"""A Job resource represents a job posting (also referred to as a "job + listing" or "job requisition"). A job belongs to a + [Company][google.cloud.talent.v4beta1.Company], which is the hiring + entity responsible for the job. + + Attributes: + name (str): + Required during job update. + + The resource name for the job. This is generated by the + service when a job is created. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + If tenant id is unspecified, the default tenant is used. For + example, "projects/foo/jobs/bar". + + Use of this field in job queries and API calls is preferred + over the use of + [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id] + since this value is unique. + company (str): + Required. The resource name of the company listing the job. + + The format is + "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". + For example, "projects/foo/tenants/bar/companies/baz". + + If tenant id is unspecified, the default tenant is used. For + example, "projects/foo/companies/bar". + requisition_id (str): + Required. The requisition ID, also referred to as the + posting ID, is assigned by the client to identify a job. + This field is intended to be used by clients for client + identification and tracking of postings. A job isn't allowed + to be created if there is another job with the same + [company][google.cloud.talent.v4beta1.Job.name], + [language_code][google.cloud.talent.v4beta1.Job.language_code] + and + [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id]. + + The maximum number of allowed characters is 255. + title (str): + Required. The title of the job, such as + "Software Engineer" + The maximum number of allowed characters is 500. + description (str): + Required. The description of the job, which typically + includes a multi-paragraph description of the company and + related information. Separate fields are provided on the job + object for + [responsibilities][google.cloud.talent.v4beta1.Job.responsibilities], + [qualifications][google.cloud.talent.v4beta1.Job.qualifications], + and other job characteristics. Use of these separate job + fields is recommended. + + This field accepts and sanitizes HTML input, and also + accepts bold, italic, ordered list, and unordered list + markup tags. + + The maximum number of allowed characters is 100,000. + addresses (Sequence[str]): + Strongly recommended for the best service experience. + + Location(s) where the employer is looking to hire for this + job posting. + + Specifying the full street address(es) of the hiring + location enables better API results, especially job searches + by commute time. + + At most 50 locations are allowed for best search + performance. If a job has more locations, it is suggested to + split it into multiple jobs with unique + [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id]s + (e.g. 'ReqA' becomes 'ReqA-1', 'ReqA-2', and so on.) as + multiple jobs with the same + [company][google.cloud.talent.v4beta1.Job.company], + [language_code][google.cloud.talent.v4beta1.Job.language_code] + and + [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id] + are not allowed. If the original + [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id] + must be preserved, a custom field should be used for + storage. It is also suggested to group the locations that + close to each other in the same job for better search + experience. + + The maximum number of allowed characters is 500. + application_info (google.cloud.talent_v4beta1.types.Job.ApplicationInfo): + Job application information. + job_benefits (Sequence[google.cloud.talent_v4beta1.types.JobBenefit]): + The benefits included with the job. + compensation_info (google.cloud.talent_v4beta1.types.CompensationInfo): + Job compensation information (a.k.a. "pay + rate") i.e., the compensation that will paid to + the employee. + custom_attributes (Mapping[str, google.cloud.talent_v4beta1.types.CustomAttribute]): + A map of fields to hold both filterable and non-filterable + custom job attributes that are not covered by the provided + structured fields. + + The keys of the map are strings up to 64 bytes and must + match the pattern: ``[a-zA-Z][a-zA-Z0-9_]*``. For example, + key0LikeThis or KEY_1_LIKE_THIS. + + At most 100 filterable and at most 100 unfilterable keys are + supported. For filterable ``string_values``, across all keys + at most 200 values are allowed, with each string no more + than 255 characters. For unfilterable ``string_values``, the + maximum total size of ``string_values`` across all keys is + 50KB. + degree_types (Sequence[google.cloud.talent_v4beta1.types.DegreeType]): + The desired education degrees for the job, + such as Bachelors, Masters. + department (str): + The department or functional area within the + company with the open position. + + The maximum number of allowed characters is 255. + employment_types (Sequence[google.cloud.talent_v4beta1.types.EmploymentType]): + The employment type(s) of a job, for example, [full + time][google.cloud.talent.v4beta1.EmploymentType.FULL_TIME] + or [part + time][google.cloud.talent.v4beta1.EmploymentType.PART_TIME]. + incentives (str): + A description of bonus, commission, and other + compensation incentives associated with the job + not including salary or pay. + The maximum number of allowed characters is + 10,000. + language_code (str): + The language of the posting. This field is distinct from any + requirements for fluency that are associated with the job. + + Language codes must be in BCP-47 format, such as "en-US" or + "sr-Latn". For more information, see `Tags for Identifying + Languages `__\ {: + class="external" target="_blank" }. + + If this field is unspecified and + [Job.description][google.cloud.talent.v4beta1.Job.description] + is present, detected language code based on + [Job.description][google.cloud.talent.v4beta1.Job.description] + is assigned, otherwise defaults to 'en_US'. + job_level (google.cloud.talent_v4beta1.types.JobLevel): + The experience level associated with the job, + such as "Entry Level". + promotion_value (int): + A promotion value of the job, as determined by the client. + The value determines the sort order of the jobs returned + when searching for jobs using the featured jobs search call, + with higher promotional values being returned first and ties + being resolved by relevance sort. Only the jobs with a + promotionValue >0 are returned in a FEATURED_JOB_SEARCH. + + Default value is 0, and negative values are treated as 0. + qualifications (str): + A description of the qualifications required to perform the + job. The use of this field is recommended as an alternative + to using the more general + [description][google.cloud.talent.v4beta1.Job.description] + field. + + This field accepts and sanitizes HTML input, and also + accepts bold, italic, ordered list, and unordered list + markup tags. + + The maximum number of allowed characters is 10,000. + responsibilities (str): + A description of job responsibilities. The use of this field + is recommended as an alternative to using the more general + [description][google.cloud.talent.v4beta1.Job.description] + field. + + This field accepts and sanitizes HTML input, and also + accepts bold, italic, ordered list, and unordered list + markup tags. + + The maximum number of allowed characters is 10,000. + posting_region (google.cloud.talent_v4beta1.types.PostingRegion): + The job + [PostingRegion][google.cloud.talent.v4beta1.PostingRegion] + (for example, state, country) throughout which the job is + available. If this field is set, a + [LocationFilter][google.cloud.talent.v4beta1.LocationFilter] + in a search query within the job region finds this job + posting if an exact location match isn't specified. If this + field is set to + [PostingRegion.NATION][google.cloud.talent.v4beta1.PostingRegion.NATION] + or + [PostingRegion.ADMINISTRATIVE_AREA][google.cloud.talent.v4beta1.PostingRegion.ADMINISTRATIVE_AREA], + setting job + [Job.addresses][google.cloud.talent.v4beta1.Job.addresses] + to the same location level as this field is strongly + recommended. + visibility (google.cloud.talent_v4beta1.types.Visibility): + Deprecated. The job is only visible to the owner. + + The visibility of the job. + + Defaults to + [Visibility.ACCOUNT_ONLY][google.cloud.talent.v4beta1.Visibility.ACCOUNT_ONLY] + if not specified. + job_start_time (google.protobuf.timestamp_pb2.Timestamp): + The start timestamp of the job in UTC time + zone. Typically this field is used for + contracting engagements. Invalid timestamps are + ignored. + job_end_time (google.protobuf.timestamp_pb2.Timestamp): + The end timestamp of the job. Typically this + field is used for contracting engagements. + Invalid timestamps are ignored. + posting_publish_time (google.protobuf.timestamp_pb2.Timestamp): + The timestamp this job posting was most + recently published. The default value is the + time the request arrives at the server. Invalid + timestamps are ignored. + posting_expire_time (google.protobuf.timestamp_pb2.Timestamp): + Strongly recommended for the best service experience. + + The expiration timestamp of the job. After this timestamp, + the job is marked as expired, and it no longer appears in + search results. The expired job can't be listed by the + [ListJobs][google.cloud.talent.v4beta1.JobService.ListJobs] + API, but it can be retrieved with the + [GetJob][google.cloud.talent.v4beta1.JobService.GetJob] API + or updated with the + [UpdateJob][google.cloud.talent.v4beta1.JobService.UpdateJob] + API or deleted with the + [DeleteJob][google.cloud.talent.v4beta1.JobService.DeleteJob] + API. An expired job can be updated and opened again by using + a future expiration timestamp. Updating an expired job fails + if there is another existing open job with same + [company][google.cloud.talent.v4beta1.Job.company], + [language_code][google.cloud.talent.v4beta1.Job.language_code] + and + [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id]. + + The expired jobs are retained in our system for 90 days. + However, the overall expired job count cannot exceed 3 times + the maximum number of open jobs over previous 7 days. If + this threshold is exceeded, expired jobs are cleaned out in + order of earliest expire time. Expired jobs are no longer + accessible after they are cleaned out. + + Invalid timestamps are ignored, and treated as expire time + not provided. + + If the timestamp is before the instant request is made, the + job is treated as expired immediately on creation. This kind + of job can not be updated. And when creating a job with past + timestamp, the + [posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + must be set before + [posting_expire_time][google.cloud.talent.v4beta1.Job.posting_expire_time]. + The purpose of this feature is to allow other objects, such + as [Application][google.cloud.talent.v4beta1.Application], + to refer a job that didn't exist in the system prior to + becoming expired. If you want to modify a job that was + expired on creation, delete it and create a new one. + + If this value isn't provided at the time of job creation or + is invalid, the job posting expires after 30 days from the + job's creation time. For example, if the job was created on + 2017/01/01 13:00AM UTC with an unspecified expiration date, + the job expires after 2017/01/31 13:00AM UTC. + + If this value isn't provided on job update, it depends on + the field masks set by + [UpdateJobRequest.update_mask][google.cloud.talent.v4beta1.UpdateJobRequest.update_mask]. + If the field masks include + [job_end_time][google.cloud.talent.v4beta1.Job.job_end_time], + or the masks are empty meaning that every field is updated, + the job posting expires after 30 days from the job's last + update time. Otherwise the expiration date isn't updated. + posting_create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The timestamp when this job + posting was created. + posting_update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The timestamp when this job + posting was last updated. + company_display_name (str): + Output only. Display name of the company + listing the job. + derived_info (google.cloud.talent_v4beta1.types.Job.DerivedInfo): + Output only. Derived details about the job + posting. + processing_options (google.cloud.talent_v4beta1.types.Job.ProcessingOptions): + Options for job processing. + """ + + class ApplicationInfo(proto.Message): + r"""Application related details of a job posting. + + Attributes: + emails (Sequence[str]): + Use this field to specify email address(es) + to which resumes or applications can be sent. + The maximum number of allowed characters for + each entry is 255. + instruction (str): + Use this field to provide instructions, such + as "Mail your application to ...", that a + candidate can follow to apply for the job. + This field accepts and sanitizes HTML input, and + also accepts bold, italic, ordered list, and + unordered list markup tags. + The maximum number of allowed characters is + 3,000. + uris (Sequence[str]): + Use this URI field to direct an applicant to + a website, for example to link to an online + application form. + The maximum number of allowed characters for + each entry is 2,000. + """ + + emails = proto.RepeatedField( + proto.STRING, + number=1, + ) + instruction = proto.Field( + proto.STRING, + number=2, + ) + uris = proto.RepeatedField( + proto.STRING, + number=3, + ) + + class DerivedInfo(proto.Message): + r"""Derived details about the job posting. + + Attributes: + locations (Sequence[google.cloud.talent_v4beta1.types.Location]): + Structured locations of the job, resolved from + [Job.addresses][google.cloud.talent.v4beta1.Job.addresses]. + + [locations][google.cloud.talent.v4beta1.Job.DerivedInfo.locations] + are exactly matched to + [Job.addresses][google.cloud.talent.v4beta1.Job.addresses] + in the same order. + job_categories (Sequence[google.cloud.talent_v4beta1.types.JobCategory]): + Job categories derived from + [Job.title][google.cloud.talent.v4beta1.Job.title] and + [Job.description][google.cloud.talent.v4beta1.Job.description]. + """ + + locations = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=common.Location, + ) + job_categories = proto.RepeatedField( + proto.ENUM, + number=3, + enum=common.JobCategory, + ) + + class ProcessingOptions(proto.Message): + r"""Options for job processing. + + Attributes: + disable_street_address_resolution (bool): + If set to ``true``, the service does not attempt to resolve + a more precise address for the job. + html_sanitization (google.cloud.talent_v4beta1.types.HtmlSanitization): + Option for job HTML content sanitization. Applied fields + are: + + - description + - applicationInfo.instruction + - incentives + - qualifications + - responsibilities + + HTML tags in these fields may be stripped if sanitiazation + isn't disabled. + + Defaults to + [HtmlSanitization.SIMPLE_FORMATTING_ONLY][google.cloud.talent.v4beta1.HtmlSanitization.SIMPLE_FORMATTING_ONLY]. + """ + + disable_street_address_resolution = proto.Field( + proto.BOOL, + number=1, + ) + html_sanitization = proto.Field( + proto.ENUM, + number=2, + enum=common.HtmlSanitization, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + company = proto.Field( + proto.STRING, + number=2, + ) + requisition_id = proto.Field( + proto.STRING, + number=3, + ) + title = proto.Field( + proto.STRING, + number=4, + ) + description = proto.Field( + proto.STRING, + number=5, + ) + addresses = proto.RepeatedField( + proto.STRING, + number=6, + ) + application_info = proto.Field( + proto.MESSAGE, + number=7, + message=ApplicationInfo, + ) + job_benefits = proto.RepeatedField( + proto.ENUM, + number=8, + enum=common.JobBenefit, + ) + compensation_info = proto.Field( + proto.MESSAGE, + number=9, + message=common.CompensationInfo, + ) + custom_attributes = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=10, + message=common.CustomAttribute, + ) + degree_types = proto.RepeatedField( + proto.ENUM, + number=11, + enum=common.DegreeType, + ) + department = proto.Field( + proto.STRING, + number=12, + ) + employment_types = proto.RepeatedField( + proto.ENUM, + number=13, + enum=common.EmploymentType, + ) + incentives = proto.Field( + proto.STRING, + number=14, + ) + language_code = proto.Field( + proto.STRING, + number=15, + ) + job_level = proto.Field( + proto.ENUM, + number=16, + enum=common.JobLevel, + ) + promotion_value = proto.Field( + proto.INT32, + number=17, + ) + qualifications = proto.Field( + proto.STRING, + number=18, + ) + responsibilities = proto.Field( + proto.STRING, + number=19, + ) + posting_region = proto.Field( + proto.ENUM, + number=20, + enum=common.PostingRegion, + ) + visibility = proto.Field( + proto.ENUM, + number=21, + enum=common.Visibility, + ) + job_start_time = proto.Field( + proto.MESSAGE, + number=22, + message=timestamp_pb2.Timestamp, + ) + job_end_time = proto.Field( + proto.MESSAGE, + number=23, + message=timestamp_pb2.Timestamp, + ) + posting_publish_time = proto.Field( + proto.MESSAGE, + number=24, + message=timestamp_pb2.Timestamp, + ) + posting_expire_time = proto.Field( + proto.MESSAGE, + number=25, + message=timestamp_pb2.Timestamp, + ) + posting_create_time = proto.Field( + proto.MESSAGE, + number=26, + message=timestamp_pb2.Timestamp, + ) + posting_update_time = proto.Field( + proto.MESSAGE, + number=27, + message=timestamp_pb2.Timestamp, + ) + company_display_name = proto.Field( + proto.STRING, + number=28, + ) + derived_info = proto.Field( + proto.MESSAGE, + number=29, + message=DerivedInfo, + ) + processing_options = proto.Field( + proto.MESSAGE, + number=30, + message=ProcessingOptions, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job_service.py new file mode 100644 index 00000000..bb7ffc7a --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job_service.py @@ -0,0 +1,1110 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import filters +from google.cloud.talent_v4beta1.types import histogram +from google.cloud.talent_v4beta1.types import job as gct_job +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'JobView', + 'CreateJobRequest', + 'GetJobRequest', + 'UpdateJobRequest', + 'DeleteJobRequest', + 'BatchDeleteJobsRequest', + 'ListJobsRequest', + 'ListJobsResponse', + 'SearchJobsRequest', + 'SearchJobsResponse', + 'BatchCreateJobsRequest', + 'BatchUpdateJobsRequest', + 'JobOperationResult', + }, +) + + +class JobView(proto.Enum): + r"""An enum that specifies the job attributes that are returned in the + [MatchingJob.job][google.cloud.talent.v4beta1.SearchJobsResponse.MatchingJob.job] + or + [ListJobsResponse.jobs][google.cloud.talent.v4beta1.ListJobsResponse.jobs] + fields. + """ + JOB_VIEW_UNSPECIFIED = 0 + JOB_VIEW_ID_ONLY = 1 + JOB_VIEW_MINIMAL = 2 + JOB_VIEW_SMALL = 3 + JOB_VIEW_FULL = 4 + + +class CreateJobRequest(proto.Message): + r"""Create job request. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenant/bar". If tenant id is + unspecified a default tenant is created. For example, + "projects/foo". + job (google.cloud.talent_v4beta1.types.Job): + Required. The Job to be created. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + job = proto.Field( + proto.MESSAGE, + number=2, + message=gct_job.Job, + ) + + +class GetJobRequest(proto.Message): + r"""Get job request. + + Attributes: + name (str): + Required. The resource name of the job to retrieve. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + If tenant id is unspecified, the default tenant is used. For + example, "projects/foo/jobs/bar". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateJobRequest(proto.Message): + r"""Update job request. + + Attributes: + job (google.cloud.talent_v4beta1.types.Job): + Required. The Job to be updated. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Strongly recommended for the best service experience. + + If + [update_mask][google.cloud.talent.v4beta1.UpdateJobRequest.update_mask] + is provided, only the specified fields in + [job][google.cloud.talent.v4beta1.UpdateJobRequest.job] are + updated. Otherwise all the fields are updated. + + A field mask to restrict the fields that are updated. Only + top level fields of [Job][google.cloud.talent.v4beta1.Job] + are supported. + """ + + job = proto.Field( + proto.MESSAGE, + number=1, + message=gct_job.Job, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteJobRequest(proto.Message): + r"""Delete job request. + + Attributes: + name (str): + Required. The resource name of the job to be deleted. + + The format is + "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + For example, "projects/foo/tenants/bar/jobs/baz". + + If tenant id is unspecified, the default tenant is used. For + example, "projects/foo/jobs/bar". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class BatchDeleteJobsRequest(proto.Message): + r"""Batch delete jobs request. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + filter (str): + Required. The filter string specifies the jobs to be + deleted. + + Supported operator: =, AND + + The fields eligible for filtering are: + + - ``companyName`` (Required) + - ``requisitionId`` (Required) + + Sample Query: companyName = "projects/foo/companies/bar" AND + requisitionId = "req-1". + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + + +class ListJobsRequest(proto.Message): + r"""List jobs request. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + filter (str): + Required. The filter string specifies the jobs to be + enumerated. + + Supported operator: =, AND + + The fields eligible for filtering are: + + - ``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" + - requisitionId = "req-1" + - requisitionId = "req-1" AND status = "EXPIRED". + page_token (str): + The starting point of a query result. + page_size (int): + The maximum number of jobs to be returned per page of + results. + + If + [job_view][google.cloud.talent.v4beta1.ListJobsRequest.job_view] + is set to + [JobView.JOB_VIEW_ID_ONLY][google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY], + the maximum allowed page size is 1000. Otherwise, the + maximum allowed page size is 100. + + Default is 100 if empty or a number < 1 is specified. + job_view (google.cloud.talent_v4beta1.types.JobView): + The desired job attributes returned for jobs in the search + response. Defaults to + [JobView.JOB_VIEW_FULL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL] + if no value is specified. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + page_size = proto.Field( + proto.INT32, + number=4, + ) + job_view = proto.Field( + proto.ENUM, + number=5, + enum='JobView', + ) + + +class ListJobsResponse(proto.Message): + r"""List jobs response. + + Attributes: + jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): + The Jobs for a given company. + The maximum number of items returned is based on + the limit field provided in the request. + 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 + + jobs = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_job.Job, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + metadata = proto.Field( + proto.MESSAGE, + number=3, + message=common.ResponseMetadata, + ) + + +class SearchJobsRequest(proto.Message): + r"""The Request body of the ``SearchJobs`` 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/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + search_mode (google.cloud.talent_v4beta1.types.SearchJobsRequest.SearchMode): + Mode of a search. + + Defaults to + [SearchMode.JOB_SEARCH][google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH]. + request_metadata (google.cloud.talent_v4beta1.types.RequestMetadata): + Required. The meta information collected about the job + searcher, used to improve the search quality of the service. + The identifiers (such as ``user_id``) are provided by users, + and must be unique and consistent. + job_query (google.cloud.talent_v4beta1.types.JobQuery): + Query used to search against jobs, such as + keyword, location filters, etc. + enable_broadening (bool): + Controls whether to broaden the search when + it produces sparse results. Broadened queries + append results to the end of the matching + results list. + + Defaults to false. + require_precise_result_size (bool): + This field is deprecated. + histogram_queries (Sequence[google.cloud.talent_v4beta1.types.HistogramQuery]): + An expression specifies a histogram request against matching + jobs. + + Expression syntax is an aggregation function call with + histogram facets and other options. + + Available aggregation function calls are: + + - ``count(string_histogram_facet)``: Count the number of + matching entities, for each distinct attribute value. + - ``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 + ``[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 built-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). + + Job histogram facets: + + - company_display_name: histogram by + [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name]. + - employment_type: histogram by + [Job.employment_types][google.cloud.talent.v4beta1.Job.employment_types], + for example, "FULL_TIME", "PART_TIME". + - 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. + - publish_time_in_year: histogram by the + [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + in years. Must specify list of numeric buckets in spec. + - degree_types: histogram by the + [Job.degree_types][google.cloud.talent.v4beta1.Job.degree_types], + for example, "Bachelors", "Masters". + - job_level: histogram by the + [Job.job_level][google.cloud.talent.v4beta1.Job.job_level], + for example, "Entry Level". + - country: histogram by the country code of jobs, for + example, "US", "FR". + - admin1: histogram by the admin1 code of jobs, which is a + global placeholder referring to the state, province, or + the particular term a country uses to define the + geographic structure below the country level, for + example, "CA", "IL". + - city: histogram by a combination of the "city name, + admin1 code". For example, "Mountain View, CA", "New + York, NY". + - admin1_country: histogram by a combination of the "admin1 + code, country", for example, "CA, US", "IL, US". + - city_coordinate: histogram by the city center's GPS + coordinates (latitude and longitude), for example, + 37.4038522,-122.0987765. Since the coordinates of a city + center can change, customers may need to refresh them + periodically. + - locale: histogram by the + [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], + for example, "en-US", "fr-FR". + - language: histogram by the language subtag of the + [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], + for example, "en", "fr". + - category: histogram by the + [JobCategory][google.cloud.talent.v4beta1.JobCategory], + for example, "COMPUTER_AND_IT", "HEALTHCARE". + - base_compensation_unit: histogram by the + [CompensationInfo.CompensationUnit][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit] + of base salary, for example, "WEEKLY", "MONTHLY". + - base_compensation: histogram by the base salary. Must + specify list of numeric buckets to group results by. + - annualized_base_compensation: histogram by the base + annualized salary. Must specify list of numeric buckets + to group results by. + - annualized_total_compensation: histogram by the total + annualized salary. Must specify list of numeric buckets + to group results by. + - string_custom_attribute: histogram by string + [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. + Values can be accessed via square bracket notations like + string_custom_attribute["key1"]. + - numeric_custom_attribute: histogram by numeric + [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. + Values can be accessed via square bracket notations like + numeric_custom_attribute["key1"]. Must specify list of + numeric buckets to group results by. + + Example expressions: + + - ``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")])`` + job_view (google.cloud.talent_v4beta1.types.JobView): + The desired job attributes returned for jobs in the search + response. Defaults to + [JobView.JOB_VIEW_SMALL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL] + if no value is specified. + offset (int): + An integer that specifies the current offset (that is, + starting result location, amongst the jobs deemed by the API + as relevant) in search results. This field is only + considered if + [page_token][google.cloud.talent.v4beta1.SearchJobsRequest.page_token] + is unset. + + The maximum allowed value is 5000. Otherwise an error is + thrown. + + For example, 0 means to return results starting from the + first matching job, and 10 means to return from the 11th + job. This can be used for pagination, (for example, pageSize + = 10 and offset = 10 means to return from the second page). + page_size (int): + A limit on the number of jobs returned in the + search results. Increasing this value above the + default value of 10 can increase search response + time. The value can be between 1 and 100. + page_token (str): + The token specifying the current offset within search + results. See + [SearchJobsResponse.next_page_token][google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token] + for an explanation of how to obtain the next set of query + results. + order_by (str): + The criteria determining how search results are sorted. + Default is ``"relevance desc"``. + + Supported options are: + + - ``"relevance desc"``: By relevance descending, as + determined by the API algorithms. Relevance thresholding + of query results is only available with this ordering. + - ``"posting_publish_time desc"``: By + [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + descending. + - ``"posting_update_time desc"``: By + [Job.posting_update_time][google.cloud.talent.v4beta1.Job.posting_update_time] + descending. + - ``"title"``: By + [Job.title][google.cloud.talent.v4beta1.Job.title] + ascending. + - ``"title desc"``: By + [Job.title][google.cloud.talent.v4beta1.Job.title] + descending. + - ``"annualized_base_compensation"``: By job's + [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] + ascending. Jobs whose annualized base compensation is + unspecified are put at the end of search results. + - ``"annualized_base_compensation desc"``: By job's + [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] + descending. Jobs whose annualized base compensation is + unspecified are put at the end of search results. + - ``"annualized_total_compensation"``: By job's + [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] + ascending. Jobs whose annualized base compensation is + unspecified are put at the end of search results. + - ``"annualized_total_compensation desc"``: By job's + [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] + descending. Jobs whose annualized base compensation is + unspecified are put at the end of search results. + - ``"custom_ranking desc"``: By the relevance score + adjusted to the + [SearchJobsRequest.CustomRankingInfo.ranking_expression][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression] + with weight factor assigned by + [SearchJobsRequest.CustomRankingInfo.importance_level][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level] + in descending order. + - Location sorting: Use the special syntax to order jobs by + distance: ``"distance_from('Hawaii')"``: Order by + distance from Hawaii. ``"distance_from(19.89, 155.5)"``: + Order by distance from a coordinate. + ``"distance_from('Hawaii'), distance_from('Puerto Rico')"``: + Order by multiple locations. See details below. + ``"distance_from('Hawaii'), distance_from(19.89, 155.5)"``: + Order by multiple locations. See details below. The + string can have a maximum of 256 characters. When + multiple distance centers are provided, a job that is + close to any of the distance centers would have a high + rank. When a job has multiple locations, the job location + closest to one of the distance centers will be used. Jobs + that don't have locations will be ranked at the bottom. + Distance is calculated with a precision of 11.3 meters + (37.4 feet). Diversification strategy is still applied + unless explicitly disabled in + [diversification_level][google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level]. + diversification_level (google.cloud.talent_v4beta1.types.SearchJobsRequest.DiversificationLevel): + Controls whether highly similar jobs are returned next to + each other in the search results. Jobs are identified as + highly similar based on their titles, job categories, and + locations. Highly similar results are clustered so that only + one representative job of the cluster is displayed to the + job seeker higher up in the results, with the other jobs + being displayed lower down in the results. + + Defaults to + [DiversificationLevel.SIMPLE][google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE] + if no value is specified. + custom_ranking_info (google.cloud.talent_v4beta1.types.SearchJobsRequest.CustomRankingInfo): + Controls over how job documents get ranked on + 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], + [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name], + [Job.addresses][google.cloud.talent.v4beta1.Job.addresses], + [Job.qualifications][google.cloud.talent.v4beta1.Job.qualifications]. + When disable keyword match is turned off, a keyword match + returns jobs that do not match given category filters when + there are matching keywords. For example, for the query + "program manager," a result is returned even if the job + posting has the title "software developer," which doesn't + fall into "program manager" ontology, but does have "program + manager" appearing in its description. + + For queries like "cloud" that don't contain title or + location specific ontology, jobs with "cloud" keyword + matches are returned regardless of this flag'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. + + 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): + r"""A string-represented enumeration of the job search mode. The + service operate differently for different modes of service. + """ + SEARCH_MODE_UNSPECIFIED = 0 + JOB_SEARCH = 1 + FEATURED_JOB_SEARCH = 2 + + class DiversificationLevel(proto.Enum): + r"""Controls whether highly similar jobs are returned next to + each other in the search results. Jobs are identified as highly + similar based on their titles, job categories, and locations. + Highly similar results are clustered so that only one + representative job of the cluster is displayed to the job seeker + higher up in the results, with the other jobs being displayed + lower down in the results. + """ + DIVERSIFICATION_LEVEL_UNSPECIFIED = 0 + 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]. + + Attributes: + importance_level (google.cloud.talent_v4beta1.types.SearchJobsRequest.CustomRankingInfo.ImportanceLevel): + Required. Controls over how important the score of + [CustomRankingInfo.ranking_expression][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression] + gets applied to job's final ranking position. + + An error is thrown if not specified. + ranking_expression (str): + Required. Controls over how job documents get ranked on top + of existing relevance score (determined by API algorithm). A + combination of the ranking expression and relevance score is + used to determine job's final ranking position. + + The syntax for this expression is a subset of Google SQL + syntax. + + Supported operators are: +, -, \*, /, where the left and + right side of the operator is either a numeric + [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes] + key, integer/double value or an expression that can be + evaluated to a number. + + Parenthesis are supported to adjust calculation precedence. + 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 + populated on the job or if the expression results in a + divide by zero. If an expression is invalid for a job, that + job is demoted to the end of the results. + + Sample ranking expression (year + 25) \* 0.25 - (freshness / + 0.5) + """ + class ImportanceLevel(proto.Enum): + r"""The importance level for + [CustomRankingInfo.ranking_expression][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression]. + """ + IMPORTANCE_LEVEL_UNSPECIFIED = 0 + NONE = 1 + LOW = 2 + MILD = 3 + MEDIUM = 4 + HIGH = 5 + EXTREME = 6 + + importance_level = proto.Field( + proto.ENUM, + number=1, + enum='SearchJobsRequest.CustomRankingInfo.ImportanceLevel', + ) + ranking_expression = proto.Field( + proto.STRING, + number=2, + ) + + parent = proto.Field( + proto.STRING, + number=1, + ) + search_mode = proto.Field( + proto.ENUM, + number=2, + enum=SearchMode, + ) + request_metadata = proto.Field( + proto.MESSAGE, + number=3, + message=common.RequestMetadata, + ) + job_query = proto.Field( + proto.MESSAGE, + number=4, + message=filters.JobQuery, + ) + enable_broadening = proto.Field( + proto.BOOL, + number=5, + ) + require_precise_result_size = proto.Field( + proto.BOOL, + number=6, + ) + histogram_queries = proto.RepeatedField( + proto.MESSAGE, + number=7, + message=histogram.HistogramQuery, + ) + job_view = proto.Field( + proto.ENUM, + number=8, + enum='JobView', + ) + offset = proto.Field( + proto.INT32, + number=9, + ) + page_size = proto.Field( + proto.INT32, + number=10, + ) + page_token = proto.Field( + proto.STRING, + number=11, + ) + order_by = proto.Field( + proto.STRING, + number=12, + ) + diversification_level = proto.Field( + proto.ENUM, + number=13, + enum=DiversificationLevel, + ) + custom_ranking_info = proto.Field( + proto.MESSAGE, + number=14, + message=CustomRankingInfo, + ) + disable_keyword_match = proto.Field( + proto.BOOL, + number=16, + ) + keyword_match_mode = proto.Field( + proto.ENUM, + number=18, + enum=KeywordMatchMode, + ) + + +class SearchJobsResponse(proto.Message): + r"""Response for SearchJob method. + + Attributes: + matching_jobs (Sequence[google.cloud.talent_v4beta1.types.SearchJobsResponse.MatchingJob]): + The Job entities that match the specified + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + histogram_query_results (Sequence[google.cloud.talent_v4beta1.types.HistogramQueryResult]): + The histogram results that match with specified + [SearchJobsRequest.histogram_queries][google.cloud.talent.v4beta1.SearchJobsRequest.histogram_queries]. + next_page_token (str): + The token that specifies the starting + position of the next page of results. This field + is empty if there are no more results. + location_filters (Sequence[google.cloud.talent_v4beta1.types.Location]): + The location filters that the service applied to the + specified query. If any filters are lat-lng based, the + [Location.location_type][google.cloud.talent.v4beta1.Location.location_type] + is + [Location.LocationType.LOCATION_TYPE_UNSPECIFIED][google.cloud.talent.v4beta1.Location.LocationType.LOCATION_TYPE_UNSPECIFIED]. + estimated_total_size (int): + An estimation of the number of jobs that match the specified + query. + + This number isn't guaranteed to be accurate. For accurate + results, see + [SearchJobsResponse.total_size][google.cloud.talent.v4beta1.SearchJobsResponse.total_size]. + total_size (int): + 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. + broadened_query_jobs_count (int): + If query broadening is enabled, we may append + additional results from the broadened query. + This number indicates how many of the jobs + returned in the jobs field are from the + broadened query. These results are always at the + end of the jobs list. In particular, a value of + 0, or if the field isn't set, all the jobs in + the jobs list are from the original (without + broadening) query. If this field is non-zero, + subsequent requests with offset after this + result set should contain all broadened results. + spell_correction (google.cloud.talent_v4beta1.types.SpellingCorrection): + The spell checking result, and correction. + """ + + class MatchingJob(proto.Message): + r"""Job entry with metadata inside + [SearchJobsResponse][google.cloud.talent.v4beta1.SearchJobsResponse]. + + Attributes: + job (google.cloud.talent_v4beta1.types.Job): + Job resource that matches the specified + [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + job_summary (str): + A summary of the job with core information + that's displayed on the search results listing + page. + job_title_snippet (str): + Contains snippets of text from the + [Job.title][google.cloud.talent.v4beta1.Job.title] field + most closely matching a search query's keywords, if + available. The matching query keywords are enclosed in HTML + bold tags. + search_text_snippet (str): + Contains snippets of text from the + [Job.description][google.cloud.talent.v4beta1.Job.description] + and similar fields that most closely match a search query's + keywords, if available. All HTML tags in the original fields + are stripped when returned in this field, and matching query + keywords are enclosed in HTML bold tags. + commute_info (google.cloud.talent_v4beta1.types.SearchJobsResponse.CommuteInfo): + Commute information which is generated based on specified + [CommuteFilter][google.cloud.talent.v4beta1.CommuteFilter]. + """ + + job = proto.Field( + proto.MESSAGE, + number=1, + message=gct_job.Job, + ) + job_summary = proto.Field( + proto.STRING, + number=2, + ) + job_title_snippet = proto.Field( + proto.STRING, + number=3, + ) + search_text_snippet = proto.Field( + proto.STRING, + number=4, + ) + commute_info = proto.Field( + proto.MESSAGE, + number=5, + message='SearchJobsResponse.CommuteInfo', + ) + + class CommuteInfo(proto.Message): + r"""Commute details related to this job. + + Attributes: + job_location (google.cloud.talent_v4beta1.types.Location): + Location used as the destination in the + commute calculation. + travel_duration (google.protobuf.duration_pb2.Duration): + The number of seconds required to travel to + the job location from the query location. A + duration of 0 seconds indicates that the job + isn't reachable within the requested duration, + but was returned as part of an expanded query. + """ + + job_location = proto.Field( + proto.MESSAGE, + number=1, + message=common.Location, + ) + travel_duration = proto.Field( + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, + ) + + @property + def raw_page(self): + return self + + matching_jobs = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=MatchingJob, + ) + histogram_query_results = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=histogram.HistogramQueryResult, + ) + next_page_token = proto.Field( + proto.STRING, + number=3, + ) + location_filters = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=common.Location, + ) + estimated_total_size = proto.Field( + proto.INT32, + number=5, + ) + total_size = proto.Field( + proto.INT32, + number=6, + ) + metadata = proto.Field( + proto.MESSAGE, + number=7, + message=common.ResponseMetadata, + ) + broadened_query_jobs_count = proto.Field( + proto.INT32, + number=8, + ) + spell_correction = proto.Field( + proto.MESSAGE, + number=9, + message=common.SpellingCorrection, + ) + + +class BatchCreateJobsRequest(proto.Message): + r"""Request to create a batch of jobs. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): + Required. The jobs to be created. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + jobs = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=gct_job.Job, + ) + + +class BatchUpdateJobsRequest(proto.Message): + r"""Request to update a batch of jobs. + + Attributes: + parent (str): + Required. The resource name of the tenant under which the + job is created. + + The format is "projects/{project_id}/tenants/{tenant_id}". + For example, "projects/foo/tenant/bar". If tenant id is + unspecified, a default tenant is created. For example, + "projects/foo". + jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): + Required. The jobs to be updated. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Strongly recommended for the best service experience. Be + aware that it will also increase latency when checking the + status of a batch operation. + + If + [update_mask][google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask] + is provided, only the specified fields in + [Job][google.cloud.talent.v4beta1.Job] are updated. + Otherwise all the fields are updated. + + A field mask to restrict the fields that are updated. Only + top level fields of [Job][google.cloud.talent.v4beta1.Job] + are supported. + + If + [update_mask][google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask] + is provided, The [Job][google.cloud.talent.v4beta1.Job] + inside + [JobResult][google.cloud.talent.v4beta1.JobOperationResult.JobResult] + will only contains fields that is updated, plus the Id of + the Job. Otherwise, [Job][google.cloud.talent.v4beta1.Job] + will include all fields, which can yield a very large + response. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + jobs = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=gct_job.Job, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=3, + message=field_mask_pb2.FieldMask, + ) + + +class JobOperationResult(proto.Message): + r"""The result of + [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] + or + [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] + APIs. It's used to replace + [google.longrunning.Operation.response][google.longrunning.Operation.response] + in case of success. + + Attributes: + job_results (Sequence[google.cloud.talent_v4beta1.types.JobOperationResult.JobResult]): + List of job mutation results from a batch + mutate operation. It can change until operation + status is FINISHED, FAILED or CANCELLED. + """ + + class JobResult(proto.Message): + r"""Mutation result of a job. + + Attributes: + job (google.cloud.talent_v4beta1.types.Job): + Here [Job][google.cloud.talent.v4beta1.Job] only contains + basic information including + [name][google.cloud.talent.v4beta1.Job.name], + [company][google.cloud.talent.v4beta1.Job.company], + [language_code][google.cloud.talent.v4beta1.Job.language_code] + and + [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id], + use getJob method to retrieve detailed information of the + created/updated job. + status (google.rpc.status_pb2.Status): + The status of the job processed. This field is populated if + the processing of the + [job][google.cloud.talent.v4beta1.JobOperationResult.JobResult.job] + fails. + """ + + job = proto.Field( + proto.MESSAGE, + number=1, + message=gct_job.Job, + ) + status = proto.Field( + proto.MESSAGE, + number=2, + message=status_pb2.Status, + ) + + job_results = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=JobResult, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant.py new file mode 100644 index 00000000..842f5d71 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant.py @@ -0,0 +1,91 @@ +# -*- 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 proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'Tenant', + }, +) + + +class Tenant(proto.Message): + r"""A Tenant resource represents a tenant in the service. A + tenant is a group or entity that shares common access with + specific privileges for resources like profiles. Customer may + create multiple tenants to provide data isolation for different + groups. + + Attributes: + name (str): + Required during tenant update. + + The resource name for a tenant. This is generated by the + service when a tenant is created. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + external_id (str): + Required. Client side tenant identifier, used + to uniquely identify the tenant. + The maximum number of allowed characters is 255. + usage_type (google.cloud.talent_v4beta1.types.Tenant.DataUsageType): + Indicates whether data owned by this tenant may be used to + provide product improvements across other tenants. + + Defaults behavior is + [DataUsageType.ISOLATED][google.cloud.talent.v4beta1.Tenant.DataUsageType.ISOLATED] + if it's unset. + keyword_searchable_profile_custom_attributes (Sequence[str]): + A list of keys of filterable + [Profile.custom_attributes][google.cloud.talent.v4beta1.Profile.custom_attributes], + whose corresponding ``string_values`` are used in keyword + searches. Profiles with ``string_values`` under these + specified field keys are returned if any of the values match + the search keyword. Custom field values with parenthesis, + brackets and special symbols are not searchable as-is, and + must be surrounded by quotes. + """ + class DataUsageType(proto.Enum): + r"""Enum that represents how user data owned by the tenant is + used. + """ + DATA_USAGE_TYPE_UNSPECIFIED = 0 + AGGREGATED = 1 + ISOLATED = 2 + + name = proto.Field( + proto.STRING, + number=1, + ) + external_id = proto.Field( + proto.STRING, + number=2, + ) + usage_type = proto.Field( + proto.ENUM, + number=3, + enum=DataUsageType, + ) + keyword_searchable_profile_custom_attributes = proto.RepeatedField( + proto.STRING, + number=4, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant_service.py new file mode 100644 index 00000000..dae84765 --- /dev/null +++ b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant_service.py @@ -0,0 +1,194 @@ +# -*- 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 proto # type: ignore + +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import tenant as gct_tenant +from google.protobuf import field_mask_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.talent.v4beta1', + manifest={ + 'CreateTenantRequest', + 'GetTenantRequest', + 'UpdateTenantRequest', + 'DeleteTenantRequest', + 'ListTenantsRequest', + 'ListTenantsResponse', + }, +) + + +class CreateTenantRequest(proto.Message): + r"""The Request of the CreateTenant method. + + Attributes: + parent (str): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + tenant (google.cloud.talent_v4beta1.types.Tenant): + Required. The tenant to be created. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + tenant = proto.Field( + proto.MESSAGE, + number=2, + message=gct_tenant.Tenant, + ) + + +class GetTenantRequest(proto.Message): + r"""Request for getting a tenant by name. + + Attributes: + name (str): + Required. The resource name of the tenant to be retrieved. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateTenantRequest(proto.Message): + r"""Request for updating a specified tenant. + + Attributes: + tenant (google.cloud.talent_v4beta1.types.Tenant): + Required. The tenant 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.UpdateTenantRequest.update_mask] + is provided, only the specified fields in + [tenant][google.cloud.talent.v4beta1.UpdateTenantRequest.tenant] + are updated. Otherwise all the fields are updated. + + A field mask to specify the tenant fields to be updated. + Only top level fields of + [Tenant][google.cloud.talent.v4beta1.Tenant] are supported. + """ + + tenant = proto.Field( + proto.MESSAGE, + number=1, + message=gct_tenant.Tenant, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteTenantRequest(proto.Message): + r"""Request to delete a tenant. + + Attributes: + name (str): + Required. The resource name of the tenant to be deleted. + + The format is "projects/{project_id}/tenants/{tenant_id}", + for example, "projects/foo/tenants/bar". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListTenantsRequest(proto.Message): + r"""List tenants for which the client has ACL visibility. + + Attributes: + parent (str): + Required. Resource name of the project under which the + tenant is created. + + The format is "projects/{project_id}", for example, + "projects/foo". + page_token (str): + The starting indicator from which to return + results. + page_size (int): + The maximum number of tenants 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 ListTenantsResponse(proto.Message): + r"""The List tenants response object. + + Attributes: + tenants (Sequence[google.cloud.talent_v4beta1.types.Tenant]): + Tenants 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 + + tenants = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_tenant.Tenant, + ) + 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/owl-bot-staging/v4beta1/mypy.ini b/owl-bot-staging/v4beta1/mypy.ini new file mode 100644 index 00000000..574c5aed --- /dev/null +++ b/owl-bot-staging/v4beta1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.7 +namespace_packages = True diff --git a/owl-bot-staging/v4beta1/noxfile.py b/owl-bot-staging/v4beta1/noxfile.py new file mode 100644 index 00000000..46aafa08 --- /dev/null +++ b/owl-bot-staging/v4beta1/noxfile.py @@ -0,0 +1,179 @@ +# -*- 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 +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +ALL_PYTHON = [ + "3.7", + "3.8", + "3.9", + "3.10", +] + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + +BLACK_VERSION = "black==22.3.0" +BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] +DEFAULT_PYTHON_VERSION = "3.10" + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", + "blacken", + "lint", + "lint_setup_py", +] + +@nox.session(python=ALL_PYTHON) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/talent_v4beta1/', + '--cov=tests/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + 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", "erase") + + +@nox.session(python=ALL_PYTHON) +def mypy(session): + """Run the type checker.""" + session.install('mypy', 'types-pkg_resources') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx==4.0.1", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint(session): + """Run linters. + + Returns a failure if the linters find linting errors or sufficiently + serious code quality issues. + """ + session.install("flake8", BLACK_VERSION) + session.run( + "black", + "--check", + *BLACK_PATHS, + ) + session.run("flake8", "google", "tests", "samples") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def blacken(session): + """Run black. Format code to uniform standard.""" + session.install(BLACK_VERSION) + session.run( + "black", + *BLACK_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint_setup_py(session): + """Verify that setup.py is valid (including RST check).""" + session.install("docutils", "pygments") + session.run("python", "setup.py", "check", "--restructuredtext", "--strict") diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py new file mode 100644 index 00000000..beb39636 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py @@ -0,0 +1,57 @@ +# -*- 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 CreateCompany +# 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_CompanyService_CreateCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_create_company(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + company = talent_v4beta1.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4beta1.CreateCompanyRequest( + parent="parent_value", + company=company, + ) + + # Make the request + response = await client.create_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_CompanyService_CreateCompany_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py new file mode 100644 index 00000000..3c09bc1f --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py @@ -0,0 +1,57 @@ +# -*- 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 CreateCompany +# 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_CompanyService_CreateCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_create_company(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + company = talent_v4beta1.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4beta1.CreateCompanyRequest( + parent="parent_value", + company=company, + ) + + # Make the request + response = client.create_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_CompanyService_CreateCompany_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py new file mode 100644 index 00000000..3afbe7d5 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteCompany +# 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_CompanyService_DeleteCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_delete_company(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteCompanyRequest( + name="name_value", + ) + + # Make the request + await client.delete_company(request=request) + + +# [END jobs_v4beta1_generated_CompanyService_DeleteCompany_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py new file mode 100644 index 00000000..efaed012 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteCompany +# 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_CompanyService_DeleteCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_delete_company(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteCompanyRequest( + name="name_value", + ) + + # Make the request + client.delete_company(request=request) + + +# [END jobs_v4beta1_generated_CompanyService_DeleteCompany_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py new file mode 100644 index 00000000..f3c4a42a --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py @@ -0,0 +1,52 @@ +# -*- 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 GetCompany +# 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_CompanyService_GetCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_get_company(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetCompanyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_CompanyService_GetCompany_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py new file mode 100644 index 00000000..e8d8e57d --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py @@ -0,0 +1,52 @@ +# -*- 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 GetCompany +# 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_CompanyService_GetCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_get_company(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetCompanyRequest( + name="name_value", + ) + + # Make the request + response = client.get_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_CompanyService_GetCompany_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py new file mode 100644 index 00000000..4b45b106 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py @@ -0,0 +1,53 @@ +# -*- 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 ListCompanies +# 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_CompanyService_ListCompanies_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_list_companies(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListCompaniesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_companies(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_CompanyService_ListCompanies_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py new file mode 100644 index 00000000..77f31bc4 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py @@ -0,0 +1,53 @@ +# -*- 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 ListCompanies +# 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_CompanyService_ListCompanies_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_list_companies(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListCompaniesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_companies(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_CompanyService_ListCompanies_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py new file mode 100644 index 00000000..cf6bd525 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py @@ -0,0 +1,56 @@ +# -*- 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 UpdateCompany +# 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_CompanyService_UpdateCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_update_company(): + # Create a client + client = talent_v4beta1.CompanyServiceAsyncClient() + + # Initialize request argument(s) + company = talent_v4beta1.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4beta1.UpdateCompanyRequest( + company=company, + ) + + # Make the request + response = await client.update_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_CompanyService_UpdateCompany_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py new file mode 100644 index 00000000..091111cf --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py @@ -0,0 +1,56 @@ +# -*- 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 UpdateCompany +# 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_CompanyService_UpdateCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_update_company(): + # Create a client + client = talent_v4beta1.CompanyServiceClient() + + # Initialize request argument(s) + company = talent_v4beta1.Company() + company.display_name = "display_name_value" + company.external_id = "external_id_value" + + request = talent_v4beta1.UpdateCompanyRequest( + company=company, + ) + + # Make the request + response = client.update_company(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_CompanyService_UpdateCompany_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py new file mode 100644 index 00000000..79699ead --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py @@ -0,0 +1,54 @@ +# -*- 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 CompleteQuery +# 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_Completion_CompleteQuery_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_complete_query(): + # Create a client + client = talent_v4beta1.CompletionAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.CompleteQueryRequest( + parent="parent_value", + query="query_value", + page_size=951, + ) + + # Make the request + response = await client.complete_query(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_Completion_CompleteQuery_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py new file mode 100644 index 00000000..9d46cef2 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py @@ -0,0 +1,54 @@ +# -*- 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 CompleteQuery +# 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_Completion_CompleteQuery_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_complete_query(): + # Create a client + client = talent_v4beta1.CompletionClient() + + # Initialize request argument(s) + request = talent_v4beta1.CompleteQueryRequest( + parent="parent_value", + query="query_value", + page_size=951, + ) + + # Make the request + response = client.complete_query(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_Completion_CompleteQuery_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py new file mode 100644 index 00000000..d6a45c89 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py @@ -0,0 +1,58 @@ +# -*- 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 CreateClientEvent +# 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_EventService_CreateClientEvent_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_create_client_event(): + # Create a client + client = talent_v4beta1.EventServiceAsyncClient() + + # Initialize request argument(s) + client_event = talent_v4beta1.ClientEvent() + client_event.job_event.type_ = "INTERVIEW_GRANTED" + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] + client_event.event_id = "event_id_value" + + request = talent_v4beta1.CreateClientEventRequest( + parent="parent_value", + client_event=client_event, + ) + + # Make the request + response = await client.create_client_event(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_EventService_CreateClientEvent_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py new file mode 100644 index 00000000..15421a47 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py @@ -0,0 +1,58 @@ +# -*- 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 CreateClientEvent +# 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_EventService_CreateClientEvent_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_create_client_event(): + # Create a client + client = talent_v4beta1.EventServiceClient() + + # Initialize request argument(s) + client_event = talent_v4beta1.ClientEvent() + client_event.job_event.type_ = "INTERVIEW_GRANTED" + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] + client_event.event_id = "event_id_value" + + request = talent_v4beta1.CreateClientEventRequest( + parent="parent_value", + client_event=client_event, + ) + + # Make the request + response = client.create_client_event(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_EventService_CreateClientEvent_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py new file mode 100644 index 00000000..6a13b56b --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py @@ -0,0 +1,63 @@ +# -*- 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 BatchCreateJobs +# 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_JobService_BatchCreateJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_batch_create_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + jobs = talent_v4beta1.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4beta1.BatchCreateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_create_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_BatchCreateJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py new file mode 100644 index 00000000..0bd3f5ed --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py @@ -0,0 +1,63 @@ +# -*- 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 BatchCreateJobs +# 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_JobService_BatchCreateJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_batch_create_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + jobs = talent_v4beta1.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4beta1.BatchCreateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_create_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_BatchCreateJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py new file mode 100644 index 00000000..43bcb71e --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py @@ -0,0 +1,51 @@ +# -*- 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 BatchDeleteJobs +# 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_JobService_BatchDeleteJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_batch_delete_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.BatchDeleteJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + await client.batch_delete_jobs(request=request) + + +# [END jobs_v4beta1_generated_JobService_BatchDeleteJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py new file mode 100644 index 00000000..953ac105 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py @@ -0,0 +1,51 @@ +# -*- 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 BatchDeleteJobs +# 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_JobService_BatchDeleteJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_batch_delete_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.BatchDeleteJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + client.batch_delete_jobs(request=request) + + +# [END jobs_v4beta1_generated_JobService_BatchDeleteJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py new file mode 100644 index 00000000..698e644d --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py @@ -0,0 +1,63 @@ +# -*- 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 BatchUpdateJobs +# 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_JobService_BatchUpdateJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_batch_update_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + jobs = talent_v4beta1.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4beta1.BatchUpdateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_update_jobs(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_BatchUpdateJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py new file mode 100644 index 00000000..e80971da --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py @@ -0,0 +1,63 @@ +# -*- 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 BatchUpdateJobs +# 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_JobService_BatchUpdateJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_batch_update_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + jobs = talent_v4beta1.Job() + jobs.company = "company_value" + jobs.requisition_id = "requisition_id_value" + jobs.title = "title_value" + jobs.description = "description_value" + + request = talent_v4beta1.BatchUpdateJobsRequest( + parent="parent_value", + jobs=jobs, + ) + + # Make the request + operation = client.batch_update_jobs(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_BatchUpdateJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py new file mode 100644 index 00000000..7e36a95f --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py @@ -0,0 +1,59 @@ +# -*- 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 CreateJob +# 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_JobService_CreateJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_create_job(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + job = talent_v4beta1.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4beta1.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = await client.create_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_CreateJob_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py new file mode 100644 index 00000000..600d8be9 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py @@ -0,0 +1,59 @@ +# -*- 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 CreateJob +# 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_JobService_CreateJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_create_job(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + job = talent_v4beta1.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4beta1.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = client.create_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_CreateJob_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py new file mode 100644 index 00000000..ad8224b5 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteJob +# 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_JobService_DeleteJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_delete_job(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteJobRequest( + name="name_value", + ) + + # Make the request + await client.delete_job(request=request) + + +# [END jobs_v4beta1_generated_JobService_DeleteJob_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py new file mode 100644 index 00000000..1ef01e19 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteJob +# 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_JobService_DeleteJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_delete_job(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteJobRequest( + name="name_value", + ) + + # Make the request + client.delete_job(request=request) + + +# [END jobs_v4beta1_generated_JobService_DeleteJob_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py new file mode 100644 index 00000000..d9a57ad5 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py @@ -0,0 +1,52 @@ +# -*- 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 GetJob +# 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_JobService_GetJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_get_job(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetJobRequest( + name="name_value", + ) + + # Make the request + response = await client.get_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_GetJob_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py new file mode 100644 index 00000000..4a9bc662 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py @@ -0,0 +1,52 @@ +# -*- 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 GetJob +# 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_JobService_GetJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_get_job(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetJobRequest( + name="name_value", + ) + + # Make the request + response = client.get_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_GetJob_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py new file mode 100644 index 00000000..5ec12499 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py @@ -0,0 +1,54 @@ +# -*- 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 ListJobs +# 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_JobService_ListJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_list_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_JobService_ListJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py new file mode 100644 index 00000000..793a4653 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py @@ -0,0 +1,54 @@ +# -*- 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 ListJobs +# 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_JobService_ListJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_list_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListJobsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_JobService_ListJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py new file mode 100644 index 00000000..9f5a1335 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py @@ -0,0 +1,53 @@ +# -*- 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 SearchJobs +# 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_JobService_SearchJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_search_jobs(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.search_jobs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_JobService_SearchJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py new file mode 100644 index 00000000..eeffc48d --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py @@ -0,0 +1,53 @@ +# -*- 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 SearchJobsForAlert +# 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_JobService_SearchJobsForAlert_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_search_jobs_for_alert(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.search_jobs_for_alert(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_JobService_SearchJobsForAlert_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py new file mode 100644 index 00000000..93c7cd15 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py @@ -0,0 +1,53 @@ +# -*- 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 SearchJobsForAlert +# 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_JobService_SearchJobsForAlert_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_search_jobs_for_alert(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.search_jobs_for_alert(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_JobService_SearchJobsForAlert_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py new file mode 100644 index 00000000..0df23612 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py @@ -0,0 +1,53 @@ +# -*- 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 SearchJobs +# 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_JobService_SearchJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_search_jobs(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.SearchJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.search_jobs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_JobService_SearchJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py new file mode 100644 index 00000000..60555fa8 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py @@ -0,0 +1,58 @@ +# -*- 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 UpdateJob +# 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_JobService_UpdateJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_update_job(): + # Create a client + client = talent_v4beta1.JobServiceAsyncClient() + + # Initialize request argument(s) + job = talent_v4beta1.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4beta1.UpdateJobRequest( + job=job, + ) + + # Make the request + response = await client.update_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_UpdateJob_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py new file mode 100644 index 00000000..8170b2d5 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py @@ -0,0 +1,58 @@ +# -*- 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 UpdateJob +# 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_JobService_UpdateJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_update_job(): + # Create a client + client = talent_v4beta1.JobServiceClient() + + # Initialize request argument(s) + job = talent_v4beta1.Job() + job.company = "company_value" + job.requisition_id = "requisition_id_value" + job.title = "title_value" + job.description = "description_value" + + request = talent_v4beta1.UpdateJobRequest( + job=job, + ) + + # Make the request + response = client.update_job(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_JobService_UpdateJob_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py new file mode 100644 index 00000000..239e5dbd --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py @@ -0,0 +1,56 @@ +# -*- 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 CreateTenant +# 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_TenantService_CreateTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_create_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + tenant = talent_v4beta1.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4beta1.CreateTenantRequest( + parent="parent_value", + tenant=tenant, + ) + + # Make the request + response = await client.create_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_TenantService_CreateTenant_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py new file mode 100644 index 00000000..a8673253 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py @@ -0,0 +1,56 @@ +# -*- 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 CreateTenant +# 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_TenantService_CreateTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_create_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + tenant = talent_v4beta1.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4beta1.CreateTenantRequest( + parent="parent_value", + tenant=tenant, + ) + + # Make the request + response = client.create_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_TenantService_CreateTenant_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py new file mode 100644 index 00000000..3425f2e7 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteTenant +# 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_TenantService_DeleteTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_delete_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteTenantRequest( + name="name_value", + ) + + # Make the request + await client.delete_tenant(request=request) + + +# [END jobs_v4beta1_generated_TenantService_DeleteTenant_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py new file mode 100644 index 00000000..756cb030 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py @@ -0,0 +1,50 @@ +# -*- 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 DeleteTenant +# 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_TenantService_DeleteTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_delete_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.DeleteTenantRequest( + name="name_value", + ) + + # Make the request + client.delete_tenant(request=request) + + +# [END jobs_v4beta1_generated_TenantService_DeleteTenant_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py new file mode 100644 index 00000000..492c8e7d --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py @@ -0,0 +1,52 @@ +# -*- 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 GetTenant +# 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_TenantService_GetTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_get_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetTenantRequest( + name="name_value", + ) + + # Make the request + response = await client.get_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_TenantService_GetTenant_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py new file mode 100644 index 00000000..1bfdfab9 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py @@ -0,0 +1,52 @@ +# -*- 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 GetTenant +# 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_TenantService_GetTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_get_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.GetTenantRequest( + name="name_value", + ) + + # Make the request + response = client.get_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_TenantService_GetTenant_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py new file mode 100644 index 00000000..fc99a810 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py @@ -0,0 +1,53 @@ +# -*- 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 ListTenants +# 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_TenantService_ListTenants_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_list_tenants(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListTenantsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tenants(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_TenantService_ListTenants_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py new file mode 100644 index 00000000..08f8a75c --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py @@ -0,0 +1,53 @@ +# -*- 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 ListTenants +# 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_TenantService_ListTenants_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_list_tenants(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + request = talent_v4beta1.ListTenantsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tenants(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END jobs_v4beta1_generated_TenantService_ListTenants_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py new file mode 100644 index 00000000..7f60e81e --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py @@ -0,0 +1,55 @@ +# -*- 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 UpdateTenant +# 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_TenantService_UpdateTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +async def sample_update_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceAsyncClient() + + # Initialize request argument(s) + tenant = talent_v4beta1.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4beta1.UpdateTenantRequest( + tenant=tenant, + ) + + # Make the request + response = await client.update_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_TenantService_UpdateTenant_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py new file mode 100644 index 00000000..60849278 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py @@ -0,0 +1,55 @@ +# -*- 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 UpdateTenant +# 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_TenantService_UpdateTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import talent_v4beta1 + + +def sample_update_tenant(): + # Create a client + client = talent_v4beta1.TenantServiceClient() + + # Initialize request argument(s) + tenant = talent_v4beta1.Tenant() + tenant.external_id = "external_id_value" + + request = talent_v4beta1.UpdateTenantRequest( + tenant=tenant, + ) + + # Make the request + response = client.update_tenant(request=request) + + # Handle the response + print(response) + +# [END jobs_v4beta1_generated_TenantService_UpdateTenant_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/snippet_metadata_talent_v4beta1.json b/owl-bot-staging/v4beta1/samples/generated_samples/snippet_metadata_talent_v4beta1.json new file mode 100644 index 00000000..5b2bf382 --- /dev/null +++ b/owl-bot-staging/v4beta1/samples/generated_samples/snippet_metadata_talent_v4beta1.json @@ -0,0 +1,3572 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.talent.v4beta1", + "version": "v4beta1" + } + ], + "language": "PYTHON", + "name": "google-cloud-talent" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", + "shortName": "CompanyServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.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_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_CompanyService_CreateCompany_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_company_service_create_company_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", + "shortName": "CompanyServiceClient" + }, + "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": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "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": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "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": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "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": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "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": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "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": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "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": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "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": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "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": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "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": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "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": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "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": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "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": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "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": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "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": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "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": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "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": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "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": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "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": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "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": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "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": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "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": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "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", + "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_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_JobService_DeleteJob_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_delete_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.get_job", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.GetJob", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "GetJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.GetJobRequest" + }, + { + "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.Job", + "shortName": "get_job" + }, + "description": "Sample for GetJob", + "file": "jobs_v4beta1_generated_job_service_get_job_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_JobService_GetJob_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_get_job_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.get_job", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.GetJob", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "GetJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.GetJobRequest" + }, + { + "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.Job", + "shortName": "get_job" + }, + "description": "Sample for GetJob", + "file": "jobs_v4beta1_generated_job_service_get_job_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_JobService_GetJob_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_get_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.list_jobs", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.ListJobs", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "ListJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.ListJobsRequest" + }, + { + "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]" + } + ], + "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsAsyncPager", + "shortName": "list_jobs" + }, + "description": "Sample for ListJobs", + "file": "jobs_v4beta1_generated_job_service_list_jobs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_list_jobs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.list_jobs", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.ListJobs", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "ListJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.ListJobsRequest" + }, + { + "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]" + } + ], + "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsPager", + "shortName": "list_jobs" + }, + "description": "Sample for ListJobs", + "file": "jobs_v4beta1_generated_job_service_list_jobs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_list_jobs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.search_jobs_for_alert", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "SearchJobsForAlert" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" + }, + { + "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.job_service.pagers.SearchJobsForAlertAsyncPager", + "shortName": "search_jobs_for_alert" + }, + "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_JobService_SearchJobsForAlert_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.search_jobs_for_alert", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "SearchJobsForAlert" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" + }, + { + "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.job_service.pagers.SearchJobsForAlertPager", + "shortName": "search_jobs_for_alert" + }, + "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_JobService_SearchJobsForAlert_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.search_jobs", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobs", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "SearchJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" + }, + { + "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.job_service.pagers.SearchJobsAsyncPager", + "shortName": "search_jobs" + }, + "description": "Sample for SearchJobs", + "file": "jobs_v4beta1_generated_job_service_search_jobs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_search_jobs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.search_jobs", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobs", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "SearchJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" + }, + { + "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.job_service.pagers.SearchJobsPager", + "shortName": "search_jobs" + }, + "description": "Sample for SearchJobs", + "file": "jobs_v4beta1_generated_job_service_search_jobs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_search_jobs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", + "shortName": "JobServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.update_job", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.UpdateJob", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "UpdateJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.UpdateJobRequest" + }, + { + "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": "update_job" + }, + "description": "Sample for UpdateJob", + "file": "jobs_v4beta1_generated_job_service_update_job_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_async", + "segments": [ + { + "end": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_update_job_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.JobServiceClient", + "shortName": "JobServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.JobServiceClient.update_job", + "method": { + "fullName": "google.cloud.talent.v4beta1.JobService.UpdateJob", + "service": { + "fullName": "google.cloud.talent.v4beta1.JobService", + "shortName": "JobService" + }, + "shortName": "UpdateJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.UpdateJobRequest" + }, + { + "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": "update_job" + }, + "description": "Sample for UpdateJob", + "file": "jobs_v4beta1_generated_job_service_update_job_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_sync", + "segments": [ + { + "end": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_job_service_update_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.create_tenant", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.CreateTenant", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "CreateTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.CreateTenantRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "tenant", + "type": "google.cloud.talent_v4beta1.types.Tenant" + }, + { + "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.Tenant", + "shortName": "create_tenant" + }, + "description": "Sample for CreateTenant", + "file": "jobs_v4beta1_generated_tenant_service_create_tenant_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_CreateTenant_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_create_tenant_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.create_tenant", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.CreateTenant", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "CreateTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.CreateTenantRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "tenant", + "type": "google.cloud.talent_v4beta1.types.Tenant" + }, + { + "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.Tenant", + "shortName": "create_tenant" + }, + "description": "Sample for CreateTenant", + "file": "jobs_v4beta1_generated_tenant_service_create_tenant_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_CreateTenant_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_create_tenant_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.delete_tenant", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.DeleteTenant", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "DeleteTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.DeleteTenantRequest" + }, + { + "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_tenant" + }, + "description": "Sample for DeleteTenant", + "file": "jobs_v4beta1_generated_tenant_service_delete_tenant_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_DeleteTenant_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_delete_tenant_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.delete_tenant", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.DeleteTenant", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "DeleteTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.DeleteTenantRequest" + }, + { + "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_tenant" + }, + "description": "Sample for DeleteTenant", + "file": "jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_DeleteTenant_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.get_tenant", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.GetTenant", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "GetTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.GetTenantRequest" + }, + { + "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.Tenant", + "shortName": "get_tenant" + }, + "description": "Sample for GetTenant", + "file": "jobs_v4beta1_generated_tenant_service_get_tenant_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_GetTenant_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_get_tenant_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.get_tenant", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.GetTenant", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "GetTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.GetTenantRequest" + }, + { + "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.Tenant", + "shortName": "get_tenant" + }, + "description": "Sample for GetTenant", + "file": "jobs_v4beta1_generated_tenant_service_get_tenant_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_GetTenant_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_get_tenant_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.list_tenants", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.ListTenants", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "ListTenants" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.ListTenantsRequest" + }, + { + "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.tenant_service.pagers.ListTenantsAsyncPager", + "shortName": "list_tenants" + }, + "description": "Sample for ListTenants", + "file": "jobs_v4beta1_generated_tenant_service_list_tenants_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_ListTenants_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_list_tenants_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.list_tenants", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.ListTenants", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "ListTenants" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.ListTenantsRequest" + }, + { + "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.tenant_service.pagers.ListTenantsPager", + "shortName": "list_tenants" + }, + "description": "Sample for ListTenants", + "file": "jobs_v4beta1_generated_tenant_service_list_tenants_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_ListTenants_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_list_tenants_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", + "shortName": "TenantServiceAsyncClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.update_tenant", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.UpdateTenant", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "UpdateTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.UpdateTenantRequest" + }, + { + "name": "tenant", + "type": "google.cloud.talent_v4beta1.types.Tenant" + }, + { + "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.Tenant", + "shortName": "update_tenant" + }, + "description": "Sample for UpdateTenant", + "file": "jobs_v4beta1_generated_tenant_service_update_tenant_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_UpdateTenant_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_update_tenant_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", + "shortName": "TenantServiceClient" + }, + "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.update_tenant", + "method": { + "fullName": "google.cloud.talent.v4beta1.TenantService.UpdateTenant", + "service": { + "fullName": "google.cloud.talent.v4beta1.TenantService", + "shortName": "TenantService" + }, + "shortName": "UpdateTenant" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.talent_v4beta1.types.UpdateTenantRequest" + }, + { + "name": "tenant", + "type": "google.cloud.talent_v4beta1.types.Tenant" + }, + { + "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.Tenant", + "shortName": "update_tenant" + }, + "description": "Sample for UpdateTenant", + "file": "jobs_v4beta1_generated_tenant_service_update_tenant_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "jobs_v4beta1_generated_TenantService_UpdateTenant_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "jobs_v4beta1_generated_tenant_service_update_tenant_sync.py" + } + ] +} diff --git a/owl-bot-staging/v4beta1/scripts/fixup_talent_v4beta1_keywords.py b/owl-bot-staging/v4beta1/scripts/fixup_talent_v4beta1_keywords.py new file mode 100644 index 00000000..3058f60b --- /dev/null +++ b/owl-bot-staging/v4beta1/scripts/fixup_talent_v4beta1_keywords.py @@ -0,0 +1,197 @@ +#! /usr/bin/env python3 +# -*- 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 argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class talentCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'batch_create_jobs': ('parent', 'jobs', ), + 'batch_delete_jobs': ('parent', 'filter', ), + 'batch_update_jobs': ('parent', 'jobs', 'update_mask', ), + 'complete_query': ('parent', 'query', 'page_size', 'language_codes', 'company', 'scope', 'type_', ), + 'create_client_event': ('parent', 'client_event', ), + 'create_company': ('parent', 'company', ), + 'create_job': ('parent', 'job', ), + 'create_tenant': ('parent', 'tenant', ), + 'delete_company': ('name', ), + 'delete_job': ('name', ), + 'delete_tenant': ('name', ), + 'get_company': ('name', ), + 'get_job': ('name', ), + 'get_tenant': ('name', ), + 'list_companies': ('parent', 'page_token', 'page_size', 'require_open_jobs', ), + 'list_jobs': ('parent', 'filter', 'page_token', 'page_size', 'job_view', ), + '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', '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_tenant': ('tenant', 'update_mask', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=talentCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the talent client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v4beta1/setup.py b/owl-bot-staging/v4beta1/setup.py new file mode 100644 index 00000000..ddcd0c82 --- /dev/null +++ b/owl-bot-staging/v4beta1/setup.py @@ -0,0 +1,58 @@ +# -*- 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 io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-cloud-talent', + author="Google LLC", + author_email="googleapis-packages@google.com", + url="https://github.com/googleapis/python-google-cloud-talent", + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 2.10.0, < 3.0.0dev', + 'libcst >= 0.2.5', + 'googleapis-common-protos >= 1.55.0, <2.0.0dev', + 'proto-plus >= 1.19.7', + ), + python_requires='>=3.7', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v4beta1/tests/__init__.py b/owl-bot-staging/v4beta1/tests/__init__.py new file mode 100644 index 00000000..231bc125 --- /dev/null +++ b/owl-bot-staging/v4beta1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/v4beta1/tests/unit/__init__.py b/owl-bot-staging/v4beta1/tests/unit/__init__.py new file mode 100644 index 00000000..231bc125 --- /dev/null +++ b/owl-bot-staging/v4beta1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/__init__.py b/owl-bot-staging/v4beta1/tests/unit/gapic/__init__.py new file mode 100644 index 00000000..231bc125 --- /dev/null +++ b/owl-bot-staging/v4beta1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/__init__.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/__init__.py new file mode 100644 index 00000000..231bc125 --- /dev/null +++ b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_company_service.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_company_service.py new file mode 100644 index 00000000..9e8ecd15 --- /dev/null +++ b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_company_service.py @@ -0,0 +1,2789 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4beta1.services.company_service import CompanyServiceAsyncClient +from google.cloud.talent_v4beta1.services.company_service import CompanyServiceClient +from google.cloud.talent_v4beta1.services.company_service import pagers +from google.cloud.talent_v4beta1.services.company_service import transports +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import company +from google.cloud.talent_v4beta1.types import company as gct_company +from google.cloud.talent_v4beta1.types import company_service +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 +from google.type import postal_address_pb2 # type: ignore +import google.auth + + +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 CompanyServiceClient._get_default_mtls_endpoint(None) is None + assert CompanyServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert CompanyServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert CompanyServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert CompanyServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert CompanyServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (CompanyServiceClient, "grpc"), + (CompanyServiceAsyncClient, "grpc_asyncio"), +]) +def test_company_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.CompanyServiceGrpcTransport, "grpc"), + (transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_company_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", [ + (CompanyServiceClient, "grpc"), + (CompanyServiceAsyncClient, "grpc_asyncio"), +]) +def test_company_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_company_service_client_get_transport_class(): + transport = CompanyServiceClient.get_transport_class() + available_transports = [ + transports.CompanyServiceGrpcTransport, + ] + assert transport in available_transports + + transport = CompanyServiceClient.get_transport_class("grpc") + assert transport == transports.CompanyServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc"), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) +@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) +def test_company_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(CompanyServiceClient, '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(CompanyServiceClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", "true"), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", "false"), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) +@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_company_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + CompanyServiceClient, CompanyServiceAsyncClient +]) +@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) +@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) +def test_company_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", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc"), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_company_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", grpc_helpers), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_company_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, + api_audience=None, + ) + +def test_company_service_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4beta1.services.company_service.transports.CompanyServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = CompanyServiceClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", grpc_helpers), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_company_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, + api_audience=None, + ) + + # 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", [ + company_service.CreateCompanyRequest, + dict, +]) +def test_create_company(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + ) + response = client.create_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.CreateCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +def test_create_company_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 = CompanyServiceClient( + 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_company), + '__call__') as call: + client.create_company() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.CreateCompanyRequest() + +@pytest.mark.asyncio +async def test_create_company_async(transport: str = 'grpc_asyncio', request_type=company_service.CreateCompanyRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + )) + response = await client.create_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.CreateCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +@pytest.mark.asyncio +async def test_create_company_async_from_dict(): + await test_create_company_async(request_type=dict) + + +def test_create_company_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 = company_service.CreateCompanyRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_company), + '__call__') as call: + call.return_value = gct_company.Company() + client.create_company(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_company_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 = company_service.CreateCompanyRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_company), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) + await client.create_company(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_company_flattened(): + 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.create_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_company( + parent='parent_value', + company=gct_company.Company(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].company + mock_val = gct_company.Company(name='name_value') + assert arg == mock_val + + +def test_create_company_flattened_error(): + client = CompanyServiceClient( + 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_company( + company_service.CreateCompanyRequest(), + parent='parent_value', + company=gct_company.Company(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_company_flattened_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.create_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_company( + parent='parent_value', + company=gct_company.Company(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].company + mock_val = gct_company.Company(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_company_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_company( + company_service.CreateCompanyRequest(), + parent='parent_value', + company=gct_company.Company(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + company_service.GetCompanyRequest, + dict, +]) +def test_get_company(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + ) + response = client.get_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.GetCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +def test_get_company_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 = CompanyServiceClient( + 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_company), + '__call__') as call: + client.get_company() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.GetCompanyRequest() + +@pytest.mark.asyncio +async def test_get_company_async(transport: str = 'grpc_asyncio', request_type=company_service.GetCompanyRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + )) + response = await client.get_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.GetCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +@pytest.mark.asyncio +async def test_get_company_async_from_dict(): + await test_get_company_async(request_type=dict) + + +def test_get_company_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 = company_service.GetCompanyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_company), + '__call__') as call: + call.return_value = company.Company() + client.get_company(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_company_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 = company_service.GetCompanyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_company), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) + await client.get_company(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_company_flattened(): + 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_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company.Company() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_company( + 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_company_flattened_error(): + client = CompanyServiceClient( + 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_company( + company_service.GetCompanyRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_company_flattened_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_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company.Company() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_company( + 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_company_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_company( + company_service.GetCompanyRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + company_service.UpdateCompanyRequest, + dict, +]) +def test_update_company(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + ) + response = client.update_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.UpdateCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +def test_update_company_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 = CompanyServiceClient( + 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_company), + '__call__') as call: + client.update_company() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.UpdateCompanyRequest() + +@pytest.mark.asyncio +async def test_update_company_async(transport: str = 'grpc_asyncio', request_type=company_service.UpdateCompanyRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company( + name='name_value', + display_name='display_name_value', + external_id='external_id_value', + size=common.CompanySize.MINI, + headquarters_address='headquarters_address_value', + hiring_agency=True, + eeo_text='eeo_text_value', + website_uri='website_uri_value', + career_site_uri='career_site_uri_value', + image_uri='image_uri_value', + keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], + suspended=True, + )) + response = await client.update_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.UpdateCompanyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.external_id == 'external_id_value' + assert response.size == common.CompanySize.MINI + assert response.headquarters_address == 'headquarters_address_value' + assert response.hiring_agency is True + assert response.eeo_text == 'eeo_text_value' + assert response.website_uri == 'website_uri_value' + assert response.career_site_uri == 'career_site_uri_value' + assert response.image_uri == 'image_uri_value' + assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] + assert response.suspended is True + + +@pytest.mark.asyncio +async def test_update_company_async_from_dict(): + await test_update_company_async(request_type=dict) + + +def test_update_company_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 = company_service.UpdateCompanyRequest() + + request.company.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_company), + '__call__') as call: + call.return_value = gct_company.Company() + client.update_company(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', + 'company.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_company_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 = company_service.UpdateCompanyRequest() + + request.company.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_company), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) + await client.update_company(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', + 'company.name=name_value', + ) in kw['metadata'] + + +def test_update_company_flattened(): + 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.update_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_company( + company=gct_company.Company(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].company + mock_val = gct_company.Company(name='name_value') + assert arg == mock_val + + +def test_update_company_flattened_error(): + client = CompanyServiceClient( + 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_company( + company_service.UpdateCompanyRequest(), + company=gct_company.Company(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_update_company_flattened_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.update_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_company.Company() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_company( + company=gct_company.Company(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].company + mock_val = gct_company.Company(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_company_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_company( + company_service.UpdateCompanyRequest(), + company=gct_company.Company(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + company_service.DeleteCompanyRequest, + dict, +]) +def test_delete_company(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.DeleteCompanyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_company_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 = CompanyServiceClient( + 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_company), + '__call__') as call: + client.delete_company() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.DeleteCompanyRequest() + +@pytest.mark.asyncio +async def test_delete_company_async(transport: str = 'grpc_asyncio', request_type=company_service.DeleteCompanyRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_company), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_company(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.DeleteCompanyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_company_async_from_dict(): + await test_delete_company_async(request_type=dict) + + +def test_delete_company_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 = company_service.DeleteCompanyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_company), + '__call__') as call: + call.return_value = None + client.delete_company(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_company_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 = company_service.DeleteCompanyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_company), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_company(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_company_flattened(): + 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.delete_company), + '__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_company( + 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_company_flattened_error(): + client = CompanyServiceClient( + 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_company( + company_service.DeleteCompanyRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_company_flattened_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.delete_company), + '__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_company( + 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_company_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_company( + company_service.DeleteCompanyRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + company_service.ListCompaniesRequest, + dict, +]) +def test_list_companies(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_companies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company_service.ListCompaniesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_companies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.ListCompaniesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCompaniesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_companies_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 = CompanyServiceClient( + 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_companies), + '__call__') as call: + client.list_companies() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.ListCompaniesRequest() + +@pytest.mark.asyncio +async def test_list_companies_async(transport: str = 'grpc_asyncio', request_type=company_service.ListCompaniesRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_companies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_companies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == company_service.ListCompaniesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCompaniesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_companies_async_from_dict(): + await test_list_companies_async(request_type=dict) + + +def test_list_companies_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 = company_service.ListCompaniesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_companies), + '__call__') as call: + call.return_value = company_service.ListCompaniesResponse() + client.list_companies(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_companies_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 = company_service.ListCompaniesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_companies), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse()) + await client.list_companies(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_companies_flattened(): + 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.list_companies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company_service.ListCompaniesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_companies( + 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_companies_flattened_error(): + client = CompanyServiceClient( + 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_companies( + company_service.ListCompaniesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_companies_flattened_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.list_companies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = company_service.ListCompaniesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_companies( + 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_companies_flattened_error_async(): + client = CompanyServiceAsyncClient( + 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_companies( + company_service.ListCompaniesRequest(), + parent='parent_value', + ) + + +def test_list_companies_pager(transport_name: str = "grpc"): + client = CompanyServiceClient( + 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_companies), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + company.Company(), + ], + next_page_token='abc', + ), + company_service.ListCompaniesResponse( + companies=[], + next_page_token='def', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + ], + next_page_token='ghi', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_companies(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, company.Company) + for i in results) +def test_list_companies_pages(transport_name: str = "grpc"): + client = CompanyServiceClient( + 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_companies), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + company.Company(), + ], + next_page_token='abc', + ), + company_service.ListCompaniesResponse( + companies=[], + next_page_token='def', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + ], + next_page_token='ghi', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + ], + ), + RuntimeError, + ) + pages = list(client.list_companies(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_companies_async_pager(): + 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.list_companies), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + company.Company(), + ], + next_page_token='abc', + ), + company_service.ListCompaniesResponse( + companies=[], + next_page_token='def', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + ], + next_page_token='ghi', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_companies(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, company.Company) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_companies_async_pages(): + 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.list_companies), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + company.Company(), + ], + next_page_token='abc', + ), + company_service.ListCompaniesResponse( + companies=[], + next_page_token='def', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + ], + next_page_token='ghi', + ), + company_service.ListCompaniesResponse( + companies=[ + company.Company(), + company.Company(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_companies(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.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompanyServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompanyServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CompanyServiceClient( + 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 = CompanyServiceClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompanyServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = CompanyServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.CompanyServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.CompanyServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.CompanyServiceGrpcTransport, + transports.CompanyServiceGrpcAsyncIOTransport, +]) +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 = CompanyServiceClient.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 = CompanyServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CompanyServiceGrpcTransport, + ) + +def test_company_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.CompanyServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_company_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4beta1.services.company_service.transports.CompanyServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.CompanyServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_company', + 'get_company', + 'update_company', + 'delete_company', + 'list_companies', + 'get_operation', + ) + 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_company_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.company_service.transports.CompanyServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CompanyServiceTransport( + 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_company_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.company_service.transports.CompanyServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CompanyServiceTransport() + adc.assert_called_once() + + +def test_company_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) + CompanyServiceClient() + 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.CompanyServiceGrpcTransport, + transports.CompanyServiceGrpcAsyncIOTransport, + ], +) +def test_company_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", + [ + 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", + [ + (transports.CompanyServiceGrpcTransport, grpc_helpers), + (transports.CompanyServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_company_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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) +def test_company_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_company_service_host_no_port(transport_name): + client = CompanyServiceClient( + 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_company_service_host_with_port(transport_name): + client = CompanyServiceClient( + 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_company_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CompanyServiceGrpcTransport( + 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_company_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CompanyServiceGrpcAsyncIOTransport( + 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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) +def test_company_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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) +def test_company_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_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) + actual = CompanyServiceClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = CompanyServiceClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_company_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = CompanyServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = CompanyServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "winkle" + expected = "folders/{folder}".format(folder=folder, ) + actual = CompanyServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = CompanyServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "scallop" + expected = "organizations/{organization}".format(organization=organization, ) + actual = CompanyServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = CompanyServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "squid" + expected = "projects/{project}".format(project=project, ) + actual = CompanyServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = CompanyServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "whelk" + location = "octopus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = CompanyServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = CompanyServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.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.CompanyServiceTransport, '_prep_wrapped_messages') as prep: + client = CompanyServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.CompanyServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = CompanyServiceClient.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 = CompanyServiceAsyncClient( + 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_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_async(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", + } + + for transport, close_name in transports.items(): + client = CompanyServiceClient( + 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 = CompanyServiceClient( + 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", [ + (CompanyServiceClient, transports.CompanyServiceGrpcTransport), + (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_completion.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_completion.py new file mode 100644 index 00000000..a6d8a976 --- /dev/null +++ b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_completion.py @@ -0,0 +1,1440 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4beta1.services.completion import CompletionAsyncClient +from google.cloud.talent_v4beta1.services.completion import CompletionClient +from google.cloud.talent_v4beta1.services.completion import transports +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import completion_service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +import google.auth + + +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 CompletionClient._get_default_mtls_endpoint(None) is None + assert CompletionClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert CompletionClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert CompletionClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert CompletionClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert CompletionClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (CompletionClient, "grpc"), + (CompletionAsyncClient, "grpc_asyncio"), +]) +def test_completion_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.CompletionGrpcTransport, "grpc"), + (transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_completion_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", [ + (CompletionClient, "grpc"), + (CompletionAsyncClient, "grpc_asyncio"), +]) +def test_completion_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_completion_client_get_transport_class(): + transport = CompletionClient.get_transport_class() + available_transports = [ + transports.CompletionGrpcTransport, + ] + assert transport in available_transports + + transport = CompletionClient.get_transport_class("grpc") + assert transport == transports.CompletionGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc"), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) +@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) +def test_completion_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(CompletionClient, '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(CompletionClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc", "true"), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (CompletionClient, transports.CompletionGrpcTransport, "grpc", "false"), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) +@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_completion_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + CompletionClient, CompletionAsyncClient +]) +@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) +@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) +def test_completion_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", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc"), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_completion_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc", grpc_helpers), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_completion_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, + api_audience=None, + ) + +def test_completion_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4beta1.services.completion.transports.CompletionGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = CompletionClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CompletionClient, transports.CompletionGrpcTransport, "grpc", grpc_helpers), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_completion_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, + api_audience=None, + ) + + # 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", [ + completion_service.CompleteQueryRequest, + dict, +]) +def test_complete_query(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.complete_query), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = completion_service.CompleteQueryResponse( + ) + response = client.complete_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == completion_service.CompleteQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, completion_service.CompleteQueryResponse) + + +def test_complete_query_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 = CompletionClient( + 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.complete_query), + '__call__') as call: + client.complete_query() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == completion_service.CompleteQueryRequest() + +@pytest.mark.asyncio +async def test_complete_query_async(transport: str = 'grpc_asyncio', request_type=completion_service.CompleteQueryRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.complete_query), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(completion_service.CompleteQueryResponse( + )) + response = await client.complete_query(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == completion_service.CompleteQueryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, completion_service.CompleteQueryResponse) + + +@pytest.mark.asyncio +async def test_complete_query_async_from_dict(): + await test_complete_query_async(request_type=dict) + + +def test_complete_query_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 = completion_service.CompleteQueryRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.complete_query), + '__call__') as call: + call.return_value = completion_service.CompleteQueryResponse() + client.complete_query(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_complete_query_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 = completion_service.CompleteQueryRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.complete_query), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(completion_service.CompleteQueryResponse()) + await client.complete_query(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_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompletionClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompletionClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CompletionClient( + 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 = CompletionClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CompletionClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = CompletionClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.CompletionGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.CompletionGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.CompletionGrpcTransport, + transports.CompletionGrpcAsyncIOTransport, +]) +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 = CompletionClient.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 = CompletionClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CompletionGrpcTransport, + ) + +def test_completion_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.CompletionTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_completion_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4beta1.services.completion.transports.CompletionTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.CompletionTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'complete_query', + 'get_operation', + ) + 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_completion_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.completion.transports.CompletionTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CompletionTransport( + 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_completion_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.completion.transports.CompletionTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CompletionTransport() + adc.assert_called_once() + + +def test_completion_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) + CompletionClient() + 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.CompletionGrpcTransport, + transports.CompletionGrpcAsyncIOTransport, + ], +) +def test_completion_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", + [ + 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", + [ + (transports.CompletionGrpcTransport, grpc_helpers), + (transports.CompletionGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_completion_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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) +def test_completion_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_completion_host_no_port(transport_name): + client = CompletionClient( + 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_completion_host_with_port(transport_name): + client = CompletionClient( + 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_completion_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CompletionGrpcTransport( + 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_completion_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CompletionGrpcAsyncIOTransport( + 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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) +def test_completion_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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) +def test_completion_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_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) + actual = CompletionClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = CompletionClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_company_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = CompletionClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = CompletionClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "winkle" + expected = "folders/{folder}".format(folder=folder, ) + actual = CompletionClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = CompletionClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "scallop" + expected = "organizations/{organization}".format(organization=organization, ) + actual = CompletionClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = CompletionClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "squid" + expected = "projects/{project}".format(project=project, ) + actual = CompletionClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = CompletionClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "whelk" + location = "octopus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = CompletionClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = CompletionClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.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.CompletionTransport, '_prep_wrapped_messages') as prep: + client = CompletionClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.CompletionTransport, '_prep_wrapped_messages') as prep: + transport_class = CompletionClient.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 = CompletionAsyncClient( + 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_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_async(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", + } + + for transport, close_name in transports.items(): + client = CompletionClient( + 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 = CompletionClient( + 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", [ + (CompletionClient, transports.CompletionGrpcTransport), + (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_event_service.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_event_service.py new file mode 100644 index 00000000..72e9251b --- /dev/null +++ b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_event_service.py @@ -0,0 +1,1546 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4beta1.services.event_service import EventServiceAsyncClient +from google.cloud.talent_v4beta1.services.event_service import EventServiceClient +from google.cloud.talent_v4beta1.services.event_service import transports +from google.cloud.talent_v4beta1.types import event +from google.cloud.talent_v4beta1.types import event_service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +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 EventServiceClient._get_default_mtls_endpoint(None) is None + assert EventServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert EventServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert EventServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert EventServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert EventServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (EventServiceClient, "grpc"), + (EventServiceAsyncClient, "grpc_asyncio"), +]) +def test_event_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.EventServiceGrpcTransport, "grpc"), + (transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_event_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", [ + (EventServiceClient, "grpc"), + (EventServiceAsyncClient, "grpc_asyncio"), +]) +def test_event_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_event_service_client_get_transport_class(): + transport = EventServiceClient.get_transport_class() + available_transports = [ + transports.EventServiceGrpcTransport, + ] + assert transport in available_transports + + transport = EventServiceClient.get_transport_class("grpc") + assert transport == transports.EventServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc"), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) +@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) +def test_event_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(EventServiceClient, '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(EventServiceClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", "true"), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", "false"), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) +@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_event_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + EventServiceClient, EventServiceAsyncClient +]) +@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) +@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) +def test_event_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", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc"), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_event_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", grpc_helpers), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_event_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, + api_audience=None, + ) + +def test_event_service_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4beta1.services.event_service.transports.EventServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = EventServiceClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", grpc_helpers), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_event_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, + api_audience=None, + ) + + # 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", [ + event_service.CreateClientEventRequest, + dict, +]) +def test_create_client_event(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_client_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = event.ClientEvent( + request_id='request_id_value', + event_id='event_id_value', + event_notes='event_notes_value', + job_event=event.JobEvent(type_=event.JobEvent.JobEventType.IMPRESSION), + ) + response = client.create_client_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == event_service.CreateClientEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event.ClientEvent) + assert response.request_id == 'request_id_value' + assert response.event_id == 'event_id_value' + assert response.event_notes == 'event_notes_value' + + +def test_create_client_event_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 = EventServiceClient( + 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_client_event), + '__call__') as call: + client.create_client_event() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == event_service.CreateClientEventRequest() + +@pytest.mark.asyncio +async def test_create_client_event_async(transport: str = 'grpc_asyncio', request_type=event_service.CreateClientEventRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_client_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent( + request_id='request_id_value', + event_id='event_id_value', + event_notes='event_notes_value', + )) + response = await client.create_client_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == event_service.CreateClientEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event.ClientEvent) + assert response.request_id == 'request_id_value' + assert response.event_id == 'event_id_value' + assert response.event_notes == 'event_notes_value' + + +@pytest.mark.asyncio +async def test_create_client_event_async_from_dict(): + await test_create_client_event_async(request_type=dict) + + +def test_create_client_event_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 = event_service.CreateClientEventRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_client_event), + '__call__') as call: + call.return_value = event.ClientEvent() + client.create_client_event(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_client_event_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 = event_service.CreateClientEventRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_client_event), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) + await client.create_client_event(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_client_event_flattened(): + 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.create_client_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = event.ClientEvent() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_client_event( + parent='parent_value', + client_event=event.ClientEvent(request_id='request_id_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].client_event + mock_val = event.ClientEvent(request_id='request_id_value') + assert arg == mock_val + + +def test_create_client_event_flattened_error(): + client = EventServiceClient( + 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_client_event( + event_service.CreateClientEventRequest(), + parent='parent_value', + client_event=event.ClientEvent(request_id='request_id_value'), + ) + +@pytest.mark.asyncio +async def test_create_client_event_flattened_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.create_client_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = event.ClientEvent() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_client_event( + parent='parent_value', + client_event=event.ClientEvent(request_id='request_id_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].client_event + mock_val = event.ClientEvent(request_id='request_id_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_client_event_flattened_error_async(): + client = EventServiceAsyncClient( + 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_client_event( + event_service.CreateClientEventRequest(), + parent='parent_value', + client_event=event.ClientEvent(request_id='request_id_value'), + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = EventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = EventServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EventServiceClient( + 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 = EventServiceClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = EventServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = EventServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.EventServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.EventServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.EventServiceGrpcTransport, + transports.EventServiceGrpcAsyncIOTransport, +]) +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 = EventServiceClient.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 = EventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.EventServiceGrpcTransport, + ) + +def test_event_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.EventServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_event_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4beta1.services.event_service.transports.EventServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.EventServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_client_event', + 'get_operation', + ) + 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_event_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.event_service.transports.EventServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.EventServiceTransport( + 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_event_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.event_service.transports.EventServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.EventServiceTransport() + adc.assert_called_once() + + +def test_event_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) + EventServiceClient() + 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.EventServiceGrpcTransport, + transports.EventServiceGrpcAsyncIOTransport, + ], +) +def test_event_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", + [ + 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", + [ + (transports.EventServiceGrpcTransport, grpc_helpers), + (transports.EventServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_event_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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) +def test_event_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_event_service_host_no_port(transport_name): + client = EventServiceClient( + 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_event_service_host_with_port(transport_name): + client = EventServiceClient( + 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_event_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.EventServiceGrpcTransport( + 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_event_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.EventServiceGrpcAsyncIOTransport( + 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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) +def test_event_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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) +def test_event_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_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) + actual = EventServiceClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = EventServiceClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_company_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = EventServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = EventServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "winkle" + expected = "folders/{folder}".format(folder=folder, ) + actual = EventServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = EventServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "scallop" + expected = "organizations/{organization}".format(organization=organization, ) + actual = EventServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = EventServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "squid" + expected = "projects/{project}".format(project=project, ) + actual = EventServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = EventServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "whelk" + location = "octopus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = EventServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = EventServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.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.EventServiceTransport, '_prep_wrapped_messages') as prep: + client = EventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.EventServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = EventServiceClient.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 = EventServiceAsyncClient( + 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_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_async(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", + } + + for transport, close_name in transports.items(): + client = EventServiceClient( + 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 = EventServiceClient( + 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", [ + (EventServiceClient, transports.EventServiceGrpcTransport), + (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_job_service.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_job_service.py new file mode 100644 index 00000000..505bdff3 --- /dev/null +++ b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_job_service.py @@ -0,0 +1,4375 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import operation +from google.api_core import operation_async # type: ignore +from google.api_core import operations_v1 +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4beta1.services.job_service import JobServiceAsyncClient +from google.cloud.talent_v4beta1.services.job_service import JobServiceClient +from google.cloud.talent_v4beta1.services.job_service import pagers +from google.cloud.talent_v4beta1.services.job_service import transports +from google.cloud.talent_v4beta1.types import common +from google.cloud.talent_v4beta1.types import filters +from google.cloud.talent_v4beta1.types import histogram +from google.cloud.talent_v4beta1.types import job +from google.cloud.talent_v4beta1.types import job as gct_job +from google.cloud.talent_v4beta1.types import job_service +from google.longrunning import operations_pb2 +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 latlng_pb2 # type: ignore +from google.type import money_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore +from google.type import timeofday_pb2 # type: ignore +import google.auth + + +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 JobServiceClient._get_default_mtls_endpoint(None) is None + assert JobServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert JobServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert JobServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert JobServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert JobServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (JobServiceClient, "grpc"), + (JobServiceAsyncClient, "grpc_asyncio"), +]) +def test_job_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.JobServiceGrpcTransport, "grpc"), + (transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_job_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", [ + (JobServiceClient, "grpc"), + (JobServiceAsyncClient, "grpc_asyncio"), +]) +def test_job_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_job_service_client_get_transport_class(): + transport = JobServiceClient.get_transport_class() + available_transports = [ + transports.JobServiceGrpcTransport, + ] + assert transport in available_transports + + transport = JobServiceClient.get_transport_class("grpc") + assert transport == transports.JobServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc"), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) +@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) +def test_job_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(JobServiceClient, '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(JobServiceClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", "true"), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", "false"), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) +@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_job_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + JobServiceClient, JobServiceAsyncClient +]) +@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) +@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) +def test_job_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", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc"), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_job_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", grpc_helpers), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_job_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, + api_audience=None, + ) + +def test_job_service_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4beta1.services.job_service.transports.JobServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = JobServiceClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", grpc_helpers), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_job_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, + api_audience=None, + ) + + # 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", [ + job_service.CreateJobRequest, + dict, +]) +def test_create_job(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + ) + response = client.create_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.CreateJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +def test_create_job_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 = JobServiceClient( + 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_job), + '__call__') as call: + client.create_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.CreateJobRequest() + +@pytest.mark.asyncio +async def test_create_job_async(transport: str = 'grpc_asyncio', request_type=job_service.CreateJobRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + )) + response = await client.create_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.CreateJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +@pytest.mark.asyncio +async def test_create_job_async_from_dict(): + await test_create_job_async(request_type=dict) + + +def test_create_job_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 = job_service.CreateJobRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_job), + '__call__') as call: + call.return_value = gct_job.Job() + client.create_job(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_job_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 = job_service.CreateJobRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_job), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) + await client.create_job(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_job_flattened(): + 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.create_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_job( + parent='parent_value', + job=gct_job.Job(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].job + mock_val = gct_job.Job(name='name_value') + assert arg == mock_val + + +def test_create_job_flattened_error(): + client = JobServiceClient( + 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_job( + job_service.CreateJobRequest(), + parent='parent_value', + job=gct_job.Job(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_job_flattened_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.create_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_job( + parent='parent_value', + job=gct_job.Job(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].job + mock_val = gct_job.Job(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_job_flattened_error_async(): + client = JobServiceAsyncClient( + 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_job( + job_service.CreateJobRequest(), + parent='parent_value', + job=gct_job.Job(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.BatchCreateJobsRequest, + dict, +]) +def test_batch_create_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.batch_create_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchCreateJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_batch_create_jobs_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 = JobServiceClient( + 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.batch_create_jobs), + '__call__') as call: + client.batch_create_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchCreateJobsRequest() + +@pytest.mark.asyncio +async def test_batch_create_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchCreateJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.batch_create_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchCreateJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_batch_create_jobs_async_from_dict(): + await test_batch_create_jobs_async(request_type=dict) + + +def test_batch_create_jobs_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 = job_service.BatchCreateJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_jobs), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.batch_create_jobs(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_batch_create_jobs_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 = job_service.BatchCreateJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.batch_create_jobs(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_batch_create_jobs_flattened(): + 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.batch_create_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.batch_create_jobs( + parent='parent_value', + jobs=[job.Job(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].jobs + mock_val = [job.Job(name='name_value')] + assert arg == mock_val + + +def test_batch_create_jobs_flattened_error(): + client = JobServiceClient( + 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.batch_create_jobs( + job_service.BatchCreateJobsRequest(), + parent='parent_value', + jobs=[job.Job(name='name_value')], + ) + +@pytest.mark.asyncio +async def test_batch_create_jobs_flattened_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.batch_create_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.batch_create_jobs( + parent='parent_value', + jobs=[job.Job(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].jobs + mock_val = [job.Job(name='name_value')] + assert arg == mock_val + +@pytest.mark.asyncio +async def test_batch_create_jobs_flattened_error_async(): + client = JobServiceAsyncClient( + 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.batch_create_jobs( + job_service.BatchCreateJobsRequest(), + parent='parent_value', + jobs=[job.Job(name='name_value')], + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.GetJobRequest, + dict, +]) +def test_get_job(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + ) + response = client.get_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.GetJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +def test_get_job_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 = JobServiceClient( + 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_job), + '__call__') as call: + client.get_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.GetJobRequest() + +@pytest.mark.asyncio +async def test_get_job_async(transport: str = 'grpc_asyncio', request_type=job_service.GetJobRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + )) + response = await client.get_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.GetJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +@pytest.mark.asyncio +async def test_get_job_async_from_dict(): + await test_get_job_async(request_type=dict) + + +def test_get_job_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 = job_service.GetJobRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_job), + '__call__') as call: + call.return_value = job.Job() + client.get_job(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_job_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 = job_service.GetJobRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_job), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) + await client.get_job(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_job_flattened(): + 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_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job.Job() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_job( + 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_job_flattened_error(): + client = JobServiceClient( + 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_job( + job_service.GetJobRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_job_flattened_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_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job.Job() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_job( + 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_job_flattened_error_async(): + client = JobServiceAsyncClient( + 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_job( + job_service.GetJobRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.UpdateJobRequest, + dict, +]) +def test_update_job(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + ) + response = client.update_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.UpdateJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +def test_update_job_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 = JobServiceClient( + 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_job), + '__call__') as call: + client.update_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.UpdateJobRequest() + +@pytest.mark.asyncio +async def test_update_job_async(transport: str = 'grpc_asyncio', request_type=job_service.UpdateJobRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job( + name='name_value', + company='company_value', + requisition_id='requisition_id_value', + title='title_value', + description='description_value', + addresses=['addresses_value'], + job_benefits=[common.JobBenefit.CHILD_CARE], + degree_types=[common.DegreeType.PRIMARY_EDUCATION], + department='department_value', + employment_types=[common.EmploymentType.FULL_TIME], + incentives='incentives_value', + language_code='language_code_value', + job_level=common.JobLevel.ENTRY_LEVEL, + promotion_value=1635, + qualifications='qualifications_value', + responsibilities='responsibilities_value', + posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, + visibility=common.Visibility.ACCOUNT_ONLY, + company_display_name='company_display_name_value', + )) + response = await client.update_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.UpdateJobRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) + assert response.name == 'name_value' + assert response.company == 'company_value' + assert response.requisition_id == 'requisition_id_value' + assert response.title == 'title_value' + assert response.description == 'description_value' + assert response.addresses == ['addresses_value'] + assert response.job_benefits == [common.JobBenefit.CHILD_CARE] + assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] + assert response.department == 'department_value' + assert response.employment_types == [common.EmploymentType.FULL_TIME] + assert response.incentives == 'incentives_value' + assert response.language_code == 'language_code_value' + assert response.job_level == common.JobLevel.ENTRY_LEVEL + assert response.promotion_value == 1635 + assert response.qualifications == 'qualifications_value' + assert response.responsibilities == 'responsibilities_value' + assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA + assert response.visibility == common.Visibility.ACCOUNT_ONLY + assert response.company_display_name == 'company_display_name_value' + + +@pytest.mark.asyncio +async def test_update_job_async_from_dict(): + await test_update_job_async(request_type=dict) + + +def test_update_job_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 = job_service.UpdateJobRequest() + + request.job.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_job), + '__call__') as call: + call.return_value = gct_job.Job() + client.update_job(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', + 'job.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_job_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 = job_service.UpdateJobRequest() + + request.job.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_job), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) + await client.update_job(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', + 'job.name=name_value', + ) in kw['metadata'] + + +def test_update_job_flattened(): + 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.update_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_job( + job=gct_job.Job(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].job + mock_val = gct_job.Job(name='name_value') + assert arg == mock_val + + +def test_update_job_flattened_error(): + client = JobServiceClient( + 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_job( + job_service.UpdateJobRequest(), + job=gct_job.Job(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_update_job_flattened_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.update_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_job.Job() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_job( + job=gct_job.Job(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].job + mock_val = gct_job.Job(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_job_flattened_error_async(): + client = JobServiceAsyncClient( + 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_job( + job_service.UpdateJobRequest(), + job=gct_job.Job(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.BatchUpdateJobsRequest, + dict, +]) +def test_batch_update_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.batch_update_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchUpdateJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_batch_update_jobs_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 = JobServiceClient( + 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.batch_update_jobs), + '__call__') as call: + client.batch_update_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchUpdateJobsRequest() + +@pytest.mark.asyncio +async def test_batch_update_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchUpdateJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.batch_update_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchUpdateJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_batch_update_jobs_async_from_dict(): + await test_batch_update_jobs_async(request_type=dict) + + +def test_batch_update_jobs_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 = job_service.BatchUpdateJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_jobs), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.batch_update_jobs(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_batch_update_jobs_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 = job_service.BatchUpdateJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.batch_update_jobs(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_batch_update_jobs_flattened(): + 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.batch_update_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.batch_update_jobs( + parent='parent_value', + jobs=[job.Job(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].jobs + mock_val = [job.Job(name='name_value')] + assert arg == mock_val + + +def test_batch_update_jobs_flattened_error(): + client = JobServiceClient( + 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.batch_update_jobs( + job_service.BatchUpdateJobsRequest(), + parent='parent_value', + jobs=[job.Job(name='name_value')], + ) + +@pytest.mark.asyncio +async def test_batch_update_jobs_flattened_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.batch_update_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.batch_update_jobs( + parent='parent_value', + jobs=[job.Job(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].jobs + mock_val = [job.Job(name='name_value')] + assert arg == mock_val + +@pytest.mark.asyncio +async def test_batch_update_jobs_flattened_error_async(): + client = JobServiceAsyncClient( + 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.batch_update_jobs( + job_service.BatchUpdateJobsRequest(), + parent='parent_value', + jobs=[job.Job(name='name_value')], + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.DeleteJobRequest, + dict, +]) +def test_delete_job(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.DeleteJobRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_job_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 = JobServiceClient( + 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_job), + '__call__') as call: + client.delete_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.DeleteJobRequest() + +@pytest.mark.asyncio +async def test_delete_job_async(transport: str = 'grpc_asyncio', request_type=job_service.DeleteJobRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_job), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_job(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.DeleteJobRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_job_async_from_dict(): + await test_delete_job_async(request_type=dict) + + +def test_delete_job_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 = job_service.DeleteJobRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_job), + '__call__') as call: + call.return_value = None + client.delete_job(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_job_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 = job_service.DeleteJobRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_job), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_job(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_job_flattened(): + 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.delete_job), + '__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_job( + 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_job_flattened_error(): + client = JobServiceClient( + 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_job( + job_service.DeleteJobRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_job_flattened_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.delete_job), + '__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_job( + 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_job_flattened_error_async(): + client = JobServiceAsyncClient( + 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_job( + job_service.DeleteJobRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.BatchDeleteJobsRequest, + dict, +]) +def test_batch_delete_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.batch_delete_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchDeleteJobsRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_batch_delete_jobs_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 = JobServiceClient( + 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.batch_delete_jobs), + '__call__') as call: + client.batch_delete_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchDeleteJobsRequest() + +@pytest.mark.asyncio +async def test_batch_delete_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchDeleteJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.batch_delete_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.BatchDeleteJobsRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_batch_delete_jobs_async_from_dict(): + await test_batch_delete_jobs_async(request_type=dict) + + +def test_batch_delete_jobs_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 = job_service.BatchDeleteJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_jobs), + '__call__') as call: + call.return_value = None + client.batch_delete_jobs(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_batch_delete_jobs_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 = job_service.BatchDeleteJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.batch_delete_jobs(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_batch_delete_jobs_flattened(): + 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.batch_delete_jobs), + '__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.batch_delete_jobs( + parent='parent_value', + filter='filter_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].filter + mock_val = 'filter_value' + assert arg == mock_val + + +def test_batch_delete_jobs_flattened_error(): + client = JobServiceClient( + 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.batch_delete_jobs( + job_service.BatchDeleteJobsRequest(), + parent='parent_value', + filter='filter_value', + ) + +@pytest.mark.asyncio +async def test_batch_delete_jobs_flattened_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.batch_delete_jobs), + '__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.batch_delete_jobs( + parent='parent_value', + filter='filter_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].filter + mock_val = 'filter_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_batch_delete_jobs_flattened_error_async(): + client = JobServiceAsyncClient( + 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.batch_delete_jobs( + job_service.BatchDeleteJobsRequest(), + parent='parent_value', + filter='filter_value', + ) + + +@pytest.mark.parametrize("request_type", [ + job_service.ListJobsRequest, + dict, +]) +def test_list_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.ListJobsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.ListJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListJobsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_jobs_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 = JobServiceClient( + 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_jobs), + '__call__') as call: + client.list_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.ListJobsRequest() + +@pytest.mark.asyncio +async def test_list_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.ListJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.ListJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListJobsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_jobs_async_from_dict(): + await test_list_jobs_async(request_type=dict) + + +def test_list_jobs_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 = job_service.ListJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_jobs), + '__call__') as call: + call.return_value = job_service.ListJobsResponse() + client.list_jobs(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_jobs_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 = job_service.ListJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse()) + await client.list_jobs(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_jobs_flattened(): + 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.list_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.ListJobsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_jobs( + parent='parent_value', + filter='filter_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].filter + mock_val = 'filter_value' + assert arg == mock_val + + +def test_list_jobs_flattened_error(): + client = JobServiceClient( + 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_jobs( + job_service.ListJobsRequest(), + parent='parent_value', + filter='filter_value', + ) + +@pytest.mark.asyncio +async def test_list_jobs_flattened_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.list_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.ListJobsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_jobs( + parent='parent_value', + filter='filter_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].filter + mock_val = 'filter_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_jobs_flattened_error_async(): + client = JobServiceAsyncClient( + 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_jobs( + job_service.ListJobsRequest(), + parent='parent_value', + filter='filter_value', + ) + + +def test_list_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + 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_jobs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + job.Job(), + ], + next_page_token='abc', + ), + job_service.ListJobsResponse( + jobs=[], + next_page_token='def', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + ], + next_page_token='ghi', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_jobs(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, job.Job) + for i in results) +def test_list_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + 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_jobs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + job.Job(), + ], + next_page_token='abc', + ), + job_service.ListJobsResponse( + jobs=[], + next_page_token='def', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + ], + next_page_token='ghi', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + ], + ), + RuntimeError, + ) + pages = list(client.list_jobs(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_jobs_async_pager(): + 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.list_jobs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + job.Job(), + ], + next_page_token='abc', + ), + job_service.ListJobsResponse( + jobs=[], + next_page_token='def', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + ], + next_page_token='ghi', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_jobs(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, job.Job) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_jobs_async_pages(): + 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.list_jobs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + job.Job(), + ], + next_page_token='abc', + ), + job_service.ListJobsResponse( + jobs=[], + next_page_token='def', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + ], + next_page_token='ghi', + ), + job_service.ListJobsResponse( + jobs=[ + job.Job(), + job.Job(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_jobs(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", [ + job_service.SearchJobsRequest, + dict, +]) +def test_search_jobs(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.SearchJobsResponse( + next_page_token='next_page_token_value', + estimated_total_size=2141, + total_size=1086, + broadened_query_jobs_count=2766, + ) + response = client.search_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchJobsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.estimated_total_size == 2141 + assert response.total_size == 1086 + assert response.broadened_query_jobs_count == 2766 + + +def test_search_jobs_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 = JobServiceClient( + 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_jobs), + '__call__') as call: + client.search_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + +@pytest.mark.asyncio +async def test_search_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.SearchJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse( + next_page_token='next_page_token_value', + estimated_total_size=2141, + total_size=1086, + broadened_query_jobs_count=2766, + )) + response = await client.search_jobs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchJobsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.estimated_total_size == 2141 + assert response.total_size == 1086 + assert response.broadened_query_jobs_count == 2766 + + +@pytest.mark.asyncio +async def test_search_jobs_async_from_dict(): + await test_search_jobs_async(request_type=dict) + + +def test_search_jobs_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 = job_service.SearchJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs), + '__call__') as call: + call.return_value = job_service.SearchJobsResponse() + client.search_jobs(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_jobs_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 = job_service.SearchJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse()) + await client.search_jobs(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_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + 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_jobs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='abc', + ), + job_service.SearchJobsResponse( + matching_jobs=[], + next_page_token='def', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='ghi', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.search_jobs(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, job_service.SearchJobsResponse.MatchingJob) + for i in results) +def test_search_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + 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_jobs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='abc', + ), + job_service.SearchJobsResponse( + matching_jobs=[], + next_page_token='def', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='ghi', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + ), + RuntimeError, + ) + pages = list(client.search_jobs(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_jobs_async_pager(): + 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.search_jobs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='abc', + ), + job_service.SearchJobsResponse( + matching_jobs=[], + next_page_token='def', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='ghi', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + ), + RuntimeError, + ) + async_pager = await client.search_jobs(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, job_service.SearchJobsResponse.MatchingJob) + for i in responses) + + +@pytest.mark.asyncio +async def test_search_jobs_async_pages(): + 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.search_jobs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='abc', + ), + job_service.SearchJobsResponse( + matching_jobs=[], + next_page_token='def', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='ghi', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.search_jobs(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", [ + job_service.SearchJobsRequest, + dict, +]) +def test_search_jobs_for_alert(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs_for_alert), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = job_service.SearchJobsResponse( + next_page_token='next_page_token_value', + estimated_total_size=2141, + total_size=1086, + broadened_query_jobs_count=2766, + ) + response = client.search_jobs_for_alert(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchJobsForAlertPager) + assert response.next_page_token == 'next_page_token_value' + assert response.estimated_total_size == 2141 + assert response.total_size == 1086 + assert response.broadened_query_jobs_count == 2766 + + +def test_search_jobs_for_alert_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 = JobServiceClient( + 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_jobs_for_alert), + '__call__') as call: + client.search_jobs_for_alert() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + +@pytest.mark.asyncio +async def test_search_jobs_for_alert_async(transport: str = 'grpc_asyncio', request_type=job_service.SearchJobsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs_for_alert), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse( + next_page_token='next_page_token_value', + estimated_total_size=2141, + total_size=1086, + broadened_query_jobs_count=2766, + )) + response = await client.search_jobs_for_alert(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == job_service.SearchJobsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchJobsForAlertAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.estimated_total_size == 2141 + assert response.total_size == 1086 + assert response.broadened_query_jobs_count == 2766 + + +@pytest.mark.asyncio +async def test_search_jobs_for_alert_async_from_dict(): + await test_search_jobs_for_alert_async(request_type=dict) + + +def test_search_jobs_for_alert_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 = job_service.SearchJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs_for_alert), + '__call__') as call: + call.return_value = job_service.SearchJobsResponse() + client.search_jobs_for_alert(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_jobs_for_alert_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 = job_service.SearchJobsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_jobs_for_alert), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse()) + await client.search_jobs_for_alert(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_jobs_for_alert_pager(transport_name: str = "grpc"): + client = JobServiceClient( + 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_jobs_for_alert), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='abc', + ), + job_service.SearchJobsResponse( + matching_jobs=[], + next_page_token='def', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='ghi', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.search_jobs_for_alert(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, job_service.SearchJobsResponse.MatchingJob) + for i in results) +def test_search_jobs_for_alert_pages(transport_name: str = "grpc"): + client = JobServiceClient( + 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_jobs_for_alert), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='abc', + ), + job_service.SearchJobsResponse( + matching_jobs=[], + next_page_token='def', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='ghi', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + ), + RuntimeError, + ) + pages = list(client.search_jobs_for_alert(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_jobs_for_alert_async_pager(): + 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.search_jobs_for_alert), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='abc', + ), + job_service.SearchJobsResponse( + matching_jobs=[], + next_page_token='def', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='ghi', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + ), + RuntimeError, + ) + async_pager = await client.search_jobs_for_alert(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, job_service.SearchJobsResponse.MatchingJob) + for i in responses) + + +@pytest.mark.asyncio +async def test_search_jobs_for_alert_async_pages(): + 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.search_jobs_for_alert), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='abc', + ), + job_service.SearchJobsResponse( + matching_jobs=[], + next_page_token='def', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + ], + next_page_token='ghi', + ), + job_service.SearchJobsResponse( + matching_jobs=[ + job_service.SearchJobsResponse.MatchingJob(), + job_service.SearchJobsResponse.MatchingJob(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.search_jobs_for_alert(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.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = JobServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = JobServiceClient( + 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 = JobServiceClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = JobServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = JobServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.JobServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.JobServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.JobServiceGrpcTransport, + transports.JobServiceGrpcAsyncIOTransport, +]) +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 = JobServiceClient.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 = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.JobServiceGrpcTransport, + ) + +def test_job_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.JobServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_job_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4beta1.services.job_service.transports.JobServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.JobServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_job', + 'batch_create_jobs', + 'get_job', + 'update_job', + 'batch_update_jobs', + 'delete_job', + 'batch_delete_jobs', + 'list_jobs', + 'search_jobs', + 'search_jobs_for_alert', + 'get_operation', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + # Catch all for all remaining methods and properties + remainder = [ + 'kind', + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + + +def test_job_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.job_service.transports.JobServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.JobServiceTransport( + 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_job_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.job_service.transports.JobServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.JobServiceTransport() + adc.assert_called_once() + + +def test_job_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) + JobServiceClient() + 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.JobServiceGrpcTransport, + transports.JobServiceGrpcAsyncIOTransport, + ], +) +def test_job_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", + [ + 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", + [ + (transports.JobServiceGrpcTransport, grpc_helpers), + (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_job_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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) +def test_job_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_job_service_host_no_port(transport_name): + client = JobServiceClient( + 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_job_service_host_with_port(transport_name): + client = JobServiceClient( + 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_job_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.JobServiceGrpcTransport( + 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_job_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.JobServiceGrpcAsyncIOTransport( + 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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) +def test_job_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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) +def test_job_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_job_service_grpc_lro_client(): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_job_service_grpc_lro_async_client(): + client = JobServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc_asyncio', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) + actual = JobServiceClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = JobServiceClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_company_path(path) + assert expected == actual + +def test_job_path(): + project = "cuttlefish" + tenant = "mussel" + job = "winkle" + expected = "projects/{project}/tenants/{tenant}/jobs/{job}".format(project=project, tenant=tenant, job=job, ) + actual = JobServiceClient.job_path(project, tenant, job) + assert expected == actual + + +def test_parse_job_path(): + expected = { + "project": "nautilus", + "tenant": "scallop", + "job": "abalone", + } + path = JobServiceClient.job_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_job_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "squid" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = JobServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "clam", + } + path = JobServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "whelk" + expected = "folders/{folder}".format(folder=folder, ) + actual = JobServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "octopus", + } + path = JobServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "oyster" + expected = "organizations/{organization}".format(organization=organization, ) + actual = JobServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nudibranch", + } + path = JobServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "cuttlefish" + expected = "projects/{project}".format(project=project, ) + actual = JobServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "mussel", + } + path = JobServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "winkle" + location = "nautilus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = JobServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "scallop", + "location": "abalone", + } + path = JobServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.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.JobServiceTransport, '_prep_wrapped_messages') as prep: + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.JobServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = JobServiceClient.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 = JobServiceAsyncClient( + 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_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_async(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", + } + + for transport, close_name in transports.items(): + client = JobServiceClient( + 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 = JobServiceClient( + 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", [ + (JobServiceClient, transports.JobServiceGrpcTransport), + (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_tenant_service.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_tenant_service.py new file mode 100644 index 00000000..4169d32c --- /dev/null +++ b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_tenant_service.py @@ -0,0 +1,2688 @@ +# -*- 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 grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.talent_v4beta1.services.tenant_service import TenantServiceAsyncClient +from google.cloud.talent_v4beta1.services.tenant_service import TenantServiceClient +from google.cloud.talent_v4beta1.services.tenant_service import pagers +from google.cloud.talent_v4beta1.services.tenant_service import transports +from google.cloud.talent_v4beta1.types import tenant +from google.cloud.talent_v4beta1.types import tenant as gct_tenant +from google.cloud.talent_v4beta1.types import tenant_service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +import google.auth + + +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 TenantServiceClient._get_default_mtls_endpoint(None) is None + assert TenantServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert TenantServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert TenantServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert TenantServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert TenantServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (TenantServiceClient, "grpc"), + (TenantServiceAsyncClient, "grpc_asyncio"), +]) +def test_tenant_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.TenantServiceGrpcTransport, "grpc"), + (transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_tenant_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", [ + (TenantServiceClient, "grpc"), + (TenantServiceAsyncClient, "grpc_asyncio"), +]) +def test_tenant_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_tenant_service_client_get_transport_class(): + transport = TenantServiceClient.get_transport_class() + available_transports = [ + transports.TenantServiceGrpcTransport, + ] + assert transport in available_transports + + transport = TenantServiceClient.get_transport_class("grpc") + assert transport == transports.TenantServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc"), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) +@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) +def test_tenant_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(TenantServiceClient, '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(TenantServiceClient, '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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + 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" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", "true"), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", "false"), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) +@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_tenant_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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + # 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + TenantServiceClient, TenantServiceAsyncClient +]) +@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) +@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) +def test_tenant_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", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc"), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_tenant_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, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", grpc_helpers), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_tenant_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, + api_audience=None, + ) + +def test_tenant_service_client_client_options_from_dict(): + with mock.patch('google.cloud.talent_v4beta1.services.tenant_service.transports.TenantServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = TenantServiceClient( + 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, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", grpc_helpers), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_tenant_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, + api_audience=None, + ) + + # 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", [ + tenant_service.CreateTenantRequest, + dict, +]) +def test_create_tenant(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant( + name='name_value', + external_id='external_id_value', + usage_type=gct_tenant.Tenant.DataUsageType.AGGREGATED, + keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], + ) + response = client.create_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.CreateTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + assert response.usage_type == gct_tenant.Tenant.DataUsageType.AGGREGATED + assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] + + +def test_create_tenant_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 = TenantServiceClient( + 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_tenant), + '__call__') as call: + client.create_tenant() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.CreateTenantRequest() + +@pytest.mark.asyncio +async def test_create_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.CreateTenantRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant( + name='name_value', + external_id='external_id_value', + usage_type=gct_tenant.Tenant.DataUsageType.AGGREGATED, + keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], + )) + response = await client.create_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.CreateTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + assert response.usage_type == gct_tenant.Tenant.DataUsageType.AGGREGATED + assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] + + +@pytest.mark.asyncio +async def test_create_tenant_async_from_dict(): + await test_create_tenant_async(request_type=dict) + + +def test_create_tenant_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 = tenant_service.CreateTenantRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tenant), + '__call__') as call: + call.return_value = gct_tenant.Tenant() + client.create_tenant(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_tenant_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 = tenant_service.CreateTenantRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_tenant), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) + await client.create_tenant(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_tenant_flattened(): + 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.create_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_tenant( + parent='parent_value', + tenant=gct_tenant.Tenant(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].tenant + mock_val = gct_tenant.Tenant(name='name_value') + assert arg == mock_val + + +def test_create_tenant_flattened_error(): + client = TenantServiceClient( + 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_tenant( + tenant_service.CreateTenantRequest(), + parent='parent_value', + tenant=gct_tenant.Tenant(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_tenant_flattened_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.create_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_tenant( + parent='parent_value', + tenant=gct_tenant.Tenant(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].tenant + mock_val = gct_tenant.Tenant(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_tenant_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenant( + tenant_service.CreateTenantRequest(), + parent='parent_value', + tenant=gct_tenant.Tenant(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + tenant_service.GetTenantRequest, + dict, +]) +def test_get_tenant(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant.Tenant( + name='name_value', + external_id='external_id_value', + usage_type=tenant.Tenant.DataUsageType.AGGREGATED, + keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], + ) + response = client.get_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.GetTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + assert response.usage_type == tenant.Tenant.DataUsageType.AGGREGATED + assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] + + +def test_get_tenant_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 = TenantServiceClient( + 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_tenant), + '__call__') as call: + client.get_tenant() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.GetTenantRequest() + +@pytest.mark.asyncio +async def test_get_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.GetTenantRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant( + name='name_value', + external_id='external_id_value', + usage_type=tenant.Tenant.DataUsageType.AGGREGATED, + keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], + )) + response = await client.get_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.GetTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + assert response.usage_type == tenant.Tenant.DataUsageType.AGGREGATED + assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] + + +@pytest.mark.asyncio +async def test_get_tenant_async_from_dict(): + await test_get_tenant_async(request_type=dict) + + +def test_get_tenant_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 = tenant_service.GetTenantRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tenant), + '__call__') as call: + call.return_value = tenant.Tenant() + client.get_tenant(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_tenant_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 = tenant_service.GetTenantRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_tenant), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) + await client.get_tenant(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_tenant_flattened(): + 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_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant.Tenant() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_tenant( + 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_tenant_flattened_error(): + client = TenantServiceClient( + 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_tenant( + tenant_service.GetTenantRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_tenant_flattened_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_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant.Tenant() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_tenant( + 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_tenant_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenant( + tenant_service.GetTenantRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + tenant_service.UpdateTenantRequest, + dict, +]) +def test_update_tenant(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant( + name='name_value', + external_id='external_id_value', + usage_type=gct_tenant.Tenant.DataUsageType.AGGREGATED, + keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], + ) + response = client.update_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.UpdateTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + assert response.usage_type == gct_tenant.Tenant.DataUsageType.AGGREGATED + assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] + + +def test_update_tenant_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 = TenantServiceClient( + 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_tenant), + '__call__') as call: + client.update_tenant() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.UpdateTenantRequest() + +@pytest.mark.asyncio +async def test_update_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.UpdateTenantRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant( + name='name_value', + external_id='external_id_value', + usage_type=gct_tenant.Tenant.DataUsageType.AGGREGATED, + keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], + )) + response = await client.update_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.UpdateTenantRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) + assert response.name == 'name_value' + assert response.external_id == 'external_id_value' + assert response.usage_type == gct_tenant.Tenant.DataUsageType.AGGREGATED + assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] + + +@pytest.mark.asyncio +async def test_update_tenant_async_from_dict(): + await test_update_tenant_async(request_type=dict) + + +def test_update_tenant_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 = tenant_service.UpdateTenantRequest() + + request.tenant.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tenant), + '__call__') as call: + call.return_value = gct_tenant.Tenant() + client.update_tenant(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', + 'tenant.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_tenant_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 = tenant_service.UpdateTenantRequest() + + request.tenant.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_tenant), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) + await client.update_tenant(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', + 'tenant.name=name_value', + ) in kw['metadata'] + + +def test_update_tenant_flattened(): + 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.update_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_tenant( + tenant=gct_tenant.Tenant(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].tenant + mock_val = gct_tenant.Tenant(name='name_value') + assert arg == mock_val + + +def test_update_tenant_flattened_error(): + client = TenantServiceClient( + 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_tenant( + tenant_service.UpdateTenantRequest(), + tenant=gct_tenant.Tenant(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_update_tenant_flattened_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.update_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = gct_tenant.Tenant() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_tenant( + tenant=gct_tenant.Tenant(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].tenant + mock_val = gct_tenant.Tenant(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_tenant_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenant( + tenant_service.UpdateTenantRequest(), + tenant=gct_tenant.Tenant(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + tenant_service.DeleteTenantRequest, + dict, +]) +def test_delete_tenant(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.DeleteTenantRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_tenant_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 = TenantServiceClient( + 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_tenant), + '__call__') as call: + client.delete_tenant() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.DeleteTenantRequest() + +@pytest.mark.asyncio +async def test_delete_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.DeleteTenantRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tenant), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_tenant(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.DeleteTenantRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_tenant_async_from_dict(): + await test_delete_tenant_async(request_type=dict) + + +def test_delete_tenant_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 = tenant_service.DeleteTenantRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tenant), + '__call__') as call: + call.return_value = None + client.delete_tenant(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_tenant_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 = tenant_service.DeleteTenantRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_tenant), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_tenant(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_tenant_flattened(): + 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.delete_tenant), + '__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_tenant( + 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_tenant_flattened_error(): + client = TenantServiceClient( + 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_tenant( + tenant_service.DeleteTenantRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_tenant_flattened_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.delete_tenant), + '__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_tenant( + 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_tenant_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenant( + tenant_service.DeleteTenantRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + tenant_service.ListTenantsRequest, + dict, +]) +def test_list_tenants(request_type, 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tenants), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant_service.ListTenantsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_tenants(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.ListTenantsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTenantsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_tenants_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 = TenantServiceClient( + 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_tenants), + '__call__') as call: + client.list_tenants() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.ListTenantsRequest() + +@pytest.mark.asyncio +async def test_list_tenants_async(transport: str = 'grpc_asyncio', request_type=tenant_service.ListTenantsRequest): + 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 = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tenants), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_tenants(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == tenant_service.ListTenantsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTenantsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_tenants_async_from_dict(): + await test_list_tenants_async(request_type=dict) + + +def test_list_tenants_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 = tenant_service.ListTenantsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tenants), + '__call__') as call: + call.return_value = tenant_service.ListTenantsResponse() + client.list_tenants(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_tenants_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 = tenant_service.ListTenantsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_tenants), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse()) + await client.list_tenants(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_tenants_flattened(): + 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.list_tenants), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant_service.ListTenantsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_tenants( + 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_tenants_flattened_error(): + client = TenantServiceClient( + 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_tenants( + tenant_service.ListTenantsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_tenants_flattened_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.list_tenants), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = tenant_service.ListTenantsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_tenants( + 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_tenants_flattened_error_async(): + client = TenantServiceAsyncClient( + 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_tenants( + tenant_service.ListTenantsRequest(), + parent='parent_value', + ) + + +def test_list_tenants_pager(transport_name: str = "grpc"): + client = TenantServiceClient( + 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_tenants), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + tenant.Tenant(), + ], + next_page_token='abc', + ), + tenant_service.ListTenantsResponse( + tenants=[], + next_page_token='def', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + ], + next_page_token='ghi', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_tenants(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, tenant.Tenant) + for i in results) +def test_list_tenants_pages(transport_name: str = "grpc"): + client = TenantServiceClient( + 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_tenants), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + tenant.Tenant(), + ], + next_page_token='abc', + ), + tenant_service.ListTenantsResponse( + tenants=[], + next_page_token='def', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + ], + next_page_token='ghi', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + ], + ), + RuntimeError, + ) + pages = list(client.list_tenants(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_tenants_async_pager(): + 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.list_tenants), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + tenant.Tenant(), + ], + next_page_token='abc', + ), + tenant_service.ListTenantsResponse( + tenants=[], + next_page_token='def', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + ], + next_page_token='ghi', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_tenants(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, tenant.Tenant) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_tenants_async_pages(): + 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.list_tenants), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + tenant.Tenant(), + ], + next_page_token='abc', + ), + tenant_service.ListTenantsResponse( + tenants=[], + next_page_token='def', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + ], + next_page_token='ghi', + ), + tenant_service.ListTenantsResponse( + tenants=[ + tenant.Tenant(), + tenant.Tenant(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_tenants(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.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = TenantServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = TenantServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TenantServiceClient( + 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 = TenantServiceClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = TenantServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = TenantServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.TenantServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.TenantServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.TenantServiceGrpcTransport, + transports.TenantServiceGrpcAsyncIOTransport, +]) +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 = TenantServiceClient.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 = TenantServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.TenantServiceGrpcTransport, + ) + +def test_tenant_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.TenantServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_tenant_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.talent_v4beta1.services.tenant_service.transports.TenantServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.TenantServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_tenant', + 'get_tenant', + 'update_tenant', + 'delete_tenant', + 'list_tenants', + 'get_operation', + ) + 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_tenant_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.tenant_service.transports.TenantServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.TenantServiceTransport( + 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_tenant_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.tenant_service.transports.TenantServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.TenantServiceTransport() + adc.assert_called_once() + + +def test_tenant_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) + TenantServiceClient() + 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.TenantServiceGrpcTransport, + transports.TenantServiceGrpcAsyncIOTransport, + ], +) +def test_tenant_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", + [ + 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", + [ + (transports.TenantServiceGrpcTransport, grpc_helpers), + (transports.TenantServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_tenant_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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) +def test_tenant_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_tenant_service_host_no_port(transport_name): + client = TenantServiceClient( + 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_tenant_service_host_with_port(transport_name): + client = TenantServiceClient( + 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_tenant_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.TenantServiceGrpcTransport( + 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_tenant_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.TenantServiceGrpcAsyncIOTransport( + 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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) +def test_tenant_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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) +def test_tenant_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_tenant_path(): + project = "squid" + tenant = "clam" + expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) + actual = TenantServiceClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "whelk", + "tenant": "octopus", + } + path = TenantServiceClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_tenant_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "oyster" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = TenantServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nudibranch", + } + path = TenantServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "cuttlefish" + expected = "folders/{folder}".format(folder=folder, ) + actual = TenantServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "mussel", + } + path = TenantServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "winkle" + expected = "organizations/{organization}".format(organization=organization, ) + actual = TenantServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nautilus", + } + path = TenantServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "scallop" + expected = "projects/{project}".format(project=project, ) + actual = TenantServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "abalone", + } + path = TenantServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "squid" + location = "clam" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = TenantServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = TenantServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.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.TenantServiceTransport, '_prep_wrapped_messages') as prep: + client = TenantServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.TenantServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = TenantServiceClient.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 = TenantServiceAsyncClient( + 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_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_async(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", + } + + for transport, close_name in transports.items(): + client = TenantServiceClient( + 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 = TenantServiceClient( + 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", [ + (TenantServiceClient, transports.TenantServiceGrpcTransport), + (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport), +]) +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, + api_audience=None, + ) From 8c8eb6b3b93635177da42c9944e0e6438db0fd1a Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 7 Sep 2022 01:01:13 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../services/company_service/async_client.py | 35 + .../services/company_service/client.py | 35 + .../services/completion/async_client.py | 7 + .../talent_v4/services/completion/client.py | 7 + .../services/event_service/async_client.py | 9 +- .../services/event_service/client.py | 9 +- .../services/job_service/async_client.py | 70 + .../talent_v4/services/job_service/client.py | 70 + .../services/tenant_service/async_client.py | 35 + .../services/tenant_service/client.py | 35 + .../services/company_service/async_client.py | 35 + .../services/company_service/client.py | 35 + .../services/completion/async_client.py | 7 + .../services/completion/client.py | 7 + .../services/event_service/async_client.py | 9 +- .../services/event_service/client.py | 9 +- .../services/job_service/async_client.py | 70 + .../services/job_service/client.py | 70 + .../services/tenant_service/async_client.py | 35 + .../services/tenant_service/client.py | 35 + mypy.ini | 2 +- owl-bot-staging/v4/.coveragerc | 17 - owl-bot-staging/v4/.flake8 | 33 - owl-bot-staging/v4/MANIFEST.in | 2 - owl-bot-staging/v4/README.rst | 49 - owl-bot-staging/v4/docs/conf.py | 376 -- owl-bot-staging/v4/docs/index.rst | 7 - .../v4/docs/talent_v4/company_service.rst | 10 - .../v4/docs/talent_v4/completion.rst | 6 - .../v4/docs/talent_v4/event_service.rst | 6 - .../v4/docs/talent_v4/job_service.rst | 10 - .../v4/docs/talent_v4/services.rst | 10 - .../v4/docs/talent_v4/tenant_service.rst | 10 - owl-bot-staging/v4/docs/talent_v4/types.rst | 7 - .../v4/google/cloud/talent/__init__.py | 161 - .../v4/google/cloud/talent/py.typed | 2 - .../v4/google/cloud/talent_v4/__init__.py | 162 - .../cloud/talent_v4/gapic_metadata.json | 299 -- .../v4/google/cloud/talent_v4/py.typed | 2 - .../cloud/talent_v4/services/__init__.py | 15 - .../services/company_service/__init__.py | 22 - .../services/company_service/async_client.py | 805 --- .../services/company_service/client.py | 993 ---- .../services/company_service/pagers.py | 140 - .../company_service/transports/__init__.py | 33 - .../company_service/transports/base.py | 235 - .../company_service/transports/grpc.py | 374 -- .../transports/grpc_asyncio.py | 373 -- .../talent_v4/services/completion/__init__.py | 22 - .../services/completion/async_client.py | 295 -- .../talent_v4/services/completion/client.py | 498 -- .../completion/transports/__init__.py | 33 - .../services/completion/transports/base.py | 162 - .../services/completion/transports/grpc.py | 266 - .../completion/transports/grpc_asyncio.py | 265 - .../services/event_service/__init__.py | 22 - .../services/event_service/async_client.py | 340 -- .../services/event_service/client.py | 540 -- .../event_service/transports/__init__.py | 33 - .../services/event_service/transports/base.py | 156 - .../services/event_service/transports/grpc.py | 271 - .../event_service/transports/grpc_asyncio.py | 270 - .../services/job_service/__init__.py | 22 - .../services/job_service/async_client.py | 1431 ------ .../talent_v4/services/job_service/client.py | 1630 ------ .../talent_v4/services/job_service/pagers.py | 140 - .../job_service/transports/__init__.py | 33 - .../services/job_service/transports/base.py | 312 -- .../services/job_service/transports/grpc.py | 547 --- .../job_service/transports/grpc_asyncio.py | 546 -- .../services/tenant_service/__init__.py | 22 - .../services/tenant_service/async_client.py | 797 --- .../services/tenant_service/client.py | 976 ---- .../services/tenant_service/pagers.py | 140 - .../tenant_service/transports/__init__.py | 33 - .../tenant_service/transports/base.py | 235 - .../tenant_service/transports/grpc.py | 372 -- .../tenant_service/transports/grpc_asyncio.py | 371 -- .../google/cloud/talent_v4/types/__init__.py | 164 - .../v4/google/cloud/talent_v4/types/common.py | 849 ---- .../google/cloud/talent_v4/types/company.py | 175 - .../cloud/talent_v4/types/company_service.py | 210 - .../talent_v4/types/completion_service.py | 163 - .../v4/google/cloud/talent_v4/types/event.py | 143 - .../cloud/talent_v4/types/event_service.py | 56 - .../google/cloud/talent_v4/types/filters.py | 499 -- .../google/cloud/talent_v4/types/histogram.py | 82 - .../v4/google/cloud/talent_v4/types/job.py | 569 --- .../cloud/talent_v4/types/job_service.py | 1126 ----- .../v4/google/cloud/talent_v4/types/tenant.py | 58 - .../cloud/talent_v4/types/tenant_service.py | 194 - owl-bot-staging/v4/mypy.ini | 3 - owl-bot-staging/v4/noxfile.py | 179 - ...ed_company_service_create_company_async.py | 57 - ...ted_company_service_create_company_sync.py | 57 - ...ed_company_service_delete_company_async.py | 50 - ...ted_company_service_delete_company_sync.py | 50 - ...rated_company_service_get_company_async.py | 52 - ...erated_company_service_get_company_sync.py | 52 - ...ed_company_service_list_companies_async.py | 53 - ...ted_company_service_list_companies_sync.py | 53 - ...ed_company_service_update_company_async.py | 56 - ...ted_company_service_update_company_sync.py | 56 - ...nerated_completion_complete_query_async.py | 54 - ...enerated_completion_complete_query_sync.py | 54 - ...event_service_create_client_event_async.py | 58 - ..._event_service_create_client_event_sync.py | 58 - ...ted_job_service_batch_create_jobs_async.py | 63 - ...ated_job_service_batch_create_jobs_sync.py | 63 - ...ted_job_service_batch_delete_jobs_async.py | 56 - ...ated_job_service_batch_delete_jobs_sync.py | 56 - ...ted_job_service_batch_update_jobs_async.py | 63 - ...ated_job_service_batch_update_jobs_sync.py | 63 - ..._generated_job_service_create_job_async.py | 59 - ...4_generated_job_service_create_job_sync.py | 59 - ..._generated_job_service_delete_job_async.py | 50 - ...4_generated_job_service_delete_job_sync.py | 50 - ..._v4_generated_job_service_get_job_async.py | 52 - ...s_v4_generated_job_service_get_job_sync.py | 52 - ...4_generated_job_service_list_jobs_async.py | 54 - ...v4_generated_job_service_list_jobs_sync.py | 54 - ...generated_job_service_search_jobs_async.py | 52 - ...job_service_search_jobs_for_alert_async.py | 52 - ..._job_service_search_jobs_for_alert_sync.py | 52 - ..._generated_job_service_search_jobs_sync.py | 52 - ..._generated_job_service_update_job_async.py | 58 - ...4_generated_job_service_update_job_sync.py | 58 - ...ated_tenant_service_create_tenant_async.py | 56 - ...rated_tenant_service_create_tenant_sync.py | 56 - ...ated_tenant_service_delete_tenant_async.py | 50 - ...rated_tenant_service_delete_tenant_sync.py | 50 - ...nerated_tenant_service_get_tenant_async.py | 52 - ...enerated_tenant_service_get_tenant_sync.py | 52 - ...rated_tenant_service_list_tenants_async.py | 53 - ...erated_tenant_service_list_tenants_sync.py | 53 - ...ated_tenant_service_update_tenant_async.py | 55 - ...rated_tenant_service_update_tenant_sync.py | 55 - .../snippet_metadata_talent_v4.json | 3602 -------------- .../v4/scripts/fixup_talent_v4_keywords.py | 197 - owl-bot-staging/v4/setup.py | 58 - owl-bot-staging/v4/tests/__init__.py | 16 - owl-bot-staging/v4/tests/unit/__init__.py | 16 - .../v4/tests/unit/gapic/__init__.py | 16 - .../v4/tests/unit/gapic/talent_v4/__init__.py | 16 - .../gapic/talent_v4/test_company_service.py | 2687 ---------- .../unit/gapic/talent_v4/test_completion.py | 1328 ----- .../gapic/talent_v4/test_event_service.py | 1413 ------ .../unit/gapic/talent_v4/test_job_service.py | 3895 --------------- .../gapic/talent_v4/test_tenant_service.py | 2543 ---------- owl-bot-staging/v4beta1/.coveragerc | 17 - owl-bot-staging/v4beta1/.flake8 | 33 - owl-bot-staging/v4beta1/MANIFEST.in | 2 - owl-bot-staging/v4beta1/README.rst | 49 - owl-bot-staging/v4beta1/docs/conf.py | 376 -- owl-bot-staging/v4beta1/docs/index.rst | 7 - .../docs/talent_v4beta1/company_service.rst | 10 - .../docs/talent_v4beta1/completion.rst | 6 - .../docs/talent_v4beta1/event_service.rst | 6 - .../docs/talent_v4beta1/job_service.rst | 10 - .../v4beta1/docs/talent_v4beta1/services.rst | 10 - .../docs/talent_v4beta1/tenant_service.rst | 10 - .../v4beta1/docs/talent_v4beta1/types.rst | 7 - .../v4beta1/google/cloud/talent/__init__.py | 155 - .../v4beta1/google/cloud/talent/py.typed | 2 - .../google/cloud/talent_v4beta1/__init__.py | 156 - .../cloud/talent_v4beta1/gapic_metadata.json | 299 -- .../google/cloud/talent_v4beta1/py.typed | 2 - .../cloud/talent_v4beta1/services/__init__.py | 15 - .../services/company_service/__init__.py | 22 - .../services/company_service/async_client.py | 846 ---- .../services/company_service/client.py | 1027 ---- .../services/company_service/pagers.py | 140 - .../company_service/transports/__init__.py | 33 - .../company_service/transports/base.py | 245 - .../company_service/transports/grpc.py | 393 -- .../transports/grpc_asyncio.py | 392 -- .../services/completion/__init__.py | 22 - .../services/completion/async_client.py | 345 -- .../services/completion/client.py | 541 -- .../completion/transports/__init__.py | 33 - .../services/completion/transports/base.py | 172 - .../services/completion/transports/grpc.py | 285 -- .../completion/transports/grpc_asyncio.py | 284 -- .../services/event_service/__init__.py | 22 - .../services/event_service/async_client.py | 394 -- .../services/event_service/client.py | 596 --- .../event_service/transports/__init__.py | 33 - .../services/event_service/transports/base.py | 166 - .../services/event_service/transports/grpc.py | 290 -- .../event_service/transports/grpc_asyncio.py | 289 -- .../services/job_service/__init__.py | 22 - .../services/job_service/async_client.py | 1476 ------ .../services/job_service/client.py | 1668 ------- .../services/job_service/pagers.py | 382 -- .../job_service/transports/__init__.py | 33 - .../services/job_service/transports/base.py | 322 -- .../services/job_service/transports/grpc.py | 567 --- .../job_service/transports/grpc_asyncio.py | 566 --- .../services/tenant_service/__init__.py | 22 - .../services/tenant_service/async_client.py | 829 ---- .../services/tenant_service/client.py | 1010 ---- .../services/tenant_service/pagers.py | 140 - .../tenant_service/transports/__init__.py | 33 - .../tenant_service/transports/base.py | 245 - .../tenant_service/transports/grpc.py | 391 -- .../tenant_service/transports/grpc_asyncio.py | 390 -- .../cloud/talent_v4beta1/types/__init__.py | 158 - .../cloud/talent_v4beta1/types/batch.py | 25 - .../cloud/talent_v4beta1/types/common.py | 846 ---- .../cloud/talent_v4beta1/types/company.py | 178 - .../talent_v4beta1/types/company_service.py | 222 - .../types/completion_service.py | 169 - .../cloud/talent_v4beta1/types/event.py | 155 - .../talent_v4beta1/types/event_service.py | 58 - .../cloud/talent_v4beta1/types/filters.py | 511 -- .../cloud/talent_v4beta1/types/histogram.py | 84 - .../google/cloud/talent_v4beta1/types/job.py | 567 --- .../cloud/talent_v4beta1/types/job_service.py | 1110 ----- .../cloud/talent_v4beta1/types/tenant.py | 91 - .../talent_v4beta1/types/tenant_service.py | 194 - owl-bot-staging/v4beta1/mypy.ini | 3 - owl-bot-staging/v4beta1/noxfile.py | 179 - ...ed_company_service_create_company_async.py | 57 - ...ted_company_service_create_company_sync.py | 57 - ...ed_company_service_delete_company_async.py | 50 - ...ted_company_service_delete_company_sync.py | 50 - ...rated_company_service_get_company_async.py | 52 - ...erated_company_service_get_company_sync.py | 52 - ...ed_company_service_list_companies_async.py | 53 - ...ted_company_service_list_companies_sync.py | 53 - ...ed_company_service_update_company_async.py | 56 - ...ted_company_service_update_company_sync.py | 56 - ...nerated_completion_complete_query_async.py | 54 - ...enerated_completion_complete_query_sync.py | 54 - ...event_service_create_client_event_async.py | 58 - ..._event_service_create_client_event_sync.py | 58 - ...ted_job_service_batch_create_jobs_async.py | 63 - ...ated_job_service_batch_create_jobs_sync.py | 63 - ...ted_job_service_batch_delete_jobs_async.py | 51 - ...ated_job_service_batch_delete_jobs_sync.py | 51 - ...ted_job_service_batch_update_jobs_async.py | 63 - ...ated_job_service_batch_update_jobs_sync.py | 63 - ..._generated_job_service_create_job_async.py | 59 - ...1_generated_job_service_create_job_sync.py | 59 - ..._generated_job_service_delete_job_async.py | 50 - ...1_generated_job_service_delete_job_sync.py | 50 - ...ta1_generated_job_service_get_job_async.py | 52 - ...eta1_generated_job_service_get_job_sync.py | 52 - ...1_generated_job_service_list_jobs_async.py | 54 - ...a1_generated_job_service_list_jobs_sync.py | 54 - ...generated_job_service_search_jobs_async.py | 53 - ...job_service_search_jobs_for_alert_async.py | 53 - ..._job_service_search_jobs_for_alert_sync.py | 53 - ..._generated_job_service_search_jobs_sync.py | 53 - ..._generated_job_service_update_job_async.py | 58 - ...1_generated_job_service_update_job_sync.py | 58 - ...ated_tenant_service_create_tenant_async.py | 56 - ...rated_tenant_service_create_tenant_sync.py | 56 - ...ated_tenant_service_delete_tenant_async.py | 50 - ...rated_tenant_service_delete_tenant_sync.py | 50 - ...nerated_tenant_service_get_tenant_async.py | 52 - ...enerated_tenant_service_get_tenant_sync.py | 52 - ...rated_tenant_service_list_tenants_async.py | 53 - ...erated_tenant_service_list_tenants_sync.py | 53 - ...ated_tenant_service_update_tenant_async.py | 55 - ...rated_tenant_service_update_tenant_sync.py | 55 - .../snippet_metadata_talent_v4beta1.json | 3572 -------------- .../scripts/fixup_talent_v4beta1_keywords.py | 197 - owl-bot-staging/v4beta1/setup.py | 58 - owl-bot-staging/v4beta1/tests/__init__.py | 16 - .../v4beta1/tests/unit/__init__.py | 16 - .../v4beta1/tests/unit/gapic/__init__.py | 16 - .../unit/gapic/talent_v4beta1/__init__.py | 16 - .../talent_v4beta1/test_company_service.py | 2789 ----------- .../gapic/talent_v4beta1/test_completion.py | 1440 ------ .../talent_v4beta1/test_event_service.py | 1546 ------ .../gapic/talent_v4beta1/test_job_service.py | 4375 ----------------- .../talent_v4beta1/test_tenant_service.py | 2688 ---------- ...ed_company_service_create_company_async.py | 7 + ...ted_company_service_create_company_sync.py | 7 + ...ed_company_service_delete_company_async.py | 7 + ...ted_company_service_delete_company_sync.py | 7 + ...rated_company_service_get_company_async.py | 7 + ...erated_company_service_get_company_sync.py | 7 + ...ed_company_service_list_companies_async.py | 7 + ...ted_company_service_list_companies_sync.py | 7 + ...ed_company_service_update_company_async.py | 7 + ...ted_company_service_update_company_sync.py | 7 + ...nerated_completion_complete_query_async.py | 7 + ...enerated_completion_complete_query_sync.py | 7 + ...event_service_create_client_event_async.py | 9 +- ..._event_service_create_client_event_sync.py | 9 +- ...ted_job_service_batch_create_jobs_async.py | 7 + ...ated_job_service_batch_create_jobs_sync.py | 7 + ...ted_job_service_batch_delete_jobs_async.py | 7 + ...ated_job_service_batch_delete_jobs_sync.py | 7 + ...ted_job_service_batch_update_jobs_async.py | 7 + ...ated_job_service_batch_update_jobs_sync.py | 7 + ..._generated_job_service_create_job_async.py | 7 + ...4_generated_job_service_create_job_sync.py | 7 + ..._generated_job_service_delete_job_async.py | 7 + ...4_generated_job_service_delete_job_sync.py | 7 + ..._v4_generated_job_service_get_job_async.py | 7 + ...s_v4_generated_job_service_get_job_sync.py | 7 + ...4_generated_job_service_list_jobs_async.py | 7 + ...v4_generated_job_service_list_jobs_sync.py | 7 + ...generated_job_service_search_jobs_async.py | 7 + ...job_service_search_jobs_for_alert_async.py | 7 + ..._job_service_search_jobs_for_alert_sync.py | 7 + ..._generated_job_service_search_jobs_sync.py | 7 + ..._generated_job_service_update_job_async.py | 7 + ...4_generated_job_service_update_job_sync.py | 7 + ...ated_tenant_service_create_tenant_async.py | 7 + ...rated_tenant_service_create_tenant_sync.py | 7 + ...ated_tenant_service_delete_tenant_async.py | 7 + ...rated_tenant_service_delete_tenant_sync.py | 7 + ...nerated_tenant_service_get_tenant_async.py | 7 + ...enerated_tenant_service_get_tenant_sync.py | 7 + ...rated_tenant_service_list_tenants_async.py | 7 + ...erated_tenant_service_list_tenants_sync.py | 7 + ...ated_tenant_service_update_tenant_async.py | 7 + ...rated_tenant_service_update_tenant_sync.py | 7 + ...ed_company_service_create_company_async.py | 7 + ...ted_company_service_create_company_sync.py | 7 + ...ed_company_service_delete_company_async.py | 7 + ...ted_company_service_delete_company_sync.py | 7 + ...rated_company_service_get_company_async.py | 7 + ...erated_company_service_get_company_sync.py | 7 + ...ed_company_service_list_companies_async.py | 7 + ...ted_company_service_list_companies_sync.py | 7 + ...ed_company_service_update_company_async.py | 7 + ...ted_company_service_update_company_sync.py | 7 + ...nerated_completion_complete_query_async.py | 7 + ...enerated_completion_complete_query_sync.py | 7 + ...event_service_create_client_event_async.py | 9 +- ..._event_service_create_client_event_sync.py | 9 +- ...ted_job_service_batch_create_jobs_async.py | 7 + ...ated_job_service_batch_create_jobs_sync.py | 7 + ...ted_job_service_batch_delete_jobs_async.py | 7 + ...ated_job_service_batch_delete_jobs_sync.py | 7 + ...ted_job_service_batch_update_jobs_async.py | 7 + ...ated_job_service_batch_update_jobs_sync.py | 7 + ..._generated_job_service_create_job_async.py | 7 + ...1_generated_job_service_create_job_sync.py | 7 + ..._generated_job_service_delete_job_async.py | 7 + ...1_generated_job_service_delete_job_sync.py | 7 + ...ta1_generated_job_service_get_job_async.py | 7 + ...eta1_generated_job_service_get_job_sync.py | 7 + ...1_generated_job_service_list_jobs_async.py | 7 + ...a1_generated_job_service_list_jobs_sync.py | 7 + ...generated_job_service_search_jobs_async.py | 7 + ...job_service_search_jobs_for_alert_async.py | 7 + ..._job_service_search_jobs_for_alert_sync.py | 7 + ..._generated_job_service_search_jobs_sync.py | 7 + ..._generated_job_service_update_job_async.py | 7 + ...1_generated_job_service_update_job_sync.py | 7 + ...ated_tenant_service_create_tenant_async.py | 7 + ...rated_tenant_service_create_tenant_sync.py | 7 + ...ated_tenant_service_delete_tenant_async.py | 7 + ...rated_tenant_service_delete_tenant_sync.py | 7 + ...nerated_tenant_service_get_tenant_async.py | 7 + ...enerated_tenant_service_get_tenant_sync.py | 7 + ...rated_tenant_service_list_tenants_async.py | 7 + ...erated_tenant_service_list_tenants_sync.py | 7 + ...ated_tenant_service_update_tenant_async.py | 7 + ...rated_tenant_service_update_tenant_sync.py | 7 + .../snippet_metadata_talent_v4.json | 856 ++-- .../snippet_metadata_talent_v4beta1.json | 848 ++-- 368 files changed, 2093 insertions(+), 77988 deletions(-) delete mode 100644 owl-bot-staging/v4/.coveragerc delete mode 100644 owl-bot-staging/v4/.flake8 delete mode 100644 owl-bot-staging/v4/MANIFEST.in delete mode 100644 owl-bot-staging/v4/README.rst delete mode 100644 owl-bot-staging/v4/docs/conf.py delete mode 100644 owl-bot-staging/v4/docs/index.rst delete mode 100644 owl-bot-staging/v4/docs/talent_v4/company_service.rst delete mode 100644 owl-bot-staging/v4/docs/talent_v4/completion.rst delete mode 100644 owl-bot-staging/v4/docs/talent_v4/event_service.rst delete mode 100644 owl-bot-staging/v4/docs/talent_v4/job_service.rst delete mode 100644 owl-bot-staging/v4/docs/talent_v4/services.rst delete mode 100644 owl-bot-staging/v4/docs/talent_v4/tenant_service.rst delete mode 100644 owl-bot-staging/v4/docs/talent_v4/types.rst delete mode 100644 owl-bot-staging/v4/google/cloud/talent/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent/py.typed delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/gapic_metadata.json delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/py.typed delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/async_client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/pagers.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/base.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/async_client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/base.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/async_client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/base.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/async_client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/pagers.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/base.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/async_client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/client.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/pagers.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/base.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/__init__.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/common.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/company.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/company_service.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/completion_service.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/event.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/event_service.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/filters.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/histogram.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/job.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/job_service.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/tenant.py delete mode 100644 owl-bot-staging/v4/google/cloud/talent_v4/types/tenant_service.py delete mode 100644 owl-bot-staging/v4/mypy.ini delete mode 100644 owl-bot-staging/v4/noxfile.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py delete mode 100644 owl-bot-staging/v4/samples/generated_samples/snippet_metadata_talent_v4.json delete mode 100644 owl-bot-staging/v4/scripts/fixup_talent_v4_keywords.py delete mode 100644 owl-bot-staging/v4/setup.py delete mode 100644 owl-bot-staging/v4/tests/__init__.py delete mode 100644 owl-bot-staging/v4/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v4/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/__init__.py delete mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_company_service.py delete mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_completion.py delete mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_event_service.py delete mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_job_service.py delete mode 100644 owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_tenant_service.py delete mode 100644 owl-bot-staging/v4beta1/.coveragerc delete mode 100644 owl-bot-staging/v4beta1/.flake8 delete mode 100644 owl-bot-staging/v4beta1/MANIFEST.in delete mode 100644 owl-bot-staging/v4beta1/README.rst delete mode 100644 owl-bot-staging/v4beta1/docs/conf.py delete mode 100644 owl-bot-staging/v4beta1/docs/index.rst delete mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/company_service.rst delete mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/completion.rst delete mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/event_service.rst delete mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/job_service.rst delete mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/services.rst delete mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/tenant_service.rst delete mode 100644 owl-bot-staging/v4beta1/docs/talent_v4beta1/types.rst delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent/py.typed delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/py.typed delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/async_client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/pagers.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/base.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/async_client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/base.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/async_client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/base.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/async_client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/pagers.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/base.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/async_client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/client.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/pagers.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/__init__.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/batch.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/common.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company_service.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/completion_service.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event_service.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/filters.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/histogram.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job_service.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant.py delete mode 100644 owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant_service.py delete mode 100644 owl-bot-staging/v4beta1/mypy.ini delete mode 100644 owl-bot-staging/v4beta1/noxfile.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py delete mode 100644 owl-bot-staging/v4beta1/samples/generated_samples/snippet_metadata_talent_v4beta1.json delete mode 100644 owl-bot-staging/v4beta1/scripts/fixup_talent_v4beta1_keywords.py delete mode 100644 owl-bot-staging/v4beta1/setup.py delete mode 100644 owl-bot-staging/v4beta1/tests/__init__.py delete mode 100644 owl-bot-staging/v4beta1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/__init__.py delete mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_company_service.py delete mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_completion.py delete mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_event_service.py delete mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_job_service.py delete mode 100644 owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_tenant_service.py diff --git a/google/cloud/talent_v4/services/company_service/async_client.py b/google/cloud/talent_v4/services/company_service/async_client.py index a33ed454..79a15383 100644 --- a/google/cloud/talent_v4/services/company_service/async_client.py +++ b/google/cloud/talent_v4/services/company_service/async_client.py @@ -226,6 +226,13 @@ async def create_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_create_company(): @@ -341,6 +348,13 @@ async def get_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_get_company(): @@ -456,6 +470,13 @@ async def update_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_update_company(): @@ -582,6 +603,13 @@ async def delete_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_delete_company(): @@ -678,6 +706,13 @@ async def list_companies( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_list_companies(): diff --git a/google/cloud/talent_v4/services/company_service/client.py b/google/cloud/talent_v4/services/company_service/client.py index 21cfa1f7..30f251f9 100644 --- a/google/cloud/talent_v4/services/company_service/client.py +++ b/google/cloud/talent_v4/services/company_service/client.py @@ -466,6 +466,13 @@ def create_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_create_company(): @@ -581,6 +588,13 @@ def get_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_get_company(): @@ -686,6 +700,13 @@ def update_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_update_company(): @@ -812,6 +833,13 @@ def delete_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_delete_company(): @@ -898,6 +926,13 @@ def list_companies( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_list_companies(): diff --git a/google/cloud/talent_v4/services/completion/async_client.py b/google/cloud/talent_v4/services/completion/async_client.py index 1ae67f96..025e803e 100644 --- a/google/cloud/talent_v4/services/completion/async_client.py +++ b/google/cloud/talent_v4/services/completion/async_client.py @@ -212,6 +212,13 @@ async def complete_query( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_complete_query(): diff --git a/google/cloud/talent_v4/services/completion/client.py b/google/cloud/talent_v4/services/completion/client.py index 15a382d2..bf7b5886 100644 --- a/google/cloud/talent_v4/services/completion/client.py +++ b/google/cloud/talent_v4/services/completion/client.py @@ -456,6 +456,13 @@ def complete_query( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_complete_query(): diff --git a/google/cloud/talent_v4/services/event_service/async_client.py b/google/cloud/talent_v4/services/event_service/async_client.py index bc74ed49..071bab49 100644 --- a/google/cloud/talent_v4/services/event_service/async_client.py +++ b/google/cloud/talent_v4/services/event_service/async_client.py @@ -220,6 +220,13 @@ async def create_client_event( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_create_client_event(): @@ -229,7 +236,7 @@ async def sample_create_client_event(): # Initialize request argument(s) client_event = talent_v4.ClientEvent() client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value_1', 'jobs_value_2'] + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] client_event.event_id = "event_id_value" request = talent_v4.CreateClientEventRequest( diff --git a/google/cloud/talent_v4/services/event_service/client.py b/google/cloud/talent_v4/services/event_service/client.py index 834d5df3..720f3772 100644 --- a/google/cloud/talent_v4/services/event_service/client.py +++ b/google/cloud/talent_v4/services/event_service/client.py @@ -442,6 +442,13 @@ def create_client_event( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_create_client_event(): @@ -451,7 +458,7 @@ def sample_create_client_event(): # Initialize request argument(s) client_event = talent_v4.ClientEvent() client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value_1', 'jobs_value_2'] + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] client_event.event_id = "event_id_value" request = talent_v4.CreateClientEventRequest( diff --git a/google/cloud/talent_v4/services/job_service/async_client.py b/google/cloud/talent_v4/services/job_service/async_client.py index 5ee005b6..30b5dd8d 100644 --- a/google/cloud/talent_v4/services/job_service/async_client.py +++ b/google/cloud/talent_v4/services/job_service/async_client.py @@ -227,6 +227,13 @@ async def create_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_create_job(): @@ -342,6 +349,13 @@ async def batch_create_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_batch_create_jobs(): @@ -474,6 +488,13 @@ async def get_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_get_job(): @@ -587,6 +608,13 @@ async def update_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_update_job(): @@ -706,6 +734,13 @@ async def batch_update_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_batch_update_jobs(): @@ -839,6 +874,13 @@ async def delete_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_delete_job(): @@ -935,6 +977,13 @@ async def batch_delete_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_batch_delete_jobs(): @@ -1067,6 +1116,13 @@ async def list_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_list_jobs(): @@ -1227,6 +1283,13 @@ async def search_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_search_jobs(): @@ -1310,6 +1373,13 @@ async def search_jobs_for_alert( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_search_jobs_for_alert(): diff --git a/google/cloud/talent_v4/services/job_service/client.py b/google/cloud/talent_v4/services/job_service/client.py index 07e78755..1f50aa2c 100644 --- a/google/cloud/talent_v4/services/job_service/client.py +++ b/google/cloud/talent_v4/services/job_service/client.py @@ -491,6 +491,13 @@ def create_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_create_job(): @@ -606,6 +613,13 @@ def batch_create_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_batch_create_jobs(): @@ -738,6 +752,13 @@ def get_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_get_job(): @@ -841,6 +862,13 @@ def update_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_update_job(): @@ -960,6 +988,13 @@ def batch_update_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_batch_update_jobs(): @@ -1093,6 +1128,13 @@ def delete_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_delete_job(): @@ -1179,6 +1221,13 @@ def batch_delete_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_batch_delete_jobs(): @@ -1311,6 +1360,13 @@ def list_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_list_jobs(): @@ -1461,6 +1517,13 @@ def search_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_search_jobs(): @@ -1545,6 +1608,13 @@ def search_jobs_for_alert( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_search_jobs_for_alert(): diff --git a/google/cloud/talent_v4/services/tenant_service/async_client.py b/google/cloud/talent_v4/services/tenant_service/async_client.py index b127f7d3..a10115b8 100644 --- a/google/cloud/talent_v4/services/tenant_service/async_client.py +++ b/google/cloud/talent_v4/services/tenant_service/async_client.py @@ -223,6 +223,13 @@ async def create_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_create_tenant(): @@ -337,6 +344,13 @@ async def get_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_get_tenant(): @@ -452,6 +466,13 @@ async def update_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_update_tenant(): @@ -576,6 +597,13 @@ async def delete_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_delete_tenant(): @@ -671,6 +699,13 @@ async def list_tenants( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 async def sample_list_tenants(): diff --git a/google/cloud/talent_v4/services/tenant_service/client.py b/google/cloud/talent_v4/services/tenant_service/client.py index 432fa236..3f184867 100644 --- a/google/cloud/talent_v4/services/tenant_service/client.py +++ b/google/cloud/talent_v4/services/tenant_service/client.py @@ -441,6 +441,13 @@ def create_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_create_tenant(): @@ -555,6 +562,13 @@ def get_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_get_tenant(): @@ -660,6 +674,13 @@ def update_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_update_tenant(): @@ -784,6 +805,13 @@ def delete_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_delete_tenant(): @@ -869,6 +897,13 @@ def list_tenants( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 def sample_list_tenants(): 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 e82f7dc3..50bc8e1f 100644 --- a/google/cloud/talent_v4beta1/services/company_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/company_service/async_client.py @@ -224,6 +224,13 @@ async def create_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_create_company(): @@ -341,6 +348,13 @@ async def get_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_get_company(): @@ -458,6 +472,13 @@ async def update_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_update_company(): @@ -566,6 +587,13 @@ async def delete_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_delete_company(): @@ -665,6 +693,13 @@ async def list_companies( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_list_companies(): diff --git a/google/cloud/talent_v4beta1/services/company_service/client.py b/google/cloud/talent_v4beta1/services/company_service/client.py index d085647e..00aacd40 100644 --- a/google/cloud/talent_v4beta1/services/company_service/client.py +++ b/google/cloud/talent_v4beta1/services/company_service/client.py @@ -449,6 +449,13 @@ def create_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_create_company(): @@ -566,6 +573,13 @@ def get_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_get_company(): @@ -673,6 +687,13 @@ def update_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_update_company(): @@ -781,6 +802,13 @@ def delete_company( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_delete_company(): @@ -870,6 +898,13 @@ def list_companies( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_list_companies(): diff --git a/google/cloud/talent_v4beta1/services/completion/async_client.py b/google/cloud/talent_v4beta1/services/completion/async_client.py index c8c6c1c5..3214971a 100644 --- a/google/cloud/talent_v4beta1/services/completion/async_client.py +++ b/google/cloud/talent_v4beta1/services/completion/async_client.py @@ -212,6 +212,13 @@ async def complete_query( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_complete_query(): diff --git a/google/cloud/talent_v4beta1/services/completion/client.py b/google/cloud/talent_v4beta1/services/completion/client.py index 190bda85..e47f291a 100644 --- a/google/cloud/talent_v4beta1/services/completion/client.py +++ b/google/cloud/talent_v4beta1/services/completion/client.py @@ -441,6 +441,13 @@ def complete_query( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_complete_query(): 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 1dd41df2..263215bb 100644 --- a/google/cloud/talent_v4beta1/services/event_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/event_service/async_client.py @@ -221,6 +221,13 @@ async def create_client_event( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_create_client_event(): @@ -230,7 +237,7 @@ async def sample_create_client_event(): # Initialize request argument(s) client_event = talent_v4beta1.ClientEvent() client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value_1', 'jobs_value_2'] + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] client_event.event_id = "event_id_value" request = talent_v4beta1.CreateClientEventRequest( diff --git a/google/cloud/talent_v4beta1/services/event_service/client.py b/google/cloud/talent_v4beta1/services/event_service/client.py index a9f42e74..88c96b8f 100644 --- a/google/cloud/talent_v4beta1/services/event_service/client.py +++ b/google/cloud/talent_v4beta1/services/event_service/client.py @@ -448,6 +448,13 @@ def create_client_event( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_create_client_event(): @@ -457,7 +464,7 @@ def sample_create_client_event(): # Initialize request argument(s) client_event = talent_v4beta1.ClientEvent() client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value_1', 'jobs_value_2'] + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] client_event.event_id = "event_id_value" request = talent_v4beta1.CreateClientEventRequest( 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 48a59d43..7031d3a8 100644 --- a/google/cloud/talent_v4beta1/services/job_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/job_service/async_client.py @@ -225,6 +225,13 @@ async def create_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_create_job(): @@ -342,6 +349,13 @@ async def batch_create_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_batch_create_jobs(): @@ -474,6 +488,13 @@ async def get_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_get_job(): @@ -589,6 +610,13 @@ async def update_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_update_job(): @@ -690,6 +718,13 @@ async def batch_update_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_batch_update_jobs(): @@ -823,6 +858,13 @@ async def delete_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_delete_job(): @@ -923,6 +965,13 @@ async def batch_delete_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_batch_delete_jobs(): @@ -1032,6 +1081,13 @@ async def list_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_list_jobs(): @@ -1194,6 +1250,13 @@ async def search_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_search_jobs(): @@ -1291,6 +1354,13 @@ async def search_jobs_for_alert( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_search_jobs_for_alert(): diff --git a/google/cloud/talent_v4beta1/services/job_service/client.py b/google/cloud/talent_v4beta1/services/job_service/client.py index cb861532..6decd233 100644 --- a/google/cloud/talent_v4beta1/services/job_service/client.py +++ b/google/cloud/talent_v4beta1/services/job_service/client.py @@ -474,6 +474,13 @@ def create_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_create_job(): @@ -591,6 +598,13 @@ def batch_create_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_batch_create_jobs(): @@ -723,6 +737,13 @@ def get_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_get_job(): @@ -828,6 +849,13 @@ def update_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_update_job(): @@ -929,6 +957,13 @@ def batch_update_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_batch_update_jobs(): @@ -1062,6 +1097,13 @@ def delete_job( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_delete_job(): @@ -1152,6 +1194,13 @@ def batch_delete_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_batch_delete_jobs(): @@ -1261,6 +1310,13 @@ def list_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_list_jobs(): @@ -1413,6 +1469,13 @@ def search_jobs( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_search_jobs(): @@ -1511,6 +1574,13 @@ def search_jobs_for_alert( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_search_jobs_for_alert(): 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 2aa180ba..ae552a49 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/async_client.py @@ -223,6 +223,13 @@ async def create_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_create_tenant(): @@ -337,6 +344,13 @@ async def get_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_get_tenant(): @@ -451,6 +465,13 @@ async def update_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_update_tenant(): @@ -557,6 +578,13 @@ async def delete_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_delete_tenant(): @@ -652,6 +680,13 @@ async def list_tenants( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 async def sample_list_tenants(): diff --git a/google/cloud/talent_v4beta1/services/tenant_service/client.py b/google/cloud/talent_v4beta1/services/tenant_service/client.py index 5880415c..1d11f27e 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/client.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/client.py @@ -441,6 +441,13 @@ def create_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_create_tenant(): @@ -555,6 +562,13 @@ def get_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_get_tenant(): @@ -659,6 +673,13 @@ def update_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_update_tenant(): @@ -765,6 +786,13 @@ def delete_tenant( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_delete_tenant(): @@ -850,6 +878,13 @@ def list_tenants( .. code-block:: python + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 def sample_list_tenants(): diff --git a/mypy.ini b/mypy.ini index 4505b485..574c5aed 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,3 +1,3 @@ [mypy] -python_version = 3.6 +python_version = 3.7 namespace_packages = True diff --git a/owl-bot-staging/v4/.coveragerc b/owl-bot-staging/v4/.coveragerc deleted file mode 100644 index 4ad22152..00000000 --- a/owl-bot-staging/v4/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/talent/__init__.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v4/.flake8 b/owl-bot-staging/v4/.flake8 deleted file mode 100644 index 29227d4c..00000000 --- a/owl-bot-staging/v4/.flake8 +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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 by synthtool. DO NOT EDIT! -[flake8] -ignore = E203, E266, E501, W503 -exclude = - # Exclude generated code. - **/proto/** - **/gapic/** - **/services/** - **/types/** - *_pb2.py - - # Standard linting exemptions. - **/.nox/** - __pycache__, - .git, - *.pyc, - conf.py diff --git a/owl-bot-staging/v4/MANIFEST.in b/owl-bot-staging/v4/MANIFEST.in deleted file mode 100644 index 54dfff12..00000000 --- a/owl-bot-staging/v4/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/talent *.py -recursive-include google/cloud/talent_v4 *.py diff --git a/owl-bot-staging/v4/README.rst b/owl-bot-staging/v4/README.rst deleted file mode 100644 index 97bb9aff..00000000 --- a/owl-bot-staging/v4/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Talent API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Talent API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v4/docs/conf.py b/owl-bot-staging/v4/docs/conf.py deleted file mode 100644 index 3dd2f845..00000000 --- a/owl-bot-staging/v4/docs/conf.py +++ /dev/null @@ -1,376 +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. -# -# -# google-cloud-talent documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "4.0.1" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The root toctree document. -root_doc = "index" - -# General information about the project. -project = u"google-cloud-talent" -copyright = u"2022, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-talent-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - root_doc, - "google-cloud-talent.tex", - u"google-cloud-talent Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - root_doc, - "google-cloud-talent", - u"Google Cloud Talent Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - root_doc, - "google-cloud-talent", - u"google-cloud-talent Documentation", - author, - "google-cloud-talent", - "GAPIC library for Google Cloud Talent API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/v4/docs/index.rst b/owl-bot-staging/v4/docs/index.rst deleted file mode 100644 index 0390203e..00000000 --- a/owl-bot-staging/v4/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - talent_v4/services - talent_v4/types diff --git a/owl-bot-staging/v4/docs/talent_v4/company_service.rst b/owl-bot-staging/v4/docs/talent_v4/company_service.rst deleted file mode 100644 index 7d9acfc3..00000000 --- a/owl-bot-staging/v4/docs/talent_v4/company_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -CompanyService --------------------------------- - -.. automodule:: google.cloud.talent_v4.services.company_service - :members: - :inherited-members: - -.. automodule:: google.cloud.talent_v4.services.company_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/completion.rst b/owl-bot-staging/v4/docs/talent_v4/completion.rst deleted file mode 100644 index 3044c5a8..00000000 --- a/owl-bot-staging/v4/docs/talent_v4/completion.rst +++ /dev/null @@ -1,6 +0,0 @@ -Completion ----------------------------- - -.. automodule:: google.cloud.talent_v4.services.completion - :members: - :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/event_service.rst b/owl-bot-staging/v4/docs/talent_v4/event_service.rst deleted file mode 100644 index 1c90bae1..00000000 --- a/owl-bot-staging/v4/docs/talent_v4/event_service.rst +++ /dev/null @@ -1,6 +0,0 @@ -EventService ------------------------------- - -.. automodule:: google.cloud.talent_v4.services.event_service - :members: - :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/job_service.rst b/owl-bot-staging/v4/docs/talent_v4/job_service.rst deleted file mode 100644 index d8824847..00000000 --- a/owl-bot-staging/v4/docs/talent_v4/job_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -JobService ----------------------------- - -.. automodule:: google.cloud.talent_v4.services.job_service - :members: - :inherited-members: - -.. automodule:: google.cloud.talent_v4.services.job_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/services.rst b/owl-bot-staging/v4/docs/talent_v4/services.rst deleted file mode 100644 index b2eb192c..00000000 --- a/owl-bot-staging/v4/docs/talent_v4/services.rst +++ /dev/null @@ -1,10 +0,0 @@ -Services for Google Cloud Talent v4 API -======================================= -.. toctree:: - :maxdepth: 2 - - company_service - completion - event_service - job_service - tenant_service diff --git a/owl-bot-staging/v4/docs/talent_v4/tenant_service.rst b/owl-bot-staging/v4/docs/talent_v4/tenant_service.rst deleted file mode 100644 index 26f09b23..00000000 --- a/owl-bot-staging/v4/docs/talent_v4/tenant_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -TenantService -------------------------------- - -.. automodule:: google.cloud.talent_v4.services.tenant_service - :members: - :inherited-members: - -.. automodule:: google.cloud.talent_v4.services.tenant_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v4/docs/talent_v4/types.rst b/owl-bot-staging/v4/docs/talent_v4/types.rst deleted file mode 100644 index 9c08edc9..00000000 --- a/owl-bot-staging/v4/docs/talent_v4/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Talent v4 API -==================================== - -.. automodule:: google.cloud.talent_v4.types - :members: - :undoc-members: - :show-inheritance: diff --git a/owl-bot-staging/v4/google/cloud/talent/__init__.py b/owl-bot-staging/v4/google/cloud/talent/__init__.py deleted file mode 100644 index 8ba93499..00000000 --- a/owl-bot-staging/v4/google/cloud/talent/__init__.py +++ /dev/null @@ -1,161 +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.cloud.talent_v4.services.company_service.client import CompanyServiceClient -from google.cloud.talent_v4.services.company_service.async_client import CompanyServiceAsyncClient -from google.cloud.talent_v4.services.completion.client import CompletionClient -from google.cloud.talent_v4.services.completion.async_client import CompletionAsyncClient -from google.cloud.talent_v4.services.event_service.client import EventServiceClient -from google.cloud.talent_v4.services.event_service.async_client import EventServiceAsyncClient -from google.cloud.talent_v4.services.job_service.client import JobServiceClient -from google.cloud.talent_v4.services.job_service.async_client import JobServiceAsyncClient -from google.cloud.talent_v4.services.tenant_service.client import TenantServiceClient -from google.cloud.talent_v4.services.tenant_service.async_client import TenantServiceAsyncClient - -from google.cloud.talent_v4.types.common import BatchOperationMetadata -from google.cloud.talent_v4.types.common import CompensationInfo -from google.cloud.talent_v4.types.common import CustomAttribute -from google.cloud.talent_v4.types.common import DeviceInfo -from google.cloud.talent_v4.types.common import Location -from google.cloud.talent_v4.types.common import RequestMetadata -from google.cloud.talent_v4.types.common import ResponseMetadata -from google.cloud.talent_v4.types.common import SpellingCorrection -from google.cloud.talent_v4.types.common import TimestampRange -from google.cloud.talent_v4.types.common import CommuteMethod -from google.cloud.talent_v4.types.common import CompanySize -from google.cloud.talent_v4.types.common import DegreeType -from google.cloud.talent_v4.types.common import EmploymentType -from google.cloud.talent_v4.types.common import HtmlSanitization -from google.cloud.talent_v4.types.common import JobBenefit -from google.cloud.talent_v4.types.common import JobCategory -from google.cloud.talent_v4.types.common import JobLevel -from google.cloud.talent_v4.types.common import PostingRegion -from google.cloud.talent_v4.types.common import Visibility -from google.cloud.talent_v4.types.company import Company -from google.cloud.talent_v4.types.company_service import CreateCompanyRequest -from google.cloud.talent_v4.types.company_service import DeleteCompanyRequest -from google.cloud.talent_v4.types.company_service import GetCompanyRequest -from google.cloud.talent_v4.types.company_service import ListCompaniesRequest -from google.cloud.talent_v4.types.company_service import ListCompaniesResponse -from google.cloud.talent_v4.types.company_service import UpdateCompanyRequest -from google.cloud.talent_v4.types.completion_service import CompleteQueryRequest -from google.cloud.talent_v4.types.completion_service import CompleteQueryResponse -from google.cloud.talent_v4.types.event import ClientEvent -from google.cloud.talent_v4.types.event import JobEvent -from google.cloud.talent_v4.types.event_service import CreateClientEventRequest -from google.cloud.talent_v4.types.filters import CommuteFilter -from google.cloud.talent_v4.types.filters import CompensationFilter -from google.cloud.talent_v4.types.filters import JobQuery -from google.cloud.talent_v4.types.filters import LocationFilter -from google.cloud.talent_v4.types.histogram import HistogramQuery -from google.cloud.talent_v4.types.histogram import HistogramQueryResult -from google.cloud.talent_v4.types.job import Job -from google.cloud.talent_v4.types.job_service import BatchCreateJobsRequest -from google.cloud.talent_v4.types.job_service import BatchCreateJobsResponse -from google.cloud.talent_v4.types.job_service import BatchDeleteJobsRequest -from google.cloud.talent_v4.types.job_service import BatchDeleteJobsResponse -from google.cloud.talent_v4.types.job_service import BatchUpdateJobsRequest -from google.cloud.talent_v4.types.job_service import BatchUpdateJobsResponse -from google.cloud.talent_v4.types.job_service import CreateJobRequest -from google.cloud.talent_v4.types.job_service import DeleteJobRequest -from google.cloud.talent_v4.types.job_service import GetJobRequest -from google.cloud.talent_v4.types.job_service import JobResult -from google.cloud.talent_v4.types.job_service import ListJobsRequest -from google.cloud.talent_v4.types.job_service import ListJobsResponse -from google.cloud.talent_v4.types.job_service import SearchJobsRequest -from google.cloud.talent_v4.types.job_service import SearchJobsResponse -from google.cloud.talent_v4.types.job_service import UpdateJobRequest -from google.cloud.talent_v4.types.job_service import JobView -from google.cloud.talent_v4.types.tenant import Tenant -from google.cloud.talent_v4.types.tenant_service import CreateTenantRequest -from google.cloud.talent_v4.types.tenant_service import DeleteTenantRequest -from google.cloud.talent_v4.types.tenant_service import GetTenantRequest -from google.cloud.talent_v4.types.tenant_service import ListTenantsRequest -from google.cloud.talent_v4.types.tenant_service import ListTenantsResponse -from google.cloud.talent_v4.types.tenant_service import UpdateTenantRequest - -__all__ = ('CompanyServiceClient', - 'CompanyServiceAsyncClient', - 'CompletionClient', - 'CompletionAsyncClient', - 'EventServiceClient', - 'EventServiceAsyncClient', - 'JobServiceClient', - 'JobServiceAsyncClient', - 'TenantServiceClient', - 'TenantServiceAsyncClient', - 'BatchOperationMetadata', - 'CompensationInfo', - 'CustomAttribute', - 'DeviceInfo', - 'Location', - 'RequestMetadata', - 'ResponseMetadata', - 'SpellingCorrection', - 'TimestampRange', - 'CommuteMethod', - 'CompanySize', - 'DegreeType', - 'EmploymentType', - 'HtmlSanitization', - 'JobBenefit', - 'JobCategory', - 'JobLevel', - 'PostingRegion', - 'Visibility', - 'Company', - 'CreateCompanyRequest', - 'DeleteCompanyRequest', - 'GetCompanyRequest', - 'ListCompaniesRequest', - 'ListCompaniesResponse', - 'UpdateCompanyRequest', - 'CompleteQueryRequest', - 'CompleteQueryResponse', - 'ClientEvent', - 'JobEvent', - 'CreateClientEventRequest', - 'CommuteFilter', - 'CompensationFilter', - 'JobQuery', - 'LocationFilter', - 'HistogramQuery', - 'HistogramQueryResult', - 'Job', - 'BatchCreateJobsRequest', - 'BatchCreateJobsResponse', - 'BatchDeleteJobsRequest', - 'BatchDeleteJobsResponse', - 'BatchUpdateJobsRequest', - 'BatchUpdateJobsResponse', - 'CreateJobRequest', - 'DeleteJobRequest', - 'GetJobRequest', - 'JobResult', - 'ListJobsRequest', - 'ListJobsResponse', - 'SearchJobsRequest', - 'SearchJobsResponse', - 'UpdateJobRequest', - 'JobView', - 'Tenant', - 'CreateTenantRequest', - 'DeleteTenantRequest', - 'GetTenantRequest', - 'ListTenantsRequest', - 'ListTenantsResponse', - 'UpdateTenantRequest', -) diff --git a/owl-bot-staging/v4/google/cloud/talent/py.typed b/owl-bot-staging/v4/google/cloud/talent/py.typed deleted file mode 100644 index d9645927..00000000 --- a/owl-bot-staging/v4/google/cloud/talent/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-talent package uses inline types. diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/__init__.py deleted file mode 100644 index cecc3ca5..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/__init__.py +++ /dev/null @@ -1,162 +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 .services.company_service import CompanyServiceClient -from .services.company_service import CompanyServiceAsyncClient -from .services.completion import CompletionClient -from .services.completion import CompletionAsyncClient -from .services.event_service import EventServiceClient -from .services.event_service import EventServiceAsyncClient -from .services.job_service import JobServiceClient -from .services.job_service import JobServiceAsyncClient -from .services.tenant_service import TenantServiceClient -from .services.tenant_service import TenantServiceAsyncClient - -from .types.common import BatchOperationMetadata -from .types.common import CompensationInfo -from .types.common import CustomAttribute -from .types.common import DeviceInfo -from .types.common import Location -from .types.common import RequestMetadata -from .types.common import ResponseMetadata -from .types.common import SpellingCorrection -from .types.common import TimestampRange -from .types.common import CommuteMethod -from .types.common import CompanySize -from .types.common import DegreeType -from .types.common import EmploymentType -from .types.common import HtmlSanitization -from .types.common import JobBenefit -from .types.common import JobCategory -from .types.common import JobLevel -from .types.common import PostingRegion -from .types.common import Visibility -from .types.company import Company -from .types.company_service import CreateCompanyRequest -from .types.company_service import DeleteCompanyRequest -from .types.company_service import GetCompanyRequest -from .types.company_service import ListCompaniesRequest -from .types.company_service import ListCompaniesResponse -from .types.company_service import UpdateCompanyRequest -from .types.completion_service import CompleteQueryRequest -from .types.completion_service import CompleteQueryResponse -from .types.event import ClientEvent -from .types.event import JobEvent -from .types.event_service import CreateClientEventRequest -from .types.filters import CommuteFilter -from .types.filters import CompensationFilter -from .types.filters import JobQuery -from .types.filters import LocationFilter -from .types.histogram import HistogramQuery -from .types.histogram import HistogramQueryResult -from .types.job import Job -from .types.job_service import BatchCreateJobsRequest -from .types.job_service import BatchCreateJobsResponse -from .types.job_service import BatchDeleteJobsRequest -from .types.job_service import BatchDeleteJobsResponse -from .types.job_service import BatchUpdateJobsRequest -from .types.job_service import BatchUpdateJobsResponse -from .types.job_service import CreateJobRequest -from .types.job_service import DeleteJobRequest -from .types.job_service import GetJobRequest -from .types.job_service import JobResult -from .types.job_service import ListJobsRequest -from .types.job_service import ListJobsResponse -from .types.job_service import SearchJobsRequest -from .types.job_service import SearchJobsResponse -from .types.job_service import UpdateJobRequest -from .types.job_service import JobView -from .types.tenant import Tenant -from .types.tenant_service import CreateTenantRequest -from .types.tenant_service import DeleteTenantRequest -from .types.tenant_service import GetTenantRequest -from .types.tenant_service import ListTenantsRequest -from .types.tenant_service import ListTenantsResponse -from .types.tenant_service import UpdateTenantRequest - -__all__ = ( - 'CompanyServiceAsyncClient', - 'CompletionAsyncClient', - 'EventServiceAsyncClient', - 'JobServiceAsyncClient', - 'TenantServiceAsyncClient', -'BatchCreateJobsRequest', -'BatchCreateJobsResponse', -'BatchDeleteJobsRequest', -'BatchDeleteJobsResponse', -'BatchOperationMetadata', -'BatchUpdateJobsRequest', -'BatchUpdateJobsResponse', -'ClientEvent', -'CommuteFilter', -'CommuteMethod', -'Company', -'CompanyServiceClient', -'CompanySize', -'CompensationFilter', -'CompensationInfo', -'CompleteQueryRequest', -'CompleteQueryResponse', -'CompletionClient', -'CreateClientEventRequest', -'CreateCompanyRequest', -'CreateJobRequest', -'CreateTenantRequest', -'CustomAttribute', -'DegreeType', -'DeleteCompanyRequest', -'DeleteJobRequest', -'DeleteTenantRequest', -'DeviceInfo', -'EmploymentType', -'EventServiceClient', -'GetCompanyRequest', -'GetJobRequest', -'GetTenantRequest', -'HistogramQuery', -'HistogramQueryResult', -'HtmlSanitization', -'Job', -'JobBenefit', -'JobCategory', -'JobEvent', -'JobLevel', -'JobQuery', -'JobResult', -'JobServiceClient', -'JobView', -'ListCompaniesRequest', -'ListCompaniesResponse', -'ListJobsRequest', -'ListJobsResponse', -'ListTenantsRequest', -'ListTenantsResponse', -'Location', -'LocationFilter', -'PostingRegion', -'RequestMetadata', -'ResponseMetadata', -'SearchJobsRequest', -'SearchJobsResponse', -'SpellingCorrection', -'Tenant', -'TenantServiceClient', -'TimestampRange', -'UpdateCompanyRequest', -'UpdateJobRequest', -'UpdateTenantRequest', -'Visibility', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/gapic_metadata.json b/owl-bot-staging/v4/google/cloud/talent_v4/gapic_metadata.json deleted file mode 100644 index 3396f471..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/gapic_metadata.json +++ /dev/null @@ -1,299 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.talent_v4", - "protoPackage": "google.cloud.talent.v4", - "schema": "1.0", - "services": { - "CompanyService": { - "clients": { - "grpc": { - "libraryClient": "CompanyServiceClient", - "rpcs": { - "CreateCompany": { - "methods": [ - "create_company" - ] - }, - "DeleteCompany": { - "methods": [ - "delete_company" - ] - }, - "GetCompany": { - "methods": [ - "get_company" - ] - }, - "ListCompanies": { - "methods": [ - "list_companies" - ] - }, - "UpdateCompany": { - "methods": [ - "update_company" - ] - } - } - }, - "grpc-async": { - "libraryClient": "CompanyServiceAsyncClient", - "rpcs": { - "CreateCompany": { - "methods": [ - "create_company" - ] - }, - "DeleteCompany": { - "methods": [ - "delete_company" - ] - }, - "GetCompany": { - "methods": [ - "get_company" - ] - }, - "ListCompanies": { - "methods": [ - "list_companies" - ] - }, - "UpdateCompany": { - "methods": [ - "update_company" - ] - } - } - } - } - }, - "Completion": { - "clients": { - "grpc": { - "libraryClient": "CompletionClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "complete_query" - ] - } - } - }, - "grpc-async": { - "libraryClient": "CompletionAsyncClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "complete_query" - ] - } - } - } - } - }, - "EventService": { - "clients": { - "grpc": { - "libraryClient": "EventServiceClient", - "rpcs": { - "CreateClientEvent": { - "methods": [ - "create_client_event" - ] - } - } - }, - "grpc-async": { - "libraryClient": "EventServiceAsyncClient", - "rpcs": { - "CreateClientEvent": { - "methods": [ - "create_client_event" - ] - } - } - } - } - }, - "JobService": { - "clients": { - "grpc": { - "libraryClient": "JobServiceClient", - "rpcs": { - "BatchCreateJobs": { - "methods": [ - "batch_create_jobs" - ] - }, - "BatchDeleteJobs": { - "methods": [ - "batch_delete_jobs" - ] - }, - "BatchUpdateJobs": { - "methods": [ - "batch_update_jobs" - ] - }, - "CreateJob": { - "methods": [ - "create_job" - ] - }, - "DeleteJob": { - "methods": [ - "delete_job" - ] - }, - "GetJob": { - "methods": [ - "get_job" - ] - }, - "ListJobs": { - "methods": [ - "list_jobs" - ] - }, - "SearchJobs": { - "methods": [ - "search_jobs" - ] - }, - "SearchJobsForAlert": { - "methods": [ - "search_jobs_for_alert" - ] - }, - "UpdateJob": { - "methods": [ - "update_job" - ] - } - } - }, - "grpc-async": { - "libraryClient": "JobServiceAsyncClient", - "rpcs": { - "BatchCreateJobs": { - "methods": [ - "batch_create_jobs" - ] - }, - "BatchDeleteJobs": { - "methods": [ - "batch_delete_jobs" - ] - }, - "BatchUpdateJobs": { - "methods": [ - "batch_update_jobs" - ] - }, - "CreateJob": { - "methods": [ - "create_job" - ] - }, - "DeleteJob": { - "methods": [ - "delete_job" - ] - }, - "GetJob": { - "methods": [ - "get_job" - ] - }, - "ListJobs": { - "methods": [ - "list_jobs" - ] - }, - "SearchJobs": { - "methods": [ - "search_jobs" - ] - }, - "SearchJobsForAlert": { - "methods": [ - "search_jobs_for_alert" - ] - }, - "UpdateJob": { - "methods": [ - "update_job" - ] - } - } - } - } - }, - "TenantService": { - "clients": { - "grpc": { - "libraryClient": "TenantServiceClient", - "rpcs": { - "CreateTenant": { - "methods": [ - "create_tenant" - ] - }, - "DeleteTenant": { - "methods": [ - "delete_tenant" - ] - }, - "GetTenant": { - "methods": [ - "get_tenant" - ] - }, - "ListTenants": { - "methods": [ - "list_tenants" - ] - }, - "UpdateTenant": { - "methods": [ - "update_tenant" - ] - } - } - }, - "grpc-async": { - "libraryClient": "TenantServiceAsyncClient", - "rpcs": { - "CreateTenant": { - "methods": [ - "create_tenant" - ] - }, - "DeleteTenant": { - "methods": [ - "delete_tenant" - ] - }, - "GetTenant": { - "methods": [ - "get_tenant" - ] - }, - "ListTenants": { - "methods": [ - "list_tenants" - ] - }, - "UpdateTenant": { - "methods": [ - "update_tenant" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/py.typed b/owl-bot-staging/v4/google/cloud/talent_v4/py.typed deleted file mode 100644 index d9645927..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-talent package uses inline types. diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/__init__.py deleted file mode 100644 index e8e1c384..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/__init__.py +++ /dev/null @@ -1,15 +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. -# diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/__init__.py deleted file mode 100644 index bf2d436c..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_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 .client import CompanyServiceClient -from .async_client import CompanyServiceAsyncClient - -__all__ = ( - 'CompanyServiceClient', - 'CompanyServiceAsyncClient', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/async_client.py deleted file mode 100644 index 9b6c1bb1..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/async_client.py +++ /dev/null @@ -1,805 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4.services.company_service import pagers -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import company -from google.cloud.talent_v4.types import company as gct_company -from google.cloud.talent_v4.types import company_service -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import CompanyServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport -from .client import CompanyServiceClient - - -class CompanyServiceAsyncClient: - """A service that handles company management, including CRUD and - enumeration. - """ - - _client: CompanyServiceClient - - DEFAULT_ENDPOINT = CompanyServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = CompanyServiceClient.DEFAULT_MTLS_ENDPOINT - - company_path = staticmethod(CompanyServiceClient.company_path) - parse_company_path = staticmethod(CompanyServiceClient.parse_company_path) - tenant_path = staticmethod(CompanyServiceClient.tenant_path) - parse_tenant_path = staticmethod(CompanyServiceClient.parse_tenant_path) - common_billing_account_path = staticmethod(CompanyServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(CompanyServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(CompanyServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(CompanyServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(CompanyServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(CompanyServiceClient.parse_common_organization_path) - common_project_path = staticmethod(CompanyServiceClient.common_project_path) - parse_common_project_path = staticmethod(CompanyServiceClient.parse_common_project_path) - common_location_path = staticmethod(CompanyServiceClient.common_location_path) - parse_common_location_path = staticmethod(CompanyServiceClient.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: - CompanyServiceAsyncClient: The constructed client. - """ - return CompanyServiceClient.from_service_account_info.__func__(CompanyServiceAsyncClient, 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: - CompanyServiceAsyncClient: The constructed client. - """ - return CompanyServiceClient.from_service_account_file.__func__(CompanyServiceAsyncClient, 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 CompanyServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> CompanyServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CompanyServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(CompanyServiceClient).get_transport_class, type(CompanyServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, CompanyServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the company 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, ~.CompanyServiceTransport]): 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 = CompanyServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_company(self, - request: Union[company_service.CreateCompanyRequest, dict] = None, - *, - parent: str = None, - company: gct_company.Company = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_company.Company: - r"""Creates a new company entity. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_create_company(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - company = talent_v4.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4.CreateCompanyRequest( - parent="parent_value", - company=company, - ) - - # Make the request - response = await client.create_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CreateCompanyRequest, dict]): - The request object. The Request of the CreateCompany - method. - parent (:class:`str`): - Required. Resource name of the tenant under which the - company 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. - company (:class:`google.cloud.talent_v4.types.Company`): - Required. The company to be created. - This corresponds to the ``company`` 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_v4.types.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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, company]) - 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 = company_service.CreateCompanyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if company is not None: - request.company = company - - # 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_company, - 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_company(self, - request: Union[company_service.GetCompanyRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> company.Company: - r"""Retrieves specified company. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_get_company(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.GetCompanyRequest( - name="name_value", - ) - - # Make the request - response = await client.get_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.GetCompanyRequest, dict]): - The request object. Request for getting a company by - name. - name (:class:`str`): - Required. The resource name of the company to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, - "projects/api-test-project/tenants/foo/companies/bar". - - 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_v4.types.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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 = company_service.GetCompanyRequest(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_company, - 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_company(self, - request: Union[company_service.UpdateCompanyRequest, dict] = None, - *, - company: gct_company.Company = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_company.Company: - r"""Updates specified company. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_update_company(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - company = talent_v4.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4.UpdateCompanyRequest( - company=company, - ) - - # Make the request - response = await client.update_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.UpdateCompanyRequest, dict]): - The request object. Request for updating a specified - company. - company (:class:`google.cloud.talent_v4.types.Company`): - Required. The company resource to - replace the current resource in the - system. - - This corresponds to the ``company`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Strongly recommended for the best service experience. - - If - [update_mask][google.cloud.talent.v4.UpdateCompanyRequest.update_mask] - is provided, only the specified fields in - [company][google.cloud.talent.v4.UpdateCompanyRequest.company] - are updated. Otherwise all the fields are updated. - - A field mask to specify the company fields to be - updated. Only top level fields of - [Company][google.cloud.talent.v4.Company] are supported. - - This corresponds to the ``update_mask`` 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_v4.types.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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([company, update_mask]) - 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 = company_service.UpdateCompanyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if company is not None: - request.company = company - if update_mask is not None: - request.update_mask = update_mask - - # 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_company, - 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(( - ("company.name", request.company.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_company(self, - request: Union[company_service.DeleteCompanyRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified company. - Prerequisite: The company has no jobs associated with - it. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_delete_company(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.DeleteCompanyRequest( - name="name_value", - ) - - # Make the request - await client.delete_company(request=request) - - Args: - request (Union[google.cloud.talent_v4.types.DeleteCompanyRequest, dict]): - The request object. Request to delete a company. - name (:class:`str`): - Required. The resource name of the company to be - deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/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 = company_service.DeleteCompanyRequest(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_company, - 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_companies(self, - request: Union[company_service.ListCompaniesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCompaniesAsyncPager: - r"""Lists all companies associated with the project. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_list_companies(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.ListCompaniesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_companies(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.ListCompaniesRequest, dict]): - The request object. List companies for which the client - has ACL visibility. - parent (:class:`str`): - Required. Resource name of the tenant under which the - company 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_v4.services.company_service.pagers.ListCompaniesAsyncPager: - The List companies 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 = company_service.ListCompaniesRequest(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_companies, - 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.ListCompaniesAsyncPager( - 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__ = ( - "CompanyServiceAsyncClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/client.py deleted file mode 100644 index 1f55d47a..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/client.py +++ /dev/null @@ -1,993 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4.services.company_service import pagers -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import company -from google.cloud.talent_v4.types import company as gct_company -from google.cloud.talent_v4.types import company_service -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import CompanyServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import CompanyServiceGrpcTransport -from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport - - -class CompanyServiceClientMeta(type): - """Metaclass for the CompanyService 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[CompanyServiceTransport]] - _transport_registry["grpc"] = CompanyServiceGrpcTransport - _transport_registry["grpc_asyncio"] = CompanyServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[CompanyServiceTransport]: - """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 CompanyServiceClient(metaclass=CompanyServiceClientMeta): - """A service that handles company 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: - CompanyServiceClient: 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: - CompanyServiceClient: 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) -> CompanyServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CompanyServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @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 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, CompanyServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the company 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, CompanyServiceTransport]): 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, CompanyServiceTransport): - # transport is a CompanyServiceTransport 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, - api_audience=client_options.api_audience, - ) - - def create_company(self, - request: Union[company_service.CreateCompanyRequest, dict] = None, - *, - parent: str = None, - company: gct_company.Company = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_company.Company: - r"""Creates a new company entity. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_create_company(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - company = talent_v4.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4.CreateCompanyRequest( - parent="parent_value", - company=company, - ) - - # Make the request - response = client.create_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CreateCompanyRequest, dict]): - The request object. The Request of the CreateCompany - method. - parent (str): - Required. Resource name of the tenant under which the - company 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. - company (google.cloud.talent_v4.types.Company): - Required. The company to be created. - This corresponds to the ``company`` 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_v4.types.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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, company]) - 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 company_service.CreateCompanyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.CreateCompanyRequest): - request = company_service.CreateCompanyRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if company is not None: - request.company = company - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_company] - - # 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_company(self, - request: Union[company_service.GetCompanyRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> company.Company: - r"""Retrieves specified company. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_get_company(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4.GetCompanyRequest( - name="name_value", - ) - - # Make the request - response = client.get_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.GetCompanyRequest, dict]): - The request object. Request for getting a company by - name. - name (str): - Required. The resource name of the company to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, - "projects/api-test-project/tenants/foo/companies/bar". - - 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_v4.types.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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 company_service.GetCompanyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.GetCompanyRequest): - request = company_service.GetCompanyRequest(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_company] - - # 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_company(self, - request: Union[company_service.UpdateCompanyRequest, dict] = None, - *, - company: gct_company.Company = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_company.Company: - r"""Updates specified company. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_update_company(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - company = talent_v4.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4.UpdateCompanyRequest( - company=company, - ) - - # Make the request - response = client.update_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.UpdateCompanyRequest, dict]): - The request object. Request for updating a specified - company. - company (google.cloud.talent_v4.types.Company): - Required. The company resource to - replace the current resource in the - system. - - This corresponds to the ``company`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Strongly recommended for the best service experience. - - If - [update_mask][google.cloud.talent.v4.UpdateCompanyRequest.update_mask] - is provided, only the specified fields in - [company][google.cloud.talent.v4.UpdateCompanyRequest.company] - are updated. Otherwise all the fields are updated. - - A field mask to specify the company fields to be - updated. Only top level fields of - [Company][google.cloud.talent.v4.Company] are supported. - - This corresponds to the ``update_mask`` 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_v4.types.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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([company, update_mask]) - 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 company_service.UpdateCompanyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.UpdateCompanyRequest): - request = company_service.UpdateCompanyRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if company is not None: - request.company = company - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_company] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("company.name", request.company.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_company(self, - request: Union[company_service.DeleteCompanyRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified company. - Prerequisite: The company has no jobs associated with - it. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_delete_company(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4.DeleteCompanyRequest( - name="name_value", - ) - - # Make the request - client.delete_company(request=request) - - Args: - request (Union[google.cloud.talent_v4.types.DeleteCompanyRequest, dict]): - The request object. Request to delete a company. - name (str): - Required. The resource name of the company to be - deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/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 company_service.DeleteCompanyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.DeleteCompanyRequest): - request = company_service.DeleteCompanyRequest(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_company] - - # 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_companies(self, - request: Union[company_service.ListCompaniesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCompaniesPager: - r"""Lists all companies associated with the project. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_list_companies(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4.ListCompaniesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_companies(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.ListCompaniesRequest, dict]): - The request object. List companies for which the client - has ACL visibility. - parent (str): - Required. Resource name of the tenant under which the - company 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_v4.services.company_service.pagers.ListCompaniesPager: - The List companies 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 company_service.ListCompaniesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.ListCompaniesRequest): - request = company_service.ListCompaniesRequest(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_companies] - - # 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.ListCompaniesPager( - 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__ = ( - "CompanyServiceClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/pagers.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/pagers.py deleted file mode 100644 index 08dbe044..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/pagers.py +++ /dev/null @@ -1,140 +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, Sequence, Tuple, Optional, Iterator - -from google.cloud.talent_v4.types import company -from google.cloud.talent_v4.types import company_service - - -class ListCompaniesPager: - """A pager for iterating through ``list_companies`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4.types.ListCompaniesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``companies`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCompanies`` requests and continue to iterate - through the ``companies`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4.types.ListCompaniesResponse` - 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[..., company_service.ListCompaniesResponse], - request: company_service.ListCompaniesRequest, - response: company_service.ListCompaniesResponse, - *, - 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_v4.types.ListCompaniesRequest): - The initial request object. - response (google.cloud.talent_v4.types.ListCompaniesResponse): - 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 = company_service.ListCompaniesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[company_service.ListCompaniesResponse]: - 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[company.Company]: - for page in self.pages: - yield from page.companies - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCompaniesAsyncPager: - """A pager for iterating through ``list_companies`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4.types.ListCompaniesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``companies`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCompanies`` requests and continue to iterate - through the ``companies`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4.types.ListCompaniesResponse` - 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[company_service.ListCompaniesResponse]], - request: company_service.ListCompaniesRequest, - response: company_service.ListCompaniesResponse, - *, - 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_v4.types.ListCompaniesRequest): - The initial request object. - response (google.cloud.talent_v4.types.ListCompaniesResponse): - 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 = company_service.ListCompaniesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[company_service.ListCompaniesResponse]: - 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[company.Company]: - async def async_generator(): - async for page in self.pages: - for response in page.companies: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/__init__.py deleted file mode 100644 index 1b586f42..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/__init__.py +++ /dev/null @@ -1,33 +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 CompanyServiceTransport -from .grpc import CompanyServiceGrpcTransport -from .grpc_asyncio import CompanyServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[CompanyServiceTransport]] -_transport_registry['grpc'] = CompanyServiceGrpcTransport -_transport_registry['grpc_asyncio'] = CompanyServiceGrpcAsyncIOTransport - -__all__ = ( - 'CompanyServiceTransport', - 'CompanyServiceGrpcTransport', - 'CompanyServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/base.py deleted file mode 100644 index fab33738..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/base.py +++ /dev/null @@ -1,235 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4.types import company -from google.cloud.talent_v4.types import company as gct_company -from google.cloud.talent_v4.types import company_service -from google.protobuf import empty_pb2 # type: ignore - -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 CompanyServiceTransport(abc.ABC): - """Abstract transport class for CompanyService.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.create_company: gapic_v1.method.wrap_method( - self.create_company, - default_timeout=30.0, - client_info=client_info, - ), - self.get_company: gapic_v1.method.wrap_method( - self.get_company, - 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_company: gapic_v1.method.wrap_method( - self.update_company, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_company: gapic_v1.method.wrap_method( - self.delete_company, - 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_companies: gapic_v1.method.wrap_method( - self.list_companies, - 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_company(self) -> Callable[ - [company_service.CreateCompanyRequest], - Union[ - gct_company.Company, - Awaitable[gct_company.Company] - ]]: - raise NotImplementedError() - - @property - def get_company(self) -> Callable[ - [company_service.GetCompanyRequest], - Union[ - company.Company, - Awaitable[company.Company] - ]]: - raise NotImplementedError() - - @property - def update_company(self) -> Callable[ - [company_service.UpdateCompanyRequest], - Union[ - gct_company.Company, - Awaitable[gct_company.Company] - ]]: - raise NotImplementedError() - - @property - def delete_company(self) -> Callable[ - [company_service.DeleteCompanyRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_companies(self) -> Callable[ - [company_service.ListCompaniesRequest], - Union[ - company_service.ListCompaniesResponse, - Awaitable[company_service.ListCompaniesResponse] - ]]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'CompanyServiceTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc.py deleted file mode 100644 index aae783fb..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc.py +++ /dev/null @@ -1,374 +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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4.types import company -from google.cloud.talent_v4.types import company as gct_company -from google.cloud.talent_v4.types import company_service -from google.protobuf import empty_pb2 # type: ignore -from .base import CompanyServiceTransport, DEFAULT_CLIENT_INFO - - -class CompanyServiceGrpcTransport(CompanyServiceTransport): - """gRPC backend transport for CompanyService. - - A service that handles company 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_company(self) -> Callable[ - [company_service.CreateCompanyRequest], - gct_company.Company]: - r"""Return a callable for the create company method over gRPC. - - Creates a new company entity. - - Returns: - Callable[[~.CreateCompanyRequest], - ~.Company]: - 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_company' not in self._stubs: - self._stubs['create_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/CreateCompany', - request_serializer=company_service.CreateCompanyRequest.serialize, - response_deserializer=gct_company.Company.deserialize, - ) - return self._stubs['create_company'] - - @property - def get_company(self) -> Callable[ - [company_service.GetCompanyRequest], - company.Company]: - r"""Return a callable for the get company method over gRPC. - - Retrieves specified company. - - Returns: - Callable[[~.GetCompanyRequest], - ~.Company]: - 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_company' not in self._stubs: - self._stubs['get_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/GetCompany', - request_serializer=company_service.GetCompanyRequest.serialize, - response_deserializer=company.Company.deserialize, - ) - return self._stubs['get_company'] - - @property - def update_company(self) -> Callable[ - [company_service.UpdateCompanyRequest], - gct_company.Company]: - r"""Return a callable for the update company method over gRPC. - - Updates specified company. - - Returns: - Callable[[~.UpdateCompanyRequest], - ~.Company]: - 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_company' not in self._stubs: - self._stubs['update_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/UpdateCompany', - request_serializer=company_service.UpdateCompanyRequest.serialize, - response_deserializer=gct_company.Company.deserialize, - ) - return self._stubs['update_company'] - - @property - def delete_company(self) -> Callable[ - [company_service.DeleteCompanyRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete company method over gRPC. - - Deletes specified company. - Prerequisite: The company has no jobs associated with - it. - - Returns: - Callable[[~.DeleteCompanyRequest], - ~.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_company' not in self._stubs: - self._stubs['delete_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/DeleteCompany', - request_serializer=company_service.DeleteCompanyRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_company'] - - @property - def list_companies(self) -> Callable[ - [company_service.ListCompaniesRequest], - company_service.ListCompaniesResponse]: - r"""Return a callable for the list companies method over gRPC. - - Lists all companies associated with the project. - - Returns: - Callable[[~.ListCompaniesRequest], - ~.ListCompaniesResponse]: - 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_companies' not in self._stubs: - self._stubs['list_companies'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/ListCompanies', - request_serializer=company_service.ListCompaniesRequest.serialize, - response_deserializer=company_service.ListCompaniesResponse.deserialize, - ) - return self._stubs['list_companies'] - - def close(self): - self.grpc_channel.close() - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'CompanyServiceGrpcTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py deleted file mode 100644 index 2224505f..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,373 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4.types import company -from google.cloud.talent_v4.types import company as gct_company -from google.cloud.talent_v4.types import company_service -from google.protobuf import empty_pb2 # type: ignore -from .base import CompanyServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import CompanyServiceGrpcTransport - - -class CompanyServiceGrpcAsyncIOTransport(CompanyServiceTransport): - """gRPC AsyncIO backend transport for CompanyService. - - A service that handles company 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_company(self) -> Callable[ - [company_service.CreateCompanyRequest], - Awaitable[gct_company.Company]]: - r"""Return a callable for the create company method over gRPC. - - Creates a new company entity. - - Returns: - Callable[[~.CreateCompanyRequest], - Awaitable[~.Company]]: - 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_company' not in self._stubs: - self._stubs['create_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/CreateCompany', - request_serializer=company_service.CreateCompanyRequest.serialize, - response_deserializer=gct_company.Company.deserialize, - ) - return self._stubs['create_company'] - - @property - def get_company(self) -> Callable[ - [company_service.GetCompanyRequest], - Awaitable[company.Company]]: - r"""Return a callable for the get company method over gRPC. - - Retrieves specified company. - - Returns: - Callable[[~.GetCompanyRequest], - Awaitable[~.Company]]: - 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_company' not in self._stubs: - self._stubs['get_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/GetCompany', - request_serializer=company_service.GetCompanyRequest.serialize, - response_deserializer=company.Company.deserialize, - ) - return self._stubs['get_company'] - - @property - def update_company(self) -> Callable[ - [company_service.UpdateCompanyRequest], - Awaitable[gct_company.Company]]: - r"""Return a callable for the update company method over gRPC. - - Updates specified company. - - Returns: - Callable[[~.UpdateCompanyRequest], - Awaitable[~.Company]]: - 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_company' not in self._stubs: - self._stubs['update_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/UpdateCompany', - request_serializer=company_service.UpdateCompanyRequest.serialize, - response_deserializer=gct_company.Company.deserialize, - ) - return self._stubs['update_company'] - - @property - def delete_company(self) -> Callable[ - [company_service.DeleteCompanyRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete company method over gRPC. - - Deletes specified company. - Prerequisite: The company has no jobs associated with - it. - - Returns: - Callable[[~.DeleteCompanyRequest], - 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_company' not in self._stubs: - self._stubs['delete_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/DeleteCompany', - request_serializer=company_service.DeleteCompanyRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_company'] - - @property - def list_companies(self) -> Callable[ - [company_service.ListCompaniesRequest], - Awaitable[company_service.ListCompaniesResponse]]: - r"""Return a callable for the list companies method over gRPC. - - Lists all companies associated with the project. - - Returns: - Callable[[~.ListCompaniesRequest], - Awaitable[~.ListCompaniesResponse]]: - 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_companies' not in self._stubs: - self._stubs['list_companies'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.CompanyService/ListCompanies', - request_serializer=company_service.ListCompaniesRequest.serialize, - response_deserializer=company_service.ListCompaniesResponse.deserialize, - ) - return self._stubs['list_companies'] - - def close(self): - return self.grpc_channel.close() - - -__all__ = ( - 'CompanyServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/__init__.py deleted file mode 100644 index 28d77594..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/__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 .client import CompletionClient -from .async_client import CompletionAsyncClient - -__all__ = ( - 'CompletionClient', - 'CompletionAsyncClient', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/async_client.py deleted file mode 100644 index 99742513..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/async_client.py +++ /dev/null @@ -1,295 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import completion_service -from .transports.base import CompletionTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport -from .client import CompletionClient - - -class CompletionAsyncClient: - """A service handles auto completion.""" - - _client: CompletionClient - - DEFAULT_ENDPOINT = CompletionClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = CompletionClient.DEFAULT_MTLS_ENDPOINT - - company_path = staticmethod(CompletionClient.company_path) - parse_company_path = staticmethod(CompletionClient.parse_company_path) - tenant_path = staticmethod(CompletionClient.tenant_path) - parse_tenant_path = staticmethod(CompletionClient.parse_tenant_path) - common_billing_account_path = staticmethod(CompletionClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(CompletionClient.parse_common_billing_account_path) - common_folder_path = staticmethod(CompletionClient.common_folder_path) - parse_common_folder_path = staticmethod(CompletionClient.parse_common_folder_path) - common_organization_path = staticmethod(CompletionClient.common_organization_path) - parse_common_organization_path = staticmethod(CompletionClient.parse_common_organization_path) - common_project_path = staticmethod(CompletionClient.common_project_path) - parse_common_project_path = staticmethod(CompletionClient.parse_common_project_path) - common_location_path = staticmethod(CompletionClient.common_location_path) - parse_common_location_path = staticmethod(CompletionClient.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: - CompletionAsyncClient: The constructed client. - """ - return CompletionClient.from_service_account_info.__func__(CompletionAsyncClient, 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: - CompletionAsyncClient: The constructed client. - """ - return CompletionClient.from_service_account_file.__func__(CompletionAsyncClient, 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 CompletionClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> CompletionTransport: - """Returns the transport used by the client instance. - - Returns: - CompletionTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(CompletionClient).get_transport_class, type(CompletionClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, CompletionTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the completion 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, ~.CompletionTransport]): 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 = CompletionClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def complete_query(self, - request: Union[completion_service.CompleteQueryRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> completion_service.CompleteQueryResponse: - r"""Completes the specified prefix with keyword - suggestions. Intended for use by a job search - auto-complete search box. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_complete_query(): - # Create a client - client = talent_v4.CompletionAsyncClient() - - # Initialize request argument(s) - request = talent_v4.CompleteQueryRequest( - tenant="tenant_value", - query="query_value", - page_size=951, - ) - - # Make the request - response = await client.complete_query(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CompleteQueryRequest, dict]): - The request object. Auto-complete parameters. - 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_v4.types.CompleteQueryResponse: - Response of auto-complete query. - """ - # Create or coerce a protobuf request object. - request = completion_service.CompleteQueryRequest(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.complete_query, - 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(( - ("tenant", request.tenant), - )), - ) - - # 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 - - 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__ = ( - "CompletionAsyncClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/client.py deleted file mode 100644 index b2e484d9..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/client.py +++ /dev/null @@ -1,498 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import completion_service -from .transports.base import CompletionTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import CompletionGrpcTransport -from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport - - -class CompletionClientMeta(type): - """Metaclass for the Completion 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[CompletionTransport]] - _transport_registry["grpc"] = CompletionGrpcTransport - _transport_registry["grpc_asyncio"] = CompletionGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[CompletionTransport]: - """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 CompletionClient(metaclass=CompletionClientMeta): - """A service handles auto completion.""" - - @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: - CompletionClient: 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: - CompletionClient: 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) -> CompletionTransport: - """Returns the transport used by the client instance. - - Returns: - CompletionTransport: The transport used by the client - instance. - """ - return self._transport - - @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 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, CompletionTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the completion 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, CompletionTransport]): 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, CompletionTransport): - # transport is a CompletionTransport 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, - api_audience=client_options.api_audience, - ) - - def complete_query(self, - request: Union[completion_service.CompleteQueryRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> completion_service.CompleteQueryResponse: - r"""Completes the specified prefix with keyword - suggestions. Intended for use by a job search - auto-complete search box. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_complete_query(): - # Create a client - client = talent_v4.CompletionClient() - - # Initialize request argument(s) - request = talent_v4.CompleteQueryRequest( - tenant="tenant_value", - query="query_value", - page_size=951, - ) - - # Make the request - response = client.complete_query(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CompleteQueryRequest, dict]): - The request object. Auto-complete parameters. - 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_v4.types.CompleteQueryResponse: - Response of auto-complete query. - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a completion_service.CompleteQueryRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, completion_service.CompleteQueryRequest): - request = completion_service.CompleteQueryRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.complete_query] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("tenant", request.tenant), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - 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__ = ( - "CompletionClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/__init__.py deleted file mode 100644 index 14e86855..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/__init__.py +++ /dev/null @@ -1,33 +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 CompletionTransport -from .grpc import CompletionGrpcTransport -from .grpc_asyncio import CompletionGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[CompletionTransport]] -_transport_registry['grpc'] = CompletionGrpcTransport -_transport_registry['grpc_asyncio'] = CompletionGrpcAsyncIOTransport - -__all__ = ( - 'CompletionTransport', - 'CompletionGrpcTransport', - 'CompletionGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/base.py deleted file mode 100644 index 77f959f7..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/base.py +++ /dev/null @@ -1,162 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4.types import completion_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 CompletionTransport(abc.ABC): - """Abstract transport class for Completion.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.complete_query: gapic_v1.method.wrap_method( - self.complete_query, - 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 complete_query(self) -> Callable[ - [completion_service.CompleteQueryRequest], - Union[ - completion_service.CompleteQueryResponse, - Awaitable[completion_service.CompleteQueryResponse] - ]]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'CompletionTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc.py deleted file mode 100644 index ce77a841..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc.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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4.types import completion_service -from .base import CompletionTransport, DEFAULT_CLIENT_INFO - - -class CompletionGrpcTransport(CompletionTransport): - """gRPC backend transport for Completion. - - A service handles auto completion. - - 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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 complete_query(self) -> Callable[ - [completion_service.CompleteQueryRequest], - completion_service.CompleteQueryResponse]: - r"""Return a callable for the complete query method over gRPC. - - Completes the specified prefix with keyword - suggestions. Intended for use by a job search - auto-complete search box. - - Returns: - Callable[[~.CompleteQueryRequest], - ~.CompleteQueryResponse]: - 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 'complete_query' not in self._stubs: - self._stubs['complete_query'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.Completion/CompleteQuery', - request_serializer=completion_service.CompleteQueryRequest.serialize, - response_deserializer=completion_service.CompleteQueryResponse.deserialize, - ) - return self._stubs['complete_query'] - - def close(self): - self.grpc_channel.close() - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'CompletionGrpcTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py deleted file mode 100644 index fae63e49..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py +++ /dev/null @@ -1,265 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4.types import completion_service -from .base import CompletionTransport, DEFAULT_CLIENT_INFO -from .grpc import CompletionGrpcTransport - - -class CompletionGrpcAsyncIOTransport(CompletionTransport): - """gRPC AsyncIO backend transport for Completion. - - A service handles auto completion. - - 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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 complete_query(self) -> Callable[ - [completion_service.CompleteQueryRequest], - Awaitable[completion_service.CompleteQueryResponse]]: - r"""Return a callable for the complete query method over gRPC. - - Completes the specified prefix with keyword - suggestions. Intended for use by a job search - auto-complete search box. - - Returns: - Callable[[~.CompleteQueryRequest], - Awaitable[~.CompleteQueryResponse]]: - 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 'complete_query' not in self._stubs: - self._stubs['complete_query'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.Completion/CompleteQuery', - request_serializer=completion_service.CompleteQueryRequest.serialize, - response_deserializer=completion_service.CompleteQueryResponse.deserialize, - ) - return self._stubs['complete_query'] - - def close(self): - return self.grpc_channel.close() - - -__all__ = ( - 'CompletionGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/__init__.py deleted file mode 100644 index 194a67c4..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_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 .client import EventServiceClient -from .async_client import EventServiceAsyncClient - -__all__ = ( - 'EventServiceClient', - 'EventServiceAsyncClient', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/async_client.py deleted file mode 100644 index bd8d65aa..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/async_client.py +++ /dev/null @@ -1,340 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4.types import event -from google.cloud.talent_v4.types import event_service -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import EventServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport -from .client import EventServiceClient - - -class EventServiceAsyncClient: - """A service handles client event report.""" - - _client: EventServiceClient - - DEFAULT_ENDPOINT = EventServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = EventServiceClient.DEFAULT_MTLS_ENDPOINT - - tenant_path = staticmethod(EventServiceClient.tenant_path) - parse_tenant_path = staticmethod(EventServiceClient.parse_tenant_path) - common_billing_account_path = staticmethod(EventServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(EventServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(EventServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(EventServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(EventServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(EventServiceClient.parse_common_organization_path) - common_project_path = staticmethod(EventServiceClient.common_project_path) - parse_common_project_path = staticmethod(EventServiceClient.parse_common_project_path) - common_location_path = staticmethod(EventServiceClient.common_location_path) - parse_common_location_path = staticmethod(EventServiceClient.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: - EventServiceAsyncClient: The constructed client. - """ - return EventServiceClient.from_service_account_info.__func__(EventServiceAsyncClient, 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: - EventServiceAsyncClient: The constructed client. - """ - return EventServiceClient.from_service_account_file.__func__(EventServiceAsyncClient, 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 EventServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> EventServiceTransport: - """Returns the transport used by the client instance. - - Returns: - EventServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(EventServiceClient).get_transport_class, type(EventServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, EventServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the event 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, ~.EventServiceTransport]): 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 = EventServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_client_event(self, - request: Union[event_service.CreateClientEventRequest, dict] = None, - *, - parent: str = None, - client_event: event.ClientEvent = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> event.ClientEvent: - r"""Report events issued when end user interacts with customer's - application that uses Cloud Talent Solution. You may inspect the - created events in `self service - tools `__. - `Learn - more `__ - about self service tools. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_create_client_event(): - # Create a client - client = talent_v4.EventServiceAsyncClient() - - # Initialize request argument(s) - client_event = talent_v4.ClientEvent() - client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] - client_event.event_id = "event_id_value" - - request = talent_v4.CreateClientEventRequest( - parent="parent_value", - client_event=client_event, - ) - - # Make the request - response = await client.create_client_event(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CreateClientEventRequest, dict]): - The request object. The report event request. - parent (:class:`str`): - Required. Resource name of the tenant under which the - event 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. - client_event (:class:`google.cloud.talent_v4.types.ClientEvent`): - Required. Events issued when end user - interacts with customer's application - that uses Cloud Talent Solution. - - This corresponds to the ``client_event`` 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_v4.types.ClientEvent: - An event issued when an end user - interacts with the application that - implements Cloud Talent Solution. - Providing this information improves the - quality of results for the API clients, - enabling the service to perform - optimally. The number of events sent - must be consistent with other calls, - such as job searches, issued to the - service by the client. - - """ - # 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, client_event]) - 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 = event_service.CreateClientEventRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if client_event is not None: - request.client_event = client_event - - # 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_client_event, - 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 __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__ = ( - "EventServiceAsyncClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/client.py deleted file mode 100644 index 0fb2c9cb..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/client.py +++ /dev/null @@ -1,540 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4.types import event -from google.cloud.talent_v4.types import event_service -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import EventServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import EventServiceGrpcTransport -from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport - - -class EventServiceClientMeta(type): - """Metaclass for the EventService 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[EventServiceTransport]] - _transport_registry["grpc"] = EventServiceGrpcTransport - _transport_registry["grpc_asyncio"] = EventServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[EventServiceTransport]: - """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 EventServiceClient(metaclass=EventServiceClientMeta): - """A service handles client event report.""" - - @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: - EventServiceClient: 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: - EventServiceClient: 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) -> EventServiceTransport: - """Returns the transport used by the client instance. - - Returns: - EventServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @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, EventServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the event 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, EventServiceTransport]): 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, EventServiceTransport): - # transport is a EventServiceTransport 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, - api_audience=client_options.api_audience, - ) - - def create_client_event(self, - request: Union[event_service.CreateClientEventRequest, dict] = None, - *, - parent: str = None, - client_event: event.ClientEvent = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> event.ClientEvent: - r"""Report events issued when end user interacts with customer's - application that uses Cloud Talent Solution. You may inspect the - created events in `self service - tools `__. - `Learn - more `__ - about self service tools. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_create_client_event(): - # Create a client - client = talent_v4.EventServiceClient() - - # Initialize request argument(s) - client_event = talent_v4.ClientEvent() - client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] - client_event.event_id = "event_id_value" - - request = talent_v4.CreateClientEventRequest( - parent="parent_value", - client_event=client_event, - ) - - # Make the request - response = client.create_client_event(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CreateClientEventRequest, dict]): - The request object. The report event request. - parent (str): - Required. Resource name of the tenant under which the - event 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. - client_event (google.cloud.talent_v4.types.ClientEvent): - Required. Events issued when end user - interacts with customer's application - that uses Cloud Talent Solution. - - This corresponds to the ``client_event`` 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_v4.types.ClientEvent: - An event issued when an end user - interacts with the application that - implements Cloud Talent Solution. - Providing this information improves the - quality of results for the API clients, - enabling the service to perform - optimally. The number of events sent - must be consistent with other calls, - such as job searches, issued to the - service by the client. - - """ - # 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, client_event]) - 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 event_service.CreateClientEventRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, event_service.CreateClientEventRequest): - request = event_service.CreateClientEventRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if client_event is not None: - request.client_event = client_event - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_client_event] - - # 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 __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__ = ( - "EventServiceClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/__init__.py deleted file mode 100644 index 4647d6a8..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/__init__.py +++ /dev/null @@ -1,33 +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 EventServiceTransport -from .grpc import EventServiceGrpcTransport -from .grpc_asyncio import EventServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[EventServiceTransport]] -_transport_registry['grpc'] = EventServiceGrpcTransport -_transport_registry['grpc_asyncio'] = EventServiceGrpcAsyncIOTransport - -__all__ = ( - 'EventServiceTransport', - 'EventServiceGrpcTransport', - 'EventServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/base.py deleted file mode 100644 index fd166e35..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/base.py +++ /dev/null @@ -1,156 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4.types import event -from google.cloud.talent_v4.types import event_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 EventServiceTransport(abc.ABC): - """Abstract transport class for EventService.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.create_client_event: gapic_v1.method.wrap_method( - self.create_client_event, - 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_client_event(self) -> Callable[ - [event_service.CreateClientEventRequest], - Union[ - event.ClientEvent, - Awaitable[event.ClientEvent] - ]]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'EventServiceTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc.py deleted file mode 100644 index d46d20d8..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc.py +++ /dev/null @@ -1,271 +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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4.types import event -from google.cloud.talent_v4.types import event_service -from .base import EventServiceTransport, DEFAULT_CLIENT_INFO - - -class EventServiceGrpcTransport(EventServiceTransport): - """gRPC backend transport for EventService. - - A service handles client event report. - - 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_client_event(self) -> Callable[ - [event_service.CreateClientEventRequest], - event.ClientEvent]: - r"""Return a callable for the create client event method over gRPC. - - Report events issued when end user interacts with customer's - application that uses Cloud Talent Solution. You may inspect the - created events in `self service - tools `__. - `Learn - more `__ - about self service tools. - - Returns: - Callable[[~.CreateClientEventRequest], - ~.ClientEvent]: - 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_client_event' not in self._stubs: - self._stubs['create_client_event'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.EventService/CreateClientEvent', - request_serializer=event_service.CreateClientEventRequest.serialize, - response_deserializer=event.ClientEvent.deserialize, - ) - return self._stubs['create_client_event'] - - def close(self): - self.grpc_channel.close() - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'EventServiceGrpcTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py deleted file mode 100644 index 789b95c9..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,270 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4.types import event -from google.cloud.talent_v4.types import event_service -from .base import EventServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import EventServiceGrpcTransport - - -class EventServiceGrpcAsyncIOTransport(EventServiceTransport): - """gRPC AsyncIO backend transport for EventService. - - A service handles client event report. - - 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_client_event(self) -> Callable[ - [event_service.CreateClientEventRequest], - Awaitable[event.ClientEvent]]: - r"""Return a callable for the create client event method over gRPC. - - Report events issued when end user interacts with customer's - application that uses Cloud Talent Solution. You may inspect the - created events in `self service - tools `__. - `Learn - more `__ - about self service tools. - - Returns: - Callable[[~.CreateClientEventRequest], - Awaitable[~.ClientEvent]]: - 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_client_event' not in self._stubs: - self._stubs['create_client_event'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.EventService/CreateClientEvent', - request_serializer=event_service.CreateClientEventRequest.serialize, - response_deserializer=event.ClientEvent.deserialize, - ) - return self._stubs['create_client_event'] - - def close(self): - return self.grpc_channel.close() - - -__all__ = ( - 'EventServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/__init__.py deleted file mode 100644 index 3a5ccd23..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_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 .client import JobServiceClient -from .async_client import JobServiceAsyncClient - -__all__ = ( - 'JobServiceClient', - 'JobServiceAsyncClient', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/async_client.py deleted file mode 100644 index 03d79015..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/async_client.py +++ /dev/null @@ -1,1431 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.talent_v4.services.job_service import pagers -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import histogram -from google.cloud.talent_v4.types import job -from google.cloud.talent_v4.types import job as gct_job -from google.cloud.talent_v4.types import job_service -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport -from .client import JobServiceClient - - -class JobServiceAsyncClient: - """A service handles job management, including job CRUD, - enumeration and search. - """ - - _client: JobServiceClient - - DEFAULT_ENDPOINT = JobServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = JobServiceClient.DEFAULT_MTLS_ENDPOINT - - company_path = staticmethod(JobServiceClient.company_path) - parse_company_path = staticmethod(JobServiceClient.parse_company_path) - job_path = staticmethod(JobServiceClient.job_path) - parse_job_path = staticmethod(JobServiceClient.parse_job_path) - tenant_path = staticmethod(JobServiceClient.tenant_path) - parse_tenant_path = staticmethod(JobServiceClient.parse_tenant_path) - common_billing_account_path = staticmethod(JobServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(JobServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(JobServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(JobServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(JobServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(JobServiceClient.parse_common_organization_path) - common_project_path = staticmethod(JobServiceClient.common_project_path) - parse_common_project_path = staticmethod(JobServiceClient.parse_common_project_path) - common_location_path = staticmethod(JobServiceClient.common_location_path) - parse_common_location_path = staticmethod(JobServiceClient.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: - JobServiceAsyncClient: The constructed client. - """ - return JobServiceClient.from_service_account_info.__func__(JobServiceAsyncClient, 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: - JobServiceAsyncClient: The constructed client. - """ - return JobServiceClient.from_service_account_file.__func__(JobServiceAsyncClient, 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 JobServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> JobServiceTransport: - """Returns the transport used by the client instance. - - Returns: - JobServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(JobServiceClient).get_transport_class, type(JobServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, JobServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the job 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, ~.JobServiceTransport]): 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 = JobServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_job(self, - request: Union[job_service.CreateJobRequest, dict] = None, - *, - parent: str = None, - job: gct_job.Job = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_job.Job: - r"""Creates a new job. - Typically, the job becomes searchable within 10 seconds, - but it may take up to 5 minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_create_job(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - job = talent_v4.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4.CreateJobRequest( - parent="parent_value", - job=job, - ) - - # Make the request - response = await client.create_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CreateJobRequest, dict]): - The request object. Create job request. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job 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. - job (:class:`google.cloud.talent_v4.types.Job`): - Required. The Job to be created. - This corresponds to the ``job`` 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_v4.types.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4.Company], which is - the hiring entity responsible for the job. - - """ - # 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, job]) - 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 = job_service.CreateJobRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if job is not None: - request.job = job - - # 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_job, - 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 batch_create_jobs(self, - request: Union[job_service.BatchCreateJobsRequest, dict] = None, - *, - parent: str = None, - jobs: Sequence[job.Job] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Begins executing a batch create jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_batch_create_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - jobs = talent_v4.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4.BatchCreateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_create_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.BatchCreateJobsRequest, dict]): - The request object. Request to create a batch of jobs. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job 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. - jobs (:class:`Sequence[google.cloud.talent_v4.types.Job]`): - Required. The jobs to be created. - A maximum of 200 jobs can be created in - a batch. - - This corresponds to the ``jobs`` 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchCreateJobsResponse` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4.JobService.BatchCreateJobs]. It's used to - replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, jobs]) - 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 = job_service.BatchCreateJobsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if jobs: - request.jobs.extend(jobs) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.batch_create_jobs, - 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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - job_service.BatchCreateJobsResponse, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - async def get_job(self, - request: Union[job_service.GetJobRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> job.Job: - r"""Retrieves the specified job, whose status is OPEN or - recently EXPIRED within the last 90 days. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_get_job(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.GetJobRequest( - name="name_value", - ) - - # Make the request - response = await client.get_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.GetJobRequest, dict]): - The request object. Get job request. - name (:class:`str`): - Required. The resource name of the job to retrieve. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/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_v4.types.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4.Company], which is - the hiring entity responsible for the job. - - """ - # 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 = job_service.GetJobRequest(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_job, - 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_job(self, - request: Union[job_service.UpdateJobRequest, dict] = None, - *, - job: gct_job.Job = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_job.Job: - r"""Updates specified job. - Typically, updated contents become visible in search - results within 10 seconds, but it may take up to 5 - minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_update_job(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - job = talent_v4.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4.UpdateJobRequest( - job=job, - ) - - # Make the request - response = await client.update_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.UpdateJobRequest, dict]): - The request object. Update job request. - job (:class:`google.cloud.talent_v4.types.Job`): - Required. The Job to be updated. - This corresponds to the ``job`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Strongly recommended for the best service experience. - - If - [update_mask][google.cloud.talent.v4.UpdateJobRequest.update_mask] - is provided, only the specified fields in - [job][google.cloud.talent.v4.UpdateJobRequest.job] are - updated. Otherwise all the fields are updated. - - A field mask to restrict the fields that are updated. - Only top level fields of - [Job][google.cloud.talent.v4.Job] are supported. - - This corresponds to the ``update_mask`` 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_v4.types.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4.Company], which is - the hiring entity responsible for the job. - - """ - # 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([job, update_mask]) - 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 = job_service.UpdateJobRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if job is not None: - request.job = job - if update_mask is not None: - request.update_mask = update_mask - - # 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_job, - 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(( - ("job.name", request.job.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def batch_update_jobs(self, - request: Union[job_service.BatchUpdateJobsRequest, dict] = None, - *, - parent: str = None, - jobs: Sequence[job.Job] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Begins executing a batch update jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_batch_update_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - jobs = talent_v4.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4.BatchUpdateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_update_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.BatchUpdateJobsRequest, dict]): - The request object. Request to update a batch of jobs. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job 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. - jobs (:class:`Sequence[google.cloud.talent_v4.types.Job]`): - Required. The jobs to be updated. - A maximum of 200 jobs can be updated in - a batch. - - This corresponds to the ``jobs`` 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchUpdateJobsResponse` The result of [JobService.BatchUpdateJobs][google.cloud.talent.v4.JobService.BatchUpdateJobs]. It's used to - replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, jobs]) - 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 = job_service.BatchUpdateJobsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if jobs: - request.jobs.extend(jobs) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.batch_update_jobs, - 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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - job_service.BatchUpdateJobsResponse, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_job(self, - request: Union[job_service.DeleteJobRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes the specified job. - Typically, the job becomes unsearchable within 10 - seconds, but it may take up to 5 minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_delete_job(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.DeleteJobRequest( - name="name_value", - ) - - # Make the request - await client.delete_job(request=request) - - Args: - request (Union[google.cloud.talent_v4.types.DeleteJobRequest, dict]): - The request object. Delete job request. - name (:class:`str`): - Required. The resource name of the job to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/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 = job_service.DeleteJobRequest(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_job, - 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 batch_delete_jobs(self, - request: Union[job_service.BatchDeleteJobsRequest, dict] = None, - *, - parent: str = None, - names: Sequence[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Begins executing a batch delete jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_batch_delete_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.BatchDeleteJobsRequest( - parent="parent_value", - ) - - # Make the request - operation = client.batch_delete_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.BatchDeleteJobsRequest, dict]): - The request object. Request to delete a batch of jobs. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenants/bar". - - The parent of all of the jobs specified in ``names`` - must match this field. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - names (:class:`Sequence[str]`): - The names of the jobs to delete. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - A maximum of 200 jobs can be deleted in a batch. - - This corresponds to the ``names`` 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchDeleteJobsResponse` The result of [JobService.BatchDeleteJobs][google.cloud.talent.v4.JobService.BatchDeleteJobs]. It's used to - replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, names]) - 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 = job_service.BatchDeleteJobsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if names: - request.names.extend(names) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.batch_delete_jobs, - 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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - job_service.BatchDeleteJobsResponse, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - async def list_jobs(self, - request: Union[job_service.ListJobsRequest, dict] = None, - *, - parent: str = None, - filter: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListJobsAsyncPager: - r"""Lists jobs by filter. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_list_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.ListJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - page_result = client.list_jobs(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.ListJobsRequest, dict]): - The request object. List jobs request. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job 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. - filter (:class:`str`): - Required. The filter string specifies the jobs to be - enumerated. - - Supported operator: =, AND - - The fields eligible for filtering are: - - - ``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" - - requisitionId = "req-1" - - requisitionId = "req-1" AND status = "EXPIRED" - - This corresponds to the ``filter`` 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_v4.services.job_service.pagers.ListJobsAsyncPager: - List jobs response. - 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, filter]) - 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 = job_service.ListJobsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if filter is not None: - request.filter = filter - - # 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_jobs, - 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.ListJobsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def search_jobs(self, - request: Union[job_service.SearchJobsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> job_service.SearchJobsResponse: - r"""Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - - This call constrains the - [visibility][google.cloud.talent.v4.Job.visibility] of jobs - present in the database, and only returns jobs that the caller - has permission to search against. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_search_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - response = await client.search_jobs(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.SearchJobsRequest, dict]): - The request object. The Request body of the `SearchJobs` - 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_v4.types.SearchJobsResponse: - Response for SearchJob method. - """ - # Create or coerce a protobuf request object. - request = job_service.SearchJobsRequest(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_jobs, - 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 search_jobs_for_alert(self, - request: Union[job_service.SearchJobsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> job_service.SearchJobsResponse: - r"""Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - - This API call is intended for the use case of targeting passive - job seekers (for example, job seekers who have signed up to - receive email alerts about potential job opportunities), it has - different algorithmic adjustments that are designed to - specifically target passive job seekers. - - This call constrains the - [visibility][google.cloud.talent.v4.Job.visibility] of jobs - present in the database, and only returns jobs the caller has - permission to search against. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_search_jobs_for_alert(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - response = await client.search_jobs_for_alert(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.SearchJobsRequest, dict]): - The request object. The Request body of the `SearchJobs` - 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_v4.types.SearchJobsResponse: - Response for SearchJob method. - """ - # Create or coerce a protobuf request object. - request = job_service.SearchJobsRequest(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_jobs_for_alert, - 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 __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__ = ( - "JobServiceAsyncClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/client.py deleted file mode 100644 index ad995993..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/client.py +++ /dev/null @@ -1,1630 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.talent_v4.services.job_service import pagers -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import histogram -from google.cloud.talent_v4.types import job -from google.cloud.talent_v4.types import job as gct_job -from google.cloud.talent_v4.types import job_service -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import JobServiceGrpcTransport -from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport - - -class JobServiceClientMeta(type): - """Metaclass for the JobService 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[JobServiceTransport]] - _transport_registry["grpc"] = JobServiceGrpcTransport - _transport_registry["grpc_asyncio"] = JobServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[JobServiceTransport]: - """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 JobServiceClient(metaclass=JobServiceClientMeta): - """A service handles job management, including job 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: - JobServiceClient: 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: - JobServiceClient: 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) -> JobServiceTransport: - """Returns the transport used by the client instance. - - Returns: - JobServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @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 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, JobServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the job 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, JobServiceTransport]): 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, JobServiceTransport): - # transport is a JobServiceTransport 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, - api_audience=client_options.api_audience, - ) - - def create_job(self, - request: Union[job_service.CreateJobRequest, dict] = None, - *, - parent: str = None, - job: gct_job.Job = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_job.Job: - r"""Creates a new job. - Typically, the job becomes searchable within 10 seconds, - but it may take up to 5 minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_create_job(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - job = talent_v4.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4.CreateJobRequest( - parent="parent_value", - job=job, - ) - - # Make the request - response = client.create_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CreateJobRequest, dict]): - The request object. Create job request. - parent (str): - Required. The resource name of the tenant under which - the job 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. - job (google.cloud.talent_v4.types.Job): - Required. The Job to be created. - This corresponds to the ``job`` 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_v4.types.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4.Company], which is - the hiring entity responsible for the job. - - """ - # 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, job]) - 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 job_service.CreateJobRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.CreateJobRequest): - request = job_service.CreateJobRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if job is not None: - request.job = job - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_job] - - # 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 batch_create_jobs(self, - request: Union[job_service.BatchCreateJobsRequest, dict] = None, - *, - parent: str = None, - jobs: Sequence[job.Job] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Begins executing a batch create jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_batch_create_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - jobs = talent_v4.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4.BatchCreateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_create_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.BatchCreateJobsRequest, dict]): - The request object. Request to create a batch of jobs. - parent (str): - Required. The resource name of the tenant under which - the job 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. - jobs (Sequence[google.cloud.talent_v4.types.Job]): - Required. The jobs to be created. - A maximum of 200 jobs can be created in - a batch. - - This corresponds to the ``jobs`` 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchCreateJobsResponse` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4.JobService.BatchCreateJobs]. It's used to - replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, jobs]) - 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 job_service.BatchCreateJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.BatchCreateJobsRequest): - request = job_service.BatchCreateJobsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if jobs is not None: - request.jobs = jobs - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_create_jobs] - - # 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, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - job_service.BatchCreateJobsResponse, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - def get_job(self, - request: Union[job_service.GetJobRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> job.Job: - r"""Retrieves the specified job, whose status is OPEN or - recently EXPIRED within the last 90 days. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_get_job(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.GetJobRequest( - name="name_value", - ) - - # Make the request - response = client.get_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.GetJobRequest, dict]): - The request object. Get job request. - name (str): - Required. The resource name of the job to retrieve. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/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_v4.types.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4.Company], which is - the hiring entity responsible for the job. - - """ - # 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 job_service.GetJobRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.GetJobRequest): - request = job_service.GetJobRequest(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_job] - - # 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_job(self, - request: Union[job_service.UpdateJobRequest, dict] = None, - *, - job: gct_job.Job = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_job.Job: - r"""Updates specified job. - Typically, updated contents become visible in search - results within 10 seconds, but it may take up to 5 - minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_update_job(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - job = talent_v4.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4.UpdateJobRequest( - job=job, - ) - - # Make the request - response = client.update_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.UpdateJobRequest, dict]): - The request object. Update job request. - job (google.cloud.talent_v4.types.Job): - Required. The Job to be updated. - This corresponds to the ``job`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Strongly recommended for the best service experience. - - If - [update_mask][google.cloud.talent.v4.UpdateJobRequest.update_mask] - is provided, only the specified fields in - [job][google.cloud.talent.v4.UpdateJobRequest.job] are - updated. Otherwise all the fields are updated. - - A field mask to restrict the fields that are updated. - Only top level fields of - [Job][google.cloud.talent.v4.Job] are supported. - - This corresponds to the ``update_mask`` 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_v4.types.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4.Company], which is - the hiring entity responsible for the job. - - """ - # 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([job, update_mask]) - 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 job_service.UpdateJobRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.UpdateJobRequest): - request = job_service.UpdateJobRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if job is not None: - request.job = job - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_job] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("job.name", request.job.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def batch_update_jobs(self, - request: Union[job_service.BatchUpdateJobsRequest, dict] = None, - *, - parent: str = None, - jobs: Sequence[job.Job] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Begins executing a batch update jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_batch_update_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - jobs = talent_v4.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4.BatchUpdateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_update_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.BatchUpdateJobsRequest, dict]): - The request object. Request to update a batch of jobs. - parent (str): - Required. The resource name of the tenant under which - the job 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. - jobs (Sequence[google.cloud.talent_v4.types.Job]): - Required. The jobs to be updated. - A maximum of 200 jobs can be updated in - a batch. - - This corresponds to the ``jobs`` 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchUpdateJobsResponse` The result of [JobService.BatchUpdateJobs][google.cloud.talent.v4.JobService.BatchUpdateJobs]. It's used to - replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, jobs]) - 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 job_service.BatchUpdateJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.BatchUpdateJobsRequest): - request = job_service.BatchUpdateJobsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if jobs is not None: - request.jobs = jobs - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_update_jobs] - - # 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, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - job_service.BatchUpdateJobsResponse, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - def delete_job(self, - request: Union[job_service.DeleteJobRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes the specified job. - Typically, the job becomes unsearchable within 10 - seconds, but it may take up to 5 minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_delete_job(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.DeleteJobRequest( - name="name_value", - ) - - # Make the request - client.delete_job(request=request) - - Args: - request (Union[google.cloud.talent_v4.types.DeleteJobRequest, dict]): - The request object. Delete job request. - name (str): - Required. The resource name of the job to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/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 job_service.DeleteJobRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.DeleteJobRequest): - request = job_service.DeleteJobRequest(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_job] - - # 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 batch_delete_jobs(self, - request: Union[job_service.BatchDeleteJobsRequest, dict] = None, - *, - parent: str = None, - names: Sequence[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Begins executing a batch delete jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_batch_delete_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.BatchDeleteJobsRequest( - parent="parent_value", - ) - - # Make the request - operation = client.batch_delete_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.BatchDeleteJobsRequest, dict]): - The request object. Request to delete a batch of jobs. - parent (str): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenants/bar". - - The parent of all of the jobs specified in ``names`` - must match this field. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - names (Sequence[str]): - The names of the jobs to delete. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - A maximum of 200 jobs can be deleted in a batch. - - This corresponds to the ``names`` 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4.types.BatchDeleteJobsResponse` The result of [JobService.BatchDeleteJobs][google.cloud.talent.v4.JobService.BatchDeleteJobs]. It's used to - replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, names]) - 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 job_service.BatchDeleteJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.BatchDeleteJobsRequest): - request = job_service.BatchDeleteJobsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if names is not None: - request.names = names - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_delete_jobs] - - # 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, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - job_service.BatchDeleteJobsResponse, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - def list_jobs(self, - request: Union[job_service.ListJobsRequest, dict] = None, - *, - parent: str = None, - filter: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListJobsPager: - r"""Lists jobs by filter. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_list_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.ListJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - page_result = client.list_jobs(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.ListJobsRequest, dict]): - The request object. List jobs request. - parent (str): - Required. The resource name of the tenant under which - the job 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. - filter (str): - Required. The filter string specifies the jobs to be - enumerated. - - Supported operator: =, AND - - The fields eligible for filtering are: - - - ``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" - - requisitionId = "req-1" - - requisitionId = "req-1" AND status = "EXPIRED" - - This corresponds to the ``filter`` 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_v4.services.job_service.pagers.ListJobsPager: - List jobs response. - 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, filter]) - 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 job_service.ListJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.ListJobsRequest): - request = job_service.ListJobsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if filter is not None: - request.filter = filter - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_jobs] - - # 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.ListJobsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def search_jobs(self, - request: Union[job_service.SearchJobsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> job_service.SearchJobsResponse: - r"""Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - - This call constrains the - [visibility][google.cloud.talent.v4.Job.visibility] of jobs - present in the database, and only returns jobs that the caller - has permission to search against. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_search_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - response = client.search_jobs(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.SearchJobsRequest, dict]): - The request object. The Request body of the `SearchJobs` - 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_v4.types.SearchJobsResponse: - Response for SearchJob method. - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a job_service.SearchJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.SearchJobsRequest): - request = job_service.SearchJobsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.search_jobs] - - # 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 search_jobs_for_alert(self, - request: Union[job_service.SearchJobsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> job_service.SearchJobsResponse: - r"""Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - - This API call is intended for the use case of targeting passive - job seekers (for example, job seekers who have signed up to - receive email alerts about potential job opportunities), it has - different algorithmic adjustments that are designed to - specifically target passive job seekers. - - This call constrains the - [visibility][google.cloud.talent.v4.Job.visibility] of jobs - present in the database, and only returns jobs the caller has - permission to search against. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_search_jobs_for_alert(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - response = client.search_jobs_for_alert(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.SearchJobsRequest, dict]): - The request object. The Request body of the `SearchJobs` - 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_v4.types.SearchJobsResponse: - Response for SearchJob method. - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a job_service.SearchJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.SearchJobsRequest): - request = job_service.SearchJobsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.search_jobs_for_alert] - - # 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 __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__ = ( - "JobServiceClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/pagers.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/pagers.py deleted file mode 100644 index b0dbb50e..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/pagers.py +++ /dev/null @@ -1,140 +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, Sequence, Tuple, Optional, Iterator - -from google.cloud.talent_v4.types import job -from google.cloud.talent_v4.types import job_service - - -class ListJobsPager: - """A pager for iterating through ``list_jobs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4.types.ListJobsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``jobs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListJobs`` requests and continue to iterate - through the ``jobs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4.types.ListJobsResponse` - 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[..., job_service.ListJobsResponse], - request: job_service.ListJobsRequest, - response: job_service.ListJobsResponse, - *, - 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_v4.types.ListJobsRequest): - The initial request object. - response (google.cloud.talent_v4.types.ListJobsResponse): - 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 = job_service.ListJobsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[job_service.ListJobsResponse]: - 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[job.Job]: - for page in self.pages: - yield from page.jobs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListJobsAsyncPager: - """A pager for iterating through ``list_jobs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4.types.ListJobsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``jobs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListJobs`` requests and continue to iterate - through the ``jobs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4.types.ListJobsResponse` - 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[job_service.ListJobsResponse]], - request: job_service.ListJobsRequest, - response: job_service.ListJobsResponse, - *, - 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_v4.types.ListJobsRequest): - The initial request object. - response (google.cloud.talent_v4.types.ListJobsResponse): - 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 = job_service.ListJobsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[job_service.ListJobsResponse]: - 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[job.Job]: - async def async_generator(): - async for page in self.pages: - for response in page.jobs: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/__init__.py deleted file mode 100644 index 05345304..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/__init__.py +++ /dev/null @@ -1,33 +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 JobServiceTransport -from .grpc import JobServiceGrpcTransport -from .grpc_asyncio import JobServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[JobServiceTransport]] -_transport_registry['grpc'] = JobServiceGrpcTransport -_transport_registry['grpc_asyncio'] = JobServiceGrpcAsyncIOTransport - -__all__ = ( - 'JobServiceTransport', - 'JobServiceGrpcTransport', - 'JobServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/base.py deleted file mode 100644 index 3458a8f0..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/base.py +++ /dev/null @@ -1,312 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4.types import job -from google.cloud.talent_v4.types import job as gct_job -from google.cloud.talent_v4.types import job_service -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -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 JobServiceTransport(abc.ABC): - """Abstract transport class for JobService.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.create_job: gapic_v1.method.wrap_method( - self.create_job, - default_timeout=30.0, - client_info=client_info, - ), - self.batch_create_jobs: gapic_v1.method.wrap_method( - self.batch_create_jobs, - default_timeout=30.0, - client_info=client_info, - ), - self.get_job: gapic_v1.method.wrap_method( - self.get_job, - 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_job: gapic_v1.method.wrap_method( - self.update_job, - default_timeout=30.0, - client_info=client_info, - ), - self.batch_update_jobs: gapic_v1.method.wrap_method( - self.batch_update_jobs, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_job: gapic_v1.method.wrap_method( - self.delete_job, - 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.batch_delete_jobs: gapic_v1.method.wrap_method( - self.batch_delete_jobs, - default_timeout=30.0, - client_info=client_info, - ), - self.list_jobs: gapic_v1.method.wrap_method( - self.list_jobs, - 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_jobs: gapic_v1.method.wrap_method( - self.search_jobs, - default_timeout=30.0, - client_info=client_info, - ), - self.search_jobs_for_alert: gapic_v1.method.wrap_method( - self.search_jobs_for_alert, - 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 operations_client(self): - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def create_job(self) -> Callable[ - [job_service.CreateJobRequest], - Union[ - gct_job.Job, - Awaitable[gct_job.Job] - ]]: - raise NotImplementedError() - - @property - def batch_create_jobs(self) -> Callable[ - [job_service.BatchCreateJobsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_job(self) -> Callable[ - [job_service.GetJobRequest], - Union[ - job.Job, - Awaitable[job.Job] - ]]: - raise NotImplementedError() - - @property - def update_job(self) -> Callable[ - [job_service.UpdateJobRequest], - Union[ - gct_job.Job, - Awaitable[gct_job.Job] - ]]: - raise NotImplementedError() - - @property - def batch_update_jobs(self) -> Callable[ - [job_service.BatchUpdateJobsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_job(self) -> Callable[ - [job_service.DeleteJobRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def batch_delete_jobs(self) -> Callable[ - [job_service.BatchDeleteJobsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_jobs(self) -> Callable[ - [job_service.ListJobsRequest], - Union[ - job_service.ListJobsResponse, - Awaitable[job_service.ListJobsResponse] - ]]: - raise NotImplementedError() - - @property - def search_jobs(self) -> Callable[ - [job_service.SearchJobsRequest], - Union[ - job_service.SearchJobsResponse, - Awaitable[job_service.SearchJobsResponse] - ]]: - raise NotImplementedError() - - @property - def search_jobs_for_alert(self) -> Callable[ - [job_service.SearchJobsRequest], - Union[ - job_service.SearchJobsResponse, - Awaitable[job_service.SearchJobsResponse] - ]]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'JobServiceTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc.py deleted file mode 100644 index f6213994..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc.py +++ /dev/null @@ -1,547 +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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4.types import job -from google.cloud.talent_v4.types import job as gct_job -from google.cloud.talent_v4.types import job_service -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import JobServiceTransport, DEFAULT_CLIENT_INFO - - -class JobServiceGrpcTransport(JobServiceTransport): - """gRPC backend transport for JobService. - - A service handles job management, including job 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, - api_audience: Optional[str] = None, - ) -> 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] = {} - self._operations_client: Optional[operations_v1.OperationsClient] = None - - 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, - api_audience=api_audience, - ) - - 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 operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_job(self) -> Callable[ - [job_service.CreateJobRequest], - gct_job.Job]: - r"""Return a callable for the create job method over gRPC. - - Creates a new job. - Typically, the job becomes searchable within 10 seconds, - but it may take up to 5 minutes. - - Returns: - Callable[[~.CreateJobRequest], - ~.Job]: - 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_job' not in self._stubs: - self._stubs['create_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/CreateJob', - request_serializer=job_service.CreateJobRequest.serialize, - response_deserializer=gct_job.Job.deserialize, - ) - return self._stubs['create_job'] - - @property - def batch_create_jobs(self) -> Callable[ - [job_service.BatchCreateJobsRequest], - operations_pb2.Operation]: - r"""Return a callable for the batch create jobs method over gRPC. - - Begins executing a batch create jobs operation. - - Returns: - Callable[[~.BatchCreateJobsRequest], - ~.Operation]: - 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 'batch_create_jobs' not in self._stubs: - self._stubs['batch_create_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/BatchCreateJobs', - request_serializer=job_service.BatchCreateJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_create_jobs'] - - @property - def get_job(self) -> Callable[ - [job_service.GetJobRequest], - job.Job]: - r"""Return a callable for the get job method over gRPC. - - Retrieves the specified job, whose status is OPEN or - recently EXPIRED within the last 90 days. - - Returns: - Callable[[~.GetJobRequest], - ~.Job]: - 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_job' not in self._stubs: - self._stubs['get_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/GetJob', - request_serializer=job_service.GetJobRequest.serialize, - response_deserializer=job.Job.deserialize, - ) - return self._stubs['get_job'] - - @property - def update_job(self) -> Callable[ - [job_service.UpdateJobRequest], - gct_job.Job]: - r"""Return a callable for the update job method over gRPC. - - Updates specified job. - Typically, updated contents become visible in search - results within 10 seconds, but it may take up to 5 - minutes. - - Returns: - Callable[[~.UpdateJobRequest], - ~.Job]: - 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_job' not in self._stubs: - self._stubs['update_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/UpdateJob', - request_serializer=job_service.UpdateJobRequest.serialize, - response_deserializer=gct_job.Job.deserialize, - ) - return self._stubs['update_job'] - - @property - def batch_update_jobs(self) -> Callable[ - [job_service.BatchUpdateJobsRequest], - operations_pb2.Operation]: - r"""Return a callable for the batch update jobs method over gRPC. - - Begins executing a batch update jobs operation. - - Returns: - Callable[[~.BatchUpdateJobsRequest], - ~.Operation]: - 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 'batch_update_jobs' not in self._stubs: - self._stubs['batch_update_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/BatchUpdateJobs', - request_serializer=job_service.BatchUpdateJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_update_jobs'] - - @property - def delete_job(self) -> Callable[ - [job_service.DeleteJobRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete job method over gRPC. - - Deletes the specified job. - Typically, the job becomes unsearchable within 10 - seconds, but it may take up to 5 minutes. - - Returns: - Callable[[~.DeleteJobRequest], - ~.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_job' not in self._stubs: - self._stubs['delete_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/DeleteJob', - request_serializer=job_service.DeleteJobRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_job'] - - @property - def batch_delete_jobs(self) -> Callable[ - [job_service.BatchDeleteJobsRequest], - operations_pb2.Operation]: - r"""Return a callable for the batch delete jobs method over gRPC. - - Begins executing a batch delete jobs operation. - - Returns: - Callable[[~.BatchDeleteJobsRequest], - ~.Operation]: - 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 'batch_delete_jobs' not in self._stubs: - self._stubs['batch_delete_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/BatchDeleteJobs', - request_serializer=job_service.BatchDeleteJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_delete_jobs'] - - @property - def list_jobs(self) -> Callable[ - [job_service.ListJobsRequest], - job_service.ListJobsResponse]: - r"""Return a callable for the list jobs method over gRPC. - - Lists jobs by filter. - - Returns: - Callable[[~.ListJobsRequest], - ~.ListJobsResponse]: - 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_jobs' not in self._stubs: - self._stubs['list_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/ListJobs', - request_serializer=job_service.ListJobsRequest.serialize, - response_deserializer=job_service.ListJobsResponse.deserialize, - ) - return self._stubs['list_jobs'] - - @property - def search_jobs(self) -> Callable[ - [job_service.SearchJobsRequest], - job_service.SearchJobsResponse]: - r"""Return a callable for the search jobs method over gRPC. - - Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - - This call constrains the - [visibility][google.cloud.talent.v4.Job.visibility] of jobs - present in the database, and only returns jobs that the caller - has permission to search against. - - Returns: - Callable[[~.SearchJobsRequest], - ~.SearchJobsResponse]: - 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_jobs' not in self._stubs: - self._stubs['search_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/SearchJobs', - request_serializer=job_service.SearchJobsRequest.serialize, - response_deserializer=job_service.SearchJobsResponse.deserialize, - ) - return self._stubs['search_jobs'] - - @property - def search_jobs_for_alert(self) -> Callable[ - [job_service.SearchJobsRequest], - job_service.SearchJobsResponse]: - r"""Return a callable for the search jobs for alert method over gRPC. - - Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - - This API call is intended for the use case of targeting passive - job seekers (for example, job seekers who have signed up to - receive email alerts about potential job opportunities), it has - different algorithmic adjustments that are designed to - specifically target passive job seekers. - - This call constrains the - [visibility][google.cloud.talent.v4.Job.visibility] of jobs - present in the database, and only returns jobs the caller has - permission to search against. - - Returns: - Callable[[~.SearchJobsRequest], - ~.SearchJobsResponse]: - 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_jobs_for_alert' not in self._stubs: - self._stubs['search_jobs_for_alert'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/SearchJobsForAlert', - request_serializer=job_service.SearchJobsRequest.serialize, - response_deserializer=job_service.SearchJobsResponse.deserialize, - ) - return self._stubs['search_jobs_for_alert'] - - def close(self): - self.grpc_channel.close() - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'JobServiceGrpcTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py deleted file mode 100644 index 6762f591..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,546 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4.types import job -from google.cloud.talent_v4.types import job as gct_job -from google.cloud.talent_v4.types import job_service -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import JobServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import JobServiceGrpcTransport - - -class JobServiceGrpcAsyncIOTransport(JobServiceTransport): - """gRPC AsyncIO backend transport for JobService. - - A service handles job management, including job 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, - api_audience: Optional[str] = None, - ) -> 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] = {} - self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None - - 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, - api_audience=api_audience, - ) - - 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 operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_job(self) -> Callable[ - [job_service.CreateJobRequest], - Awaitable[gct_job.Job]]: - r"""Return a callable for the create job method over gRPC. - - Creates a new job. - Typically, the job becomes searchable within 10 seconds, - but it may take up to 5 minutes. - - Returns: - Callable[[~.CreateJobRequest], - Awaitable[~.Job]]: - 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_job' not in self._stubs: - self._stubs['create_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/CreateJob', - request_serializer=job_service.CreateJobRequest.serialize, - response_deserializer=gct_job.Job.deserialize, - ) - return self._stubs['create_job'] - - @property - def batch_create_jobs(self) -> Callable[ - [job_service.BatchCreateJobsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the batch create jobs method over gRPC. - - Begins executing a batch create jobs operation. - - Returns: - Callable[[~.BatchCreateJobsRequest], - Awaitable[~.Operation]]: - 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 'batch_create_jobs' not in self._stubs: - self._stubs['batch_create_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/BatchCreateJobs', - request_serializer=job_service.BatchCreateJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_create_jobs'] - - @property - def get_job(self) -> Callable[ - [job_service.GetJobRequest], - Awaitable[job.Job]]: - r"""Return a callable for the get job method over gRPC. - - Retrieves the specified job, whose status is OPEN or - recently EXPIRED within the last 90 days. - - Returns: - Callable[[~.GetJobRequest], - Awaitable[~.Job]]: - 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_job' not in self._stubs: - self._stubs['get_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/GetJob', - request_serializer=job_service.GetJobRequest.serialize, - response_deserializer=job.Job.deserialize, - ) - return self._stubs['get_job'] - - @property - def update_job(self) -> Callable[ - [job_service.UpdateJobRequest], - Awaitable[gct_job.Job]]: - r"""Return a callable for the update job method over gRPC. - - Updates specified job. - Typically, updated contents become visible in search - results within 10 seconds, but it may take up to 5 - minutes. - - Returns: - Callable[[~.UpdateJobRequest], - Awaitable[~.Job]]: - 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_job' not in self._stubs: - self._stubs['update_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/UpdateJob', - request_serializer=job_service.UpdateJobRequest.serialize, - response_deserializer=gct_job.Job.deserialize, - ) - return self._stubs['update_job'] - - @property - def batch_update_jobs(self) -> Callable[ - [job_service.BatchUpdateJobsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the batch update jobs method over gRPC. - - Begins executing a batch update jobs operation. - - Returns: - Callable[[~.BatchUpdateJobsRequest], - Awaitable[~.Operation]]: - 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 'batch_update_jobs' not in self._stubs: - self._stubs['batch_update_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/BatchUpdateJobs', - request_serializer=job_service.BatchUpdateJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_update_jobs'] - - @property - def delete_job(self) -> Callable[ - [job_service.DeleteJobRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete job method over gRPC. - - Deletes the specified job. - Typically, the job becomes unsearchable within 10 - seconds, but it may take up to 5 minutes. - - Returns: - Callable[[~.DeleteJobRequest], - 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_job' not in self._stubs: - self._stubs['delete_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/DeleteJob', - request_serializer=job_service.DeleteJobRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_job'] - - @property - def batch_delete_jobs(self) -> Callable[ - [job_service.BatchDeleteJobsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the batch delete jobs method over gRPC. - - Begins executing a batch delete jobs operation. - - Returns: - Callable[[~.BatchDeleteJobsRequest], - Awaitable[~.Operation]]: - 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 'batch_delete_jobs' not in self._stubs: - self._stubs['batch_delete_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/BatchDeleteJobs', - request_serializer=job_service.BatchDeleteJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_delete_jobs'] - - @property - def list_jobs(self) -> Callable[ - [job_service.ListJobsRequest], - Awaitable[job_service.ListJobsResponse]]: - r"""Return a callable for the list jobs method over gRPC. - - Lists jobs by filter. - - Returns: - Callable[[~.ListJobsRequest], - Awaitable[~.ListJobsResponse]]: - 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_jobs' not in self._stubs: - self._stubs['list_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/ListJobs', - request_serializer=job_service.ListJobsRequest.serialize, - response_deserializer=job_service.ListJobsResponse.deserialize, - ) - return self._stubs['list_jobs'] - - @property - def search_jobs(self) -> Callable[ - [job_service.SearchJobsRequest], - Awaitable[job_service.SearchJobsResponse]]: - r"""Return a callable for the search jobs method over gRPC. - - Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - - This call constrains the - [visibility][google.cloud.talent.v4.Job.visibility] of jobs - present in the database, and only returns jobs that the caller - has permission to search against. - - Returns: - Callable[[~.SearchJobsRequest], - Awaitable[~.SearchJobsResponse]]: - 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_jobs' not in self._stubs: - self._stubs['search_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/SearchJobs', - request_serializer=job_service.SearchJobsRequest.serialize, - response_deserializer=job_service.SearchJobsResponse.deserialize, - ) - return self._stubs['search_jobs'] - - @property - def search_jobs_for_alert(self) -> Callable[ - [job_service.SearchJobsRequest], - Awaitable[job_service.SearchJobsResponse]]: - r"""Return a callable for the search jobs for alert method over gRPC. - - Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - - This API call is intended for the use case of targeting passive - job seekers (for example, job seekers who have signed up to - receive email alerts about potential job opportunities), it has - different algorithmic adjustments that are designed to - specifically target passive job seekers. - - This call constrains the - [visibility][google.cloud.talent.v4.Job.visibility] of jobs - present in the database, and only returns jobs the caller has - permission to search against. - - Returns: - Callable[[~.SearchJobsRequest], - Awaitable[~.SearchJobsResponse]]: - 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_jobs_for_alert' not in self._stubs: - self._stubs['search_jobs_for_alert'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.JobService/SearchJobsForAlert', - request_serializer=job_service.SearchJobsRequest.serialize, - response_deserializer=job_service.SearchJobsResponse.deserialize, - ) - return self._stubs['search_jobs_for_alert'] - - def close(self): - return self.grpc_channel.close() - - -__all__ = ( - 'JobServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/__init__.py deleted file mode 100644 index 03b84ddf..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_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 .client import TenantServiceClient -from .async_client import TenantServiceAsyncClient - -__all__ = ( - 'TenantServiceClient', - 'TenantServiceAsyncClient', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/async_client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/async_client.py deleted file mode 100644 index 48325618..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/async_client.py +++ /dev/null @@ -1,797 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4.services.tenant_service import pagers -from google.cloud.talent_v4.types import tenant -from google.cloud.talent_v4.types import tenant as gct_tenant -from google.cloud.talent_v4.types import tenant_service -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import TenantServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport -from .client import TenantServiceClient - - -class TenantServiceAsyncClient: - """A service that handles tenant management, including CRUD and - enumeration. - """ - - _client: TenantServiceClient - - DEFAULT_ENDPOINT = TenantServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = TenantServiceClient.DEFAULT_MTLS_ENDPOINT - - tenant_path = staticmethod(TenantServiceClient.tenant_path) - parse_tenant_path = staticmethod(TenantServiceClient.parse_tenant_path) - common_billing_account_path = staticmethod(TenantServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(TenantServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(TenantServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(TenantServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(TenantServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(TenantServiceClient.parse_common_organization_path) - common_project_path = staticmethod(TenantServiceClient.common_project_path) - parse_common_project_path = staticmethod(TenantServiceClient.parse_common_project_path) - common_location_path = staticmethod(TenantServiceClient.common_location_path) - parse_common_location_path = staticmethod(TenantServiceClient.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: - TenantServiceAsyncClient: The constructed client. - """ - return TenantServiceClient.from_service_account_info.__func__(TenantServiceAsyncClient, 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: - TenantServiceAsyncClient: The constructed client. - """ - return TenantServiceClient.from_service_account_file.__func__(TenantServiceAsyncClient, 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 TenantServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> TenantServiceTransport: - """Returns the transport used by the client instance. - - Returns: - TenantServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(TenantServiceClient).get_transport_class, type(TenantServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, TenantServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the tenant 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, ~.TenantServiceTransport]): 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 = TenantServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_tenant(self, - request: Union[tenant_service.CreateTenantRequest, dict] = None, - *, - parent: str = None, - tenant: gct_tenant.Tenant = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_tenant.Tenant: - r"""Creates a new tenant entity. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_create_tenant(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - tenant = talent_v4.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4.CreateTenantRequest( - parent="parent_value", - tenant=tenant, - ) - - # Make the request - response = await client.create_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CreateTenantRequest, dict]): - The request object. The Request of the CreateTenant - method. - parent (:class:`str`): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tenant (:class:`google.cloud.talent_v4.types.Tenant`): - Required. The tenant to be created. - This corresponds to the ``tenant`` 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_v4.types.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - jobs. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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, tenant]) - 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 = tenant_service.CreateTenantRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if tenant is not None: - request.tenant = tenant - - # 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_tenant, - 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_tenant(self, - request: Union[tenant_service.GetTenantRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> tenant.Tenant: - r"""Retrieves specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_get_tenant(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.GetTenantRequest( - name="name_value", - ) - - # Make the request - response = await client.get_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.GetTenantRequest, dict]): - The request object. Request for getting a tenant by - name. - name (:class:`str`): - Required. The resource name of the tenant to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenants/bar". - - 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_v4.types.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - jobs. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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 = tenant_service.GetTenantRequest(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_tenant, - 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_tenant(self, - request: Union[tenant_service.UpdateTenantRequest, dict] = None, - *, - tenant: gct_tenant.Tenant = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_tenant.Tenant: - r"""Updates specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_update_tenant(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - tenant = talent_v4.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4.UpdateTenantRequest( - tenant=tenant, - ) - - # Make the request - response = await client.update_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.UpdateTenantRequest, dict]): - The request object. Request for updating a specified - tenant. - tenant (:class:`google.cloud.talent_v4.types.Tenant`): - Required. The tenant resource to - replace the current resource in the - system. - - This corresponds to the ``tenant`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Strongly recommended for the best service experience. - - If - [update_mask][google.cloud.talent.v4.UpdateTenantRequest.update_mask] - is provided, only the specified fields in - [tenant][google.cloud.talent.v4.UpdateTenantRequest.tenant] - are updated. Otherwise all the fields are updated. - - A field mask to specify the tenant fields to be updated. - Only top level fields of - [Tenant][google.cloud.talent.v4.Tenant] are supported. - - This corresponds to the ``update_mask`` 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_v4.types.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - jobs. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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([tenant, update_mask]) - 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 = tenant_service.UpdateTenantRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if tenant is not None: - request.tenant = tenant - if update_mask is not None: - request.update_mask = update_mask - - # 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_tenant, - 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(( - ("tenant.name", request.tenant.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_tenant(self, - request: Union[tenant_service.DeleteTenantRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_delete_tenant(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.DeleteTenantRequest( - name="name_value", - ) - - # Make the request - await client.delete_tenant(request=request) - - Args: - request (Union[google.cloud.talent_v4.types.DeleteTenantRequest, dict]): - The request object. Request to delete a tenant. - name (:class:`str`): - Required. The resource name of the tenant to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenants/bar". - - 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 = tenant_service.DeleteTenantRequest(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_tenant, - 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_tenants(self, - request: Union[tenant_service.ListTenantsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTenantsAsyncPager: - r"""Lists all tenants associated with the project. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - async def sample_list_tenants(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.ListTenantsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_tenants(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.ListTenantsRequest, dict]): - The request object. List tenants for which the client - has ACL visibility. - parent (:class:`str`): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - - 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_v4.services.tenant_service.pagers.ListTenantsAsyncPager: - The List tenants 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 = tenant_service.ListTenantsRequest(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_tenants, - 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.ListTenantsAsyncPager( - 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__ = ( - "TenantServiceAsyncClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/client.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/client.py deleted file mode 100644 index da9b745f..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/client.py +++ /dev/null @@ -1,976 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4.services.tenant_service import pagers -from google.cloud.talent_v4.types import tenant -from google.cloud.talent_v4.types import tenant as gct_tenant -from google.cloud.talent_v4.types import tenant_service -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import TenantServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import TenantServiceGrpcTransport -from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport - - -class TenantServiceClientMeta(type): - """Metaclass for the TenantService 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[TenantServiceTransport]] - _transport_registry["grpc"] = TenantServiceGrpcTransport - _transport_registry["grpc_asyncio"] = TenantServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[TenantServiceTransport]: - """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 TenantServiceClient(metaclass=TenantServiceClientMeta): - """A service that handles tenant 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: - TenantServiceClient: 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: - TenantServiceClient: 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) -> TenantServiceTransport: - """Returns the transport used by the client instance. - - Returns: - TenantServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @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, TenantServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the tenant 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, TenantServiceTransport]): 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, TenantServiceTransport): - # transport is a TenantServiceTransport 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, - api_audience=client_options.api_audience, - ) - - def create_tenant(self, - request: Union[tenant_service.CreateTenantRequest, dict] = None, - *, - parent: str = None, - tenant: gct_tenant.Tenant = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_tenant.Tenant: - r"""Creates a new tenant entity. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_create_tenant(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - tenant = talent_v4.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4.CreateTenantRequest( - parent="parent_value", - tenant=tenant, - ) - - # Make the request - response = client.create_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.CreateTenantRequest, dict]): - The request object. The Request of the CreateTenant - method. - parent (str): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tenant (google.cloud.talent_v4.types.Tenant): - Required. The tenant to be created. - This corresponds to the ``tenant`` 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_v4.types.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - jobs. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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, tenant]) - 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 tenant_service.CreateTenantRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.CreateTenantRequest): - request = tenant_service.CreateTenantRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if tenant is not None: - request.tenant = tenant - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_tenant] - - # 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_tenant(self, - request: Union[tenant_service.GetTenantRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> tenant.Tenant: - r"""Retrieves specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_get_tenant(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4.GetTenantRequest( - name="name_value", - ) - - # Make the request - response = client.get_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.GetTenantRequest, dict]): - The request object. Request for getting a tenant by - name. - name (str): - Required. The resource name of the tenant to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenants/bar". - - 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_v4.types.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - jobs. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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 tenant_service.GetTenantRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.GetTenantRequest): - request = tenant_service.GetTenantRequest(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_tenant] - - # 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_tenant(self, - request: Union[tenant_service.UpdateTenantRequest, dict] = None, - *, - tenant: gct_tenant.Tenant = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_tenant.Tenant: - r"""Updates specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_update_tenant(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - tenant = talent_v4.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4.UpdateTenantRequest( - tenant=tenant, - ) - - # Make the request - response = client.update_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.UpdateTenantRequest, dict]): - The request object. Request for updating a specified - tenant. - tenant (google.cloud.talent_v4.types.Tenant): - Required. The tenant resource to - replace the current resource in the - system. - - This corresponds to the ``tenant`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Strongly recommended for the best service experience. - - If - [update_mask][google.cloud.talent.v4.UpdateTenantRequest.update_mask] - is provided, only the specified fields in - [tenant][google.cloud.talent.v4.UpdateTenantRequest.tenant] - are updated. Otherwise all the fields are updated. - - A field mask to specify the tenant fields to be updated. - Only top level fields of - [Tenant][google.cloud.talent.v4.Tenant] are supported. - - This corresponds to the ``update_mask`` 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_v4.types.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - jobs. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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([tenant, update_mask]) - 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 tenant_service.UpdateTenantRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.UpdateTenantRequest): - request = tenant_service.UpdateTenantRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if tenant is not None: - request.tenant = tenant - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_tenant] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("tenant.name", request.tenant.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_tenant(self, - request: Union[tenant_service.DeleteTenantRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_delete_tenant(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4.DeleteTenantRequest( - name="name_value", - ) - - # Make the request - client.delete_tenant(request=request) - - Args: - request (Union[google.cloud.talent_v4.types.DeleteTenantRequest, dict]): - The request object. Request to delete a tenant. - name (str): - Required. The resource name of the tenant to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenants/bar". - - 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 tenant_service.DeleteTenantRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.DeleteTenantRequest): - request = tenant_service.DeleteTenantRequest(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_tenant] - - # 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_tenants(self, - request: Union[tenant_service.ListTenantsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTenantsPager: - r"""Lists all tenants associated with the project. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4 - - def sample_list_tenants(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4.ListTenantsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_tenants(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4.types.ListTenantsRequest, dict]): - The request object. List tenants for which the client - has ACL visibility. - parent (str): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - - 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_v4.services.tenant_service.pagers.ListTenantsPager: - The List tenants 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 tenant_service.ListTenantsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.ListTenantsRequest): - request = tenant_service.ListTenantsRequest(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_tenants] - - # 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.ListTenantsPager( - 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__ = ( - "TenantServiceClient", -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/pagers.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/pagers.py deleted file mode 100644 index f8a44bfc..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/pagers.py +++ /dev/null @@ -1,140 +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, Sequence, Tuple, Optional, Iterator - -from google.cloud.talent_v4.types import tenant -from google.cloud.talent_v4.types import tenant_service - - -class ListTenantsPager: - """A pager for iterating through ``list_tenants`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4.types.ListTenantsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``tenants`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListTenants`` requests and continue to iterate - through the ``tenants`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4.types.ListTenantsResponse` - 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[..., tenant_service.ListTenantsResponse], - request: tenant_service.ListTenantsRequest, - response: tenant_service.ListTenantsResponse, - *, - 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_v4.types.ListTenantsRequest): - The initial request object. - response (google.cloud.talent_v4.types.ListTenantsResponse): - 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 = tenant_service.ListTenantsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[tenant_service.ListTenantsResponse]: - 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[tenant.Tenant]: - for page in self.pages: - yield from page.tenants - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTenantsAsyncPager: - """A pager for iterating through ``list_tenants`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4.types.ListTenantsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``tenants`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListTenants`` requests and continue to iterate - through the ``tenants`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4.types.ListTenantsResponse` - 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[tenant_service.ListTenantsResponse]], - request: tenant_service.ListTenantsRequest, - response: tenant_service.ListTenantsResponse, - *, - 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_v4.types.ListTenantsRequest): - The initial request object. - response (google.cloud.talent_v4.types.ListTenantsResponse): - 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 = tenant_service.ListTenantsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[tenant_service.ListTenantsResponse]: - 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[tenant.Tenant]: - async def async_generator(): - async for page in self.pages: - for response in page.tenants: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/__init__.py deleted file mode 100644 index 59edc02c..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/__init__.py +++ /dev/null @@ -1,33 +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 TenantServiceTransport -from .grpc import TenantServiceGrpcTransport -from .grpc_asyncio import TenantServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[TenantServiceTransport]] -_transport_registry['grpc'] = TenantServiceGrpcTransport -_transport_registry['grpc_asyncio'] = TenantServiceGrpcAsyncIOTransport - -__all__ = ( - 'TenantServiceTransport', - 'TenantServiceGrpcTransport', - 'TenantServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/base.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/base.py deleted file mode 100644 index 3e72116d..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/base.py +++ /dev/null @@ -1,235 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4.types import tenant -from google.cloud.talent_v4.types import tenant as gct_tenant -from google.cloud.talent_v4.types import tenant_service -from google.protobuf import empty_pb2 # type: ignore - -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 TenantServiceTransport(abc.ABC): - """Abstract transport class for TenantService.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.create_tenant: gapic_v1.method.wrap_method( - self.create_tenant, - default_timeout=30.0, - client_info=client_info, - ), - self.get_tenant: gapic_v1.method.wrap_method( - self.get_tenant, - 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_tenant: gapic_v1.method.wrap_method( - self.update_tenant, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_tenant: gapic_v1.method.wrap_method( - self.delete_tenant, - 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_tenants: gapic_v1.method.wrap_method( - self.list_tenants, - 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_tenant(self) -> Callable[ - [tenant_service.CreateTenantRequest], - Union[ - gct_tenant.Tenant, - Awaitable[gct_tenant.Tenant] - ]]: - raise NotImplementedError() - - @property - def get_tenant(self) -> Callable[ - [tenant_service.GetTenantRequest], - Union[ - tenant.Tenant, - Awaitable[tenant.Tenant] - ]]: - raise NotImplementedError() - - @property - def update_tenant(self) -> Callable[ - [tenant_service.UpdateTenantRequest], - Union[ - gct_tenant.Tenant, - Awaitable[gct_tenant.Tenant] - ]]: - raise NotImplementedError() - - @property - def delete_tenant(self) -> Callable[ - [tenant_service.DeleteTenantRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_tenants(self) -> Callable[ - [tenant_service.ListTenantsRequest], - Union[ - tenant_service.ListTenantsResponse, - Awaitable[tenant_service.ListTenantsResponse] - ]]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'TenantServiceTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc.py deleted file mode 100644 index 616b21b3..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc.py +++ /dev/null @@ -1,372 +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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4.types import tenant -from google.cloud.talent_v4.types import tenant as gct_tenant -from google.cloud.talent_v4.types import tenant_service -from google.protobuf import empty_pb2 # type: ignore -from .base import TenantServiceTransport, DEFAULT_CLIENT_INFO - - -class TenantServiceGrpcTransport(TenantServiceTransport): - """gRPC backend transport for TenantService. - - A service that handles tenant 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_tenant(self) -> Callable[ - [tenant_service.CreateTenantRequest], - gct_tenant.Tenant]: - r"""Return a callable for the create tenant method over gRPC. - - Creates a new tenant entity. - - Returns: - Callable[[~.CreateTenantRequest], - ~.Tenant]: - 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_tenant' not in self._stubs: - self._stubs['create_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/CreateTenant', - request_serializer=tenant_service.CreateTenantRequest.serialize, - response_deserializer=gct_tenant.Tenant.deserialize, - ) - return self._stubs['create_tenant'] - - @property - def get_tenant(self) -> Callable[ - [tenant_service.GetTenantRequest], - tenant.Tenant]: - r"""Return a callable for the get tenant method over gRPC. - - Retrieves specified tenant. - - Returns: - Callable[[~.GetTenantRequest], - ~.Tenant]: - 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_tenant' not in self._stubs: - self._stubs['get_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/GetTenant', - request_serializer=tenant_service.GetTenantRequest.serialize, - response_deserializer=tenant.Tenant.deserialize, - ) - return self._stubs['get_tenant'] - - @property - def update_tenant(self) -> Callable[ - [tenant_service.UpdateTenantRequest], - gct_tenant.Tenant]: - r"""Return a callable for the update tenant method over gRPC. - - Updates specified tenant. - - Returns: - Callable[[~.UpdateTenantRequest], - ~.Tenant]: - 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_tenant' not in self._stubs: - self._stubs['update_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/UpdateTenant', - request_serializer=tenant_service.UpdateTenantRequest.serialize, - response_deserializer=gct_tenant.Tenant.deserialize, - ) - return self._stubs['update_tenant'] - - @property - def delete_tenant(self) -> Callable[ - [tenant_service.DeleteTenantRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete tenant method over gRPC. - - Deletes specified tenant. - - Returns: - Callable[[~.DeleteTenantRequest], - ~.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_tenant' not in self._stubs: - self._stubs['delete_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/DeleteTenant', - request_serializer=tenant_service.DeleteTenantRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_tenant'] - - @property - def list_tenants(self) -> Callable[ - [tenant_service.ListTenantsRequest], - tenant_service.ListTenantsResponse]: - r"""Return a callable for the list tenants method over gRPC. - - Lists all tenants associated with the project. - - Returns: - Callable[[~.ListTenantsRequest], - ~.ListTenantsResponse]: - 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_tenants' not in self._stubs: - self._stubs['list_tenants'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/ListTenants', - request_serializer=tenant_service.ListTenantsRequest.serialize, - response_deserializer=tenant_service.ListTenantsResponse.deserialize, - ) - return self._stubs['list_tenants'] - - def close(self): - self.grpc_channel.close() - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'TenantServiceGrpcTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py b/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py deleted file mode 100644 index cc59c86d..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,371 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4.types import tenant -from google.cloud.talent_v4.types import tenant as gct_tenant -from google.cloud.talent_v4.types import tenant_service -from google.protobuf import empty_pb2 # type: ignore -from .base import TenantServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import TenantServiceGrpcTransport - - -class TenantServiceGrpcAsyncIOTransport(TenantServiceTransport): - """gRPC AsyncIO backend transport for TenantService. - - A service that handles tenant 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_tenant(self) -> Callable[ - [tenant_service.CreateTenantRequest], - Awaitable[gct_tenant.Tenant]]: - r"""Return a callable for the create tenant method over gRPC. - - Creates a new tenant entity. - - Returns: - Callable[[~.CreateTenantRequest], - Awaitable[~.Tenant]]: - 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_tenant' not in self._stubs: - self._stubs['create_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/CreateTenant', - request_serializer=tenant_service.CreateTenantRequest.serialize, - response_deserializer=gct_tenant.Tenant.deserialize, - ) - return self._stubs['create_tenant'] - - @property - def get_tenant(self) -> Callable[ - [tenant_service.GetTenantRequest], - Awaitable[tenant.Tenant]]: - r"""Return a callable for the get tenant method over gRPC. - - Retrieves specified tenant. - - Returns: - Callable[[~.GetTenantRequest], - Awaitable[~.Tenant]]: - 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_tenant' not in self._stubs: - self._stubs['get_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/GetTenant', - request_serializer=tenant_service.GetTenantRequest.serialize, - response_deserializer=tenant.Tenant.deserialize, - ) - return self._stubs['get_tenant'] - - @property - def update_tenant(self) -> Callable[ - [tenant_service.UpdateTenantRequest], - Awaitable[gct_tenant.Tenant]]: - r"""Return a callable for the update tenant method over gRPC. - - Updates specified tenant. - - Returns: - Callable[[~.UpdateTenantRequest], - Awaitable[~.Tenant]]: - 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_tenant' not in self._stubs: - self._stubs['update_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/UpdateTenant', - request_serializer=tenant_service.UpdateTenantRequest.serialize, - response_deserializer=gct_tenant.Tenant.deserialize, - ) - return self._stubs['update_tenant'] - - @property - def delete_tenant(self) -> Callable[ - [tenant_service.DeleteTenantRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete tenant method over gRPC. - - Deletes specified tenant. - - Returns: - Callable[[~.DeleteTenantRequest], - 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_tenant' not in self._stubs: - self._stubs['delete_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/DeleteTenant', - request_serializer=tenant_service.DeleteTenantRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_tenant'] - - @property - def list_tenants(self) -> Callable[ - [tenant_service.ListTenantsRequest], - Awaitable[tenant_service.ListTenantsResponse]]: - r"""Return a callable for the list tenants method over gRPC. - - Lists all tenants associated with the project. - - Returns: - Callable[[~.ListTenantsRequest], - Awaitable[~.ListTenantsResponse]]: - 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_tenants' not in self._stubs: - self._stubs['list_tenants'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4.TenantService/ListTenants', - request_serializer=tenant_service.ListTenantsRequest.serialize, - response_deserializer=tenant_service.ListTenantsResponse.deserialize, - ) - return self._stubs['list_tenants'] - - def close(self): - return self.grpc_channel.close() - - -__all__ = ( - 'TenantServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/__init__.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/__init__.py deleted file mode 100644 index e655d337..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/__init__.py +++ /dev/null @@ -1,164 +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 .common import ( - BatchOperationMetadata, - CompensationInfo, - CustomAttribute, - DeviceInfo, - Location, - RequestMetadata, - ResponseMetadata, - SpellingCorrection, - TimestampRange, - CommuteMethod, - CompanySize, - DegreeType, - EmploymentType, - HtmlSanitization, - JobBenefit, - JobCategory, - JobLevel, - PostingRegion, - Visibility, -) -from .company import ( - Company, -) -from .company_service import ( - CreateCompanyRequest, - DeleteCompanyRequest, - GetCompanyRequest, - ListCompaniesRequest, - ListCompaniesResponse, - UpdateCompanyRequest, -) -from .completion_service import ( - CompleteQueryRequest, - CompleteQueryResponse, -) -from .event import ( - ClientEvent, - JobEvent, -) -from .event_service import ( - CreateClientEventRequest, -) -from .filters import ( - CommuteFilter, - CompensationFilter, - JobQuery, - LocationFilter, -) -from .histogram import ( - HistogramQuery, - HistogramQueryResult, -) -from .job import ( - Job, -) -from .job_service import ( - BatchCreateJobsRequest, - BatchCreateJobsResponse, - BatchDeleteJobsRequest, - BatchDeleteJobsResponse, - BatchUpdateJobsRequest, - BatchUpdateJobsResponse, - CreateJobRequest, - DeleteJobRequest, - GetJobRequest, - JobResult, - ListJobsRequest, - ListJobsResponse, - SearchJobsRequest, - SearchJobsResponse, - UpdateJobRequest, - JobView, -) -from .tenant import ( - Tenant, -) -from .tenant_service import ( - CreateTenantRequest, - DeleteTenantRequest, - GetTenantRequest, - ListTenantsRequest, - ListTenantsResponse, - UpdateTenantRequest, -) - -__all__ = ( - 'BatchOperationMetadata', - 'CompensationInfo', - 'CustomAttribute', - 'DeviceInfo', - 'Location', - 'RequestMetadata', - 'ResponseMetadata', - 'SpellingCorrection', - 'TimestampRange', - 'CommuteMethod', - 'CompanySize', - 'DegreeType', - 'EmploymentType', - 'HtmlSanitization', - 'JobBenefit', - 'JobCategory', - 'JobLevel', - 'PostingRegion', - 'Visibility', - 'Company', - 'CreateCompanyRequest', - 'DeleteCompanyRequest', - 'GetCompanyRequest', - 'ListCompaniesRequest', - 'ListCompaniesResponse', - 'UpdateCompanyRequest', - 'CompleteQueryRequest', - 'CompleteQueryResponse', - 'ClientEvent', - 'JobEvent', - 'CreateClientEventRequest', - 'CommuteFilter', - 'CompensationFilter', - 'JobQuery', - 'LocationFilter', - 'HistogramQuery', - 'HistogramQueryResult', - 'Job', - 'BatchCreateJobsRequest', - 'BatchCreateJobsResponse', - 'BatchDeleteJobsRequest', - 'BatchDeleteJobsResponse', - 'BatchUpdateJobsRequest', - 'BatchUpdateJobsResponse', - 'CreateJobRequest', - 'DeleteJobRequest', - 'GetJobRequest', - 'JobResult', - 'ListJobsRequest', - 'ListJobsResponse', - 'SearchJobsRequest', - 'SearchJobsResponse', - 'UpdateJobRequest', - 'JobView', - 'Tenant', - 'CreateTenantRequest', - 'DeleteTenantRequest', - 'GetTenantRequest', - 'ListTenantsRequest', - 'ListTenantsResponse', - 'UpdateTenantRequest', -) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/common.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/common.py deleted file mode 100644 index d91639c9..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/common.py +++ /dev/null @@ -1,849 +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 proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_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 - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'CompanySize', - 'JobBenefit', - 'DegreeType', - 'EmploymentType', - 'JobLevel', - 'JobCategory', - 'PostingRegion', - 'Visibility', - 'HtmlSanitization', - 'CommuteMethod', - 'TimestampRange', - 'Location', - 'RequestMetadata', - 'ResponseMetadata', - 'DeviceInfo', - 'CustomAttribute', - 'SpellingCorrection', - 'CompensationInfo', - 'BatchOperationMetadata', - }, -) - - -class CompanySize(proto.Enum): - r"""An enum that represents the size of the company.""" - COMPANY_SIZE_UNSPECIFIED = 0 - MINI = 1 - SMALL = 2 - SMEDIUM = 3 - MEDIUM = 4 - BIG = 5 - BIGGER = 6 - GIANT = 7 - - -class JobBenefit(proto.Enum): - r"""An enum that represents employee benefits included with the - job. - """ - JOB_BENEFIT_UNSPECIFIED = 0 - CHILD_CARE = 1 - DENTAL = 2 - DOMESTIC_PARTNER = 3 - FLEXIBLE_HOURS = 4 - MEDICAL = 5 - LIFE_INSURANCE = 6 - PARENTAL_LEAVE = 7 - RETIREMENT_PLAN = 8 - SICK_DAYS = 9 - VACATION = 10 - VISION = 11 - - -class DegreeType(proto.Enum): - r"""Educational degree level defined in International Standard - Classification of Education (ISCED). - """ - DEGREE_TYPE_UNSPECIFIED = 0 - PRIMARY_EDUCATION = 1 - LOWER_SECONDARY_EDUCATION = 2 - UPPER_SECONDARY_EDUCATION = 3 - ADULT_REMEDIAL_EDUCATION = 4 - ASSOCIATES_OR_EQUIVALENT = 5 - BACHELORS_OR_EQUIVALENT = 6 - MASTERS_OR_EQUIVALENT = 7 - DOCTORAL_OR_EQUIVALENT = 8 - - -class EmploymentType(proto.Enum): - r"""An enum that represents the employment type of a job.""" - EMPLOYMENT_TYPE_UNSPECIFIED = 0 - FULL_TIME = 1 - PART_TIME = 2 - CONTRACTOR = 3 - CONTRACT_TO_HIRE = 4 - TEMPORARY = 5 - INTERN = 6 - VOLUNTEER = 7 - PER_DIEM = 8 - FLY_IN_FLY_OUT = 9 - OTHER_EMPLOYMENT_TYPE = 10 - - -class JobLevel(proto.Enum): - r"""An enum that represents the required experience level - required for the job. - """ - JOB_LEVEL_UNSPECIFIED = 0 - ENTRY_LEVEL = 1 - EXPERIENCED = 2 - MANAGER = 3 - DIRECTOR = 4 - EXECUTIVE = 5 - - -class JobCategory(proto.Enum): - r"""An enum that represents the categorization or primary focus - of specific role. This value is different than the "industry" - associated with a role, which is related to the categorization - of the company listing the job. - """ - JOB_CATEGORY_UNSPECIFIED = 0 - ACCOUNTING_AND_FINANCE = 1 - ADMINISTRATIVE_AND_OFFICE = 2 - ADVERTISING_AND_MARKETING = 3 - ANIMAL_CARE = 4 - ART_FASHION_AND_DESIGN = 5 - BUSINESS_OPERATIONS = 6 - CLEANING_AND_FACILITIES = 7 - COMPUTER_AND_IT = 8 - CONSTRUCTION = 9 - CUSTOMER_SERVICE = 10 - EDUCATION = 11 - ENTERTAINMENT_AND_TRAVEL = 12 - FARMING_AND_OUTDOORS = 13 - HEALTHCARE = 14 - HUMAN_RESOURCES = 15 - INSTALLATION_MAINTENANCE_AND_REPAIR = 16 - LEGAL = 17 - MANAGEMENT = 18 - MANUFACTURING_AND_WAREHOUSE = 19 - MEDIA_COMMUNICATIONS_AND_WRITING = 20 - OIL_GAS_AND_MINING = 21 - PERSONAL_CARE_AND_SERVICES = 22 - PROTECTIVE_SERVICES = 23 - REAL_ESTATE = 24 - RESTAURANT_AND_HOSPITALITY = 25 - SALES_AND_RETAIL = 26 - SCIENCE_AND_ENGINEERING = 27 - SOCIAL_SERVICES_AND_NON_PROFIT = 28 - SPORTS_FITNESS_AND_RECREATION = 29 - TRANSPORTATION_AND_LOGISTICS = 30 - - -class PostingRegion(proto.Enum): - r"""An enum that represents the job posting region. In most - cases, job postings don't need to specify a region. If a region - is given, jobs are eligible for searches in the specified - region. - """ - POSTING_REGION_UNSPECIFIED = 0 - ADMINISTRATIVE_AREA = 1 - NATION = 2 - TELECOMMUTE = 3 - - -class Visibility(proto.Enum): - r"""Deprecated. All resources are only visible to the owner. - An enum that represents who has view access to the resource. - """ - _pb_options = {'deprecated': True} - VISIBILITY_UNSPECIFIED = 0 - ACCOUNT_ONLY = 1 - SHARED_WITH_GOOGLE = 2 - SHARED_WITH_PUBLIC = 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 - determine whether and how sanitization is performed on these - fields. - """ - HTML_SANITIZATION_UNSPECIFIED = 0 - HTML_SANITIZATION_DISABLED = 1 - SIMPLE_FORMATTING_ONLY = 2 - - -class CommuteMethod(proto.Enum): - r"""Method for commute. Walking, biking and wheelchair accessible - transit is still in the Preview stage. - """ - COMMUTE_METHOD_UNSPECIFIED = 0 - DRIVING = 1 - TRANSIT = 2 - WALKING = 3 - CYCLING = 4 - TRANSIT_ACCESSIBLE = 5 - - -class TimestampRange(proto.Message): - r"""Message representing a period of time between two timestamps. - - Attributes: - start_time (google.protobuf.timestamp_pb2.Timestamp): - Begin of the period (inclusive). - end_time (google.protobuf.timestamp_pb2.Timestamp): - End of the period (exclusive). - """ - - start_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - - -class Location(proto.Message): - r"""A resource that represents a location with full geographic - information. - - Attributes: - location_type (google.cloud.talent_v4.types.Location.LocationType): - The type of a location, which corresponds to the address - lines field of - [google.type.PostalAddress][google.type.PostalAddress]. For - example, "Downtown, Atlanta, GA, USA" has a type of - [LocationType.NEIGHBORHOOD][google.cloud.talent.v4.Location.LocationType.NEIGHBORHOOD], - and "Kansas City, KS, USA" has a type of - [LocationType.LOCALITY][google.cloud.talent.v4.Location.LocationType.LOCALITY]. - postal_address (google.type.postal_address_pb2.PostalAddress): - Postal address of the location that includes - human readable information, such as postal - delivery and payments addresses. Given a postal - address, a postal service can deliver items to a - premises, P.O. Box, or other delivery location. - lat_lng (google.type.latlng_pb2.LatLng): - An object representing a latitude/longitude - pair. - radius_miles (float): - Radius in miles of the job location. This value is derived - from the location bounding box in which a circle with the - specified radius centered from - [google.type.LatLng][google.type.LatLng] covers the area - associated with the job location. For example, currently, - "Mountain View, CA, USA" has a radius of 6.17 miles. - """ - class LocationType(proto.Enum): - r"""An enum which represents the type of a location.""" - LOCATION_TYPE_UNSPECIFIED = 0 - COUNTRY = 1 - ADMINISTRATIVE_AREA = 2 - SUB_ADMINISTRATIVE_AREA = 3 - LOCALITY = 4 - POSTAL_CODE = 5 - SUB_LOCALITY = 6 - SUB_LOCALITY_1 = 7 - SUB_LOCALITY_2 = 8 - NEIGHBORHOOD = 9 - STREET_ADDRESS = 10 - - location_type = proto.Field( - proto.ENUM, - number=1, - enum=LocationType, - ) - postal_address = proto.Field( - proto.MESSAGE, - number=2, - message=postal_address_pb2.PostalAddress, - ) - lat_lng = proto.Field( - proto.MESSAGE, - number=3, - message=latlng_pb2.LatLng, - ) - radius_miles = proto.Field( - proto.DOUBLE, - number=4, - ) - - -class RequestMetadata(proto.Message): - r"""Meta information related to the job searcher or entity - conducting the job search. This information is used to improve - the performance of the service. - - Attributes: - domain (str): - Required if - [allow_missing_ids][google.cloud.talent.v4.RequestMetadata.allow_missing_ids] - is unset or ``false``. - - The client-defined scope or source of the service call, - which typically is the domain on which the service has been - implemented and is currently being run. - - For example, if the service is being run by client Foo, - Inc., on job board www.foo.com and career site www.bar.com, - then this field is set to "foo.com" for use on the job - board, and "bar.com" for use on the career site. - - Note that any improvements to the model for a particular - tenant site rely on this field being set correctly to a - unique domain. - - The maximum number of allowed characters is 255. - session_id (str): - Required if - [allow_missing_ids][google.cloud.talent.v4.RequestMetadata.allow_missing_ids] - is unset or ``false``. - - A unique session identification string. A session is defined - as the duration of an end user's interaction with the - service over a certain period. Obfuscate this field for - privacy concerns before providing it to the service. - - Note that any improvements to the model for a particular - tenant site rely on this field being set correctly to a - unique session ID. - - The maximum number of allowed characters is 255. - user_id (str): - Required if - [allow_missing_ids][google.cloud.talent.v4.RequestMetadata.allow_missing_ids] - is unset or ``false``. - - A unique user identification string, as determined by the - client. To have the strongest positive impact on search - quality make sure the client-level is unique. Obfuscate this - field for privacy concerns before providing it to the - service. - - Note that any improvements to the model for a particular - tenant site rely on this field being set correctly to a - unique user ID. - - The maximum number of allowed characters is 255. - allow_missing_ids (bool): - Only set when any of - [domain][google.cloud.talent.v4.RequestMetadata.domain], - [session_id][google.cloud.talent.v4.RequestMetadata.session_id] - and - [user_id][google.cloud.talent.v4.RequestMetadata.user_id] - isn't available for some reason. It is highly recommended - not to set this field and provide accurate - [domain][google.cloud.talent.v4.RequestMetadata.domain], - [session_id][google.cloud.talent.v4.RequestMetadata.session_id] - and - [user_id][google.cloud.talent.v4.RequestMetadata.user_id] - for the best service experience. - device_info (google.cloud.talent_v4.types.DeviceInfo): - The type of device used by the job seeker at - the time of the call to the service. - """ - - domain = proto.Field( - proto.STRING, - number=1, - ) - session_id = proto.Field( - proto.STRING, - number=2, - ) - user_id = proto.Field( - proto.STRING, - number=3, - ) - allow_missing_ids = proto.Field( - proto.BOOL, - number=4, - ) - device_info = proto.Field( - proto.MESSAGE, - number=5, - message='DeviceInfo', - ) - - -class ResponseMetadata(proto.Message): - r"""Additional information returned to client, such as debugging - information. - - Attributes: - request_id (str): - A unique id associated with this call. - This id is logged for tracking purposes. - """ - - request_id = proto.Field( - proto.STRING, - number=1, - ) - - -class DeviceInfo(proto.Message): - r"""Device information collected from the job seeker, candidate, - or other entity conducting the job search. Providing this - information improves the quality of the search results across - devices. - - Attributes: - device_type (google.cloud.talent_v4.types.DeviceInfo.DeviceType): - Type of the device. - id (str): - A device-specific ID. The ID must be a unique - identifier that distinguishes the device from - other devices. - """ - class DeviceType(proto.Enum): - r"""An enumeration describing an API access portal and exposure - mechanism. - """ - DEVICE_TYPE_UNSPECIFIED = 0 - WEB = 1 - MOBILE_WEB = 2 - ANDROID = 3 - IOS = 4 - BOT = 5 - OTHER = 6 - - device_type = proto.Field( - proto.ENUM, - number=1, - enum=DeviceType, - ) - id = proto.Field( - proto.STRING, - number=2, - ) - - -class CustomAttribute(proto.Message): - r"""Custom attribute values that are either filterable or - non-filterable. - - Attributes: - string_values (Sequence[str]): - Exactly one of - [string_values][google.cloud.talent.v4.CustomAttribute.string_values] - or - [long_values][google.cloud.talent.v4.CustomAttribute.long_values] - must be specified. - - This field is used to perform a string match - (``CASE_SENSITIVE_MATCH`` or ``CASE_INSENSITIVE_MATCH``) - search. For filterable ``string_value``\ s, a maximum total - number of 200 values is allowed, with each ``string_value`` - has a byte size of no more than 500B. For unfilterable - ``string_values``, the maximum total byte size of - unfilterable ``string_values`` is 50KB. - - Empty string isn't allowed. - long_values (Sequence[int]): - Exactly one of - [string_values][google.cloud.talent.v4.CustomAttribute.string_values] - or - [long_values][google.cloud.talent.v4.CustomAttribute.long_values] - must be specified. - - This field is used to perform number range search. (``EQ``, - ``GT``, ``GE``, ``LE``, ``LT``) over filterable - ``long_value``. - - Currently at most 1 - [long_values][google.cloud.talent.v4.CustomAttribute.long_values] - is supported. - filterable (bool): - If the ``filterable`` flag is true, the custom field values - may be used for custom attribute filters - [JobQuery.custom_attribute_filter][google.cloud.talent.v4.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. - """ - - string_values = proto.RepeatedField( - proto.STRING, - number=1, - ) - long_values = proto.RepeatedField( - proto.INT64, - number=2, - ) - filterable = proto.Field( - proto.BOOL, - number=3, - ) - keyword_searchable = proto.Field( - proto.BOOL, - number=4, - ) - - -class SpellingCorrection(proto.Message): - r"""Spell check result. - - Attributes: - corrected (bool): - Indicates if the query was corrected by the - spell checker. - corrected_text (str): - Correction output consisting of the corrected - keyword string. - corrected_html (str): - Corrected output with html tags to highlight - the corrected words. Corrected words are called - out with the "..." html tags. - For example, the user input query is "software - enginear", where the second word, "enginear," is - incorrect. It should be "engineer". When - spelling correction is enabled, this value is - "software engineer". - """ - - corrected = proto.Field( - proto.BOOL, - number=1, - ) - corrected_text = proto.Field( - proto.STRING, - number=2, - ) - corrected_html = proto.Field( - proto.STRING, - number=3, - ) - - -class CompensationInfo(proto.Message): - r"""Job compensation details. - - Attributes: - entries (Sequence[google.cloud.talent_v4.types.CompensationInfo.CompensationEntry]): - Job compensation information. - - At most one entry can be of type - [CompensationInfo.CompensationType.BASE][google.cloud.talent.v4.CompensationInfo.CompensationType.BASE], - which is referred as **base compensation entry** for the - job. - annualized_base_compensation_range (google.cloud.talent_v4.types.CompensationInfo.CompensationRange): - Output only. Annualized base compensation range. Computed as - base compensation entry's - [CompensationEntry.amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] - times - [CompensationEntry.expected_units_per_year][google.cloud.talent.v4.CompensationInfo.CompensationEntry.expected_units_per_year]. - - See - [CompensationEntry][google.cloud.talent.v4.CompensationInfo.CompensationEntry] - for explanation on compensation annualization. - annualized_total_compensation_range (google.cloud.talent_v4.types.CompensationInfo.CompensationRange): - Output only. Annualized total compensation range. Computed - as all compensation entries' - [CompensationEntry.amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] - times - [CompensationEntry.expected_units_per_year][google.cloud.talent.v4.CompensationInfo.CompensationEntry.expected_units_per_year]. - - See - [CompensationEntry][google.cloud.talent.v4.CompensationInfo.CompensationEntry] - for explanation on compensation annualization. - """ - class CompensationType(proto.Enum): - r"""The type of compensation. - - For compensation amounts specified in non-monetary amounts, describe - the compensation scheme in the - [CompensationEntry.description][google.cloud.talent.v4.CompensationInfo.CompensationEntry.description]. - - For example, tipping format is described in - [CompensationEntry.description][google.cloud.talent.v4.CompensationInfo.CompensationEntry.description] - (for example, "expect 15-20% tips based on customer bill.") and an - estimate of the tips provided in - [CompensationEntry.amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] - or - [CompensationEntry.range][google.cloud.talent.v4.CompensationInfo.CompensationEntry.range] - ($10 per hour). - - For example, equity is described in - [CompensationEntry.description][google.cloud.talent.v4.CompensationInfo.CompensationEntry.description] - (for example, "1% - 2% equity vesting over 4 years, 1 year cliff") - and value estimated in - [CompensationEntry.amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] - or - [CompensationEntry.range][google.cloud.talent.v4.CompensationInfo.CompensationEntry.range]. - If no value estimate is possible, units are - [CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED][google.cloud.talent.v4.CompensationInfo.CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED] - and then further clarified in - [CompensationEntry.description][google.cloud.talent.v4.CompensationInfo.CompensationEntry.description] - field. - """ - COMPENSATION_TYPE_UNSPECIFIED = 0 - BASE = 1 - BONUS = 2 - SIGNING_BONUS = 3 - EQUITY = 4 - PROFIT_SHARING = 5 - COMMISSIONS = 6 - TIPS = 7 - OTHER_COMPENSATION_TYPE = 8 - - class CompensationUnit(proto.Enum): - r"""Pay frequency.""" - COMPENSATION_UNIT_UNSPECIFIED = 0 - HOURLY = 1 - DAILY = 2 - WEEKLY = 3 - MONTHLY = 4 - YEARLY = 5 - ONE_TIME = 6 - OTHER_COMPENSATION_UNIT = 7 - - class CompensationEntry(proto.Message): - r"""A compensation entry that represents one component of compensation, - such as base pay, bonus, or other compensation type. - - Annualization: One compensation entry can be annualized if - - - it contains valid - [amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] - or - [range][google.cloud.talent.v4.CompensationInfo.CompensationEntry.range]. - - and its - [expected_units_per_year][google.cloud.talent.v4.CompensationInfo.CompensationEntry.expected_units_per_year] - is set or can be derived. Its annualized range is determined as - ([amount][google.cloud.talent.v4.CompensationInfo.CompensationEntry.amount] - or - [range][google.cloud.talent.v4.CompensationInfo.CompensationEntry.range]) - times - [expected_units_per_year][google.cloud.talent.v4.CompensationInfo.CompensationEntry.expected_units_per_year]. - - 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: - type_ (google.cloud.talent_v4.types.CompensationInfo.CompensationType): - Compensation type. - - Default is - [CompensationType.COMPENSATION_TYPE_UNSPECIFIED][google.cloud.talent.v4.CompensationInfo.CompensationType.COMPENSATION_TYPE_UNSPECIFIED]. - unit (google.cloud.talent_v4.types.CompensationInfo.CompensationUnit): - Frequency of the specified amount. - - Default is - [CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED][google.cloud.talent.v4.CompensationInfo.CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED]. - amount (google.type.money_pb2.Money): - Compensation amount. - - This field is a member of `oneof`_ ``compensation_amount``. - range_ (google.cloud.talent_v4.types.CompensationInfo.CompensationRange): - Compensation range. - - This field is a member of `oneof`_ ``compensation_amount``. - description (str): - Compensation description. For example, could - indicate equity terms or provide additional - context to an estimated bonus. - expected_units_per_year (google.protobuf.wrappers_pb2.DoubleValue): - Expected number of units paid each year. If not specified, - when - [Job.employment_types][google.cloud.talent.v4.Job.employment_types] - is FULLTIME, a default value is inferred based on - [unit][google.cloud.talent.v4.CompensationInfo.CompensationEntry.unit]. - Default values: - - - HOURLY: 2080 - - DAILY: 260 - - WEEKLY: 52 - - MONTHLY: 12 - - ANNUAL: 1 - """ - - type_ = proto.Field( - proto.ENUM, - number=1, - enum='CompensationInfo.CompensationType', - ) - unit = proto.Field( - proto.ENUM, - number=2, - enum='CompensationInfo.CompensationUnit', - ) - amount = proto.Field( - proto.MESSAGE, - number=3, - oneof='compensation_amount', - message=money_pb2.Money, - ) - range_ = proto.Field( - proto.MESSAGE, - number=4, - oneof='compensation_amount', - message='CompensationInfo.CompensationRange', - ) - description = proto.Field( - proto.STRING, - number=5, - ) - expected_units_per_year = proto.Field( - proto.MESSAGE, - number=6, - message=wrappers_pb2.DoubleValue, - ) - - class CompensationRange(proto.Message): - r"""Compensation range. - - Attributes: - max_compensation (google.type.money_pb2.Money): - The maximum amount of compensation. If left empty, the value - is set to a maximal compensation value and the currency code - is set to match the [currency - code][google.type.Money.currency_code] of min_compensation. - min_compensation (google.type.money_pb2.Money): - The minimum amount of compensation. If left empty, the value - is set to zero and the currency code is set to match the - [currency code][google.type.Money.currency_code] of - max_compensation. - """ - - max_compensation = proto.Field( - proto.MESSAGE, - number=2, - message=money_pb2.Money, - ) - min_compensation = proto.Field( - proto.MESSAGE, - number=1, - message=money_pb2.Money, - ) - - entries = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=CompensationEntry, - ) - annualized_base_compensation_range = proto.Field( - proto.MESSAGE, - number=2, - message=CompensationRange, - ) - annualized_total_compensation_range = proto.Field( - proto.MESSAGE, - number=3, - message=CompensationRange, - ) - - -class BatchOperationMetadata(proto.Message): - r"""Metadata used for long running operations returned by CTS batch - APIs. It's used to replace - [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]. - - Attributes: - state (google.cloud.talent_v4.types.BatchOperationMetadata.State): - The state of a long running operation. - state_description (str): - More detailed information about operation - state. - success_count (int): - Count of successful item(s) inside an - operation. - failure_count (int): - Count of failed item(s) inside an operation. - total_count (int): - Count of total item(s) inside an operation. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the batch operation is created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the batch operation status is updated. The - metadata and the - [update_time][google.cloud.talent.v4.BatchOperationMetadata.update_time] - is refreshed every minute otherwise cached data is returned. - end_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the batch operation is finished and - [google.longrunning.Operation.done][google.longrunning.Operation.done] - is set to ``true``. - """ - class State(proto.Enum): - r"""""" - STATE_UNSPECIFIED = 0 - INITIALIZING = 1 - PROCESSING = 2 - SUCCEEDED = 3 - FAILED = 4 - CANCELLING = 5 - CANCELLED = 6 - - state = proto.Field( - proto.ENUM, - number=1, - enum=State, - ) - state_description = proto.Field( - proto.STRING, - number=2, - ) - success_count = proto.Field( - proto.INT32, - number=3, - ) - failure_count = proto.Field( - proto.INT32, - number=4, - ) - total_count = proto.Field( - proto.INT32, - number=5, - ) - create_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/company.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/company.py deleted file mode 100644 index c4d82317..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/company.py +++ /dev/null @@ -1,175 +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 proto # type: ignore - -from google.cloud.talent_v4.types import common - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'Company', - }, -) - - -class Company(proto.Message): - r"""A Company resource represents a company in the service. A - company is the entity that owns job postings, that is, the - hiring entity responsible for employing applicants for the job - position. - - Attributes: - name (str): - Required during company update. - - The resource name for a company. This is generated by the - service when a company is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/baz". - display_name (str): - Required. The display name of the company, - for example, "Google LLC". - external_id (str): - Required. Client side company identifier, - used to uniquely identify the company. - - The maximum number of allowed characters is 255. - size (google.cloud.talent_v4.types.CompanySize): - The employer's company size. - headquarters_address (str): - The street address of the company's main headquarters, which - may be different from the job location. The service attempts - to geolocate the provided address, and populates a more - specific location wherever possible in - [DerivedInfo.headquarters_location][google.cloud.talent.v4.Company.DerivedInfo.headquarters_location]. - hiring_agency (bool): - Set to true if it is the hiring agency that - post jobs for other employers. - - Defaults to false if not provided. - eeo_text (str): - Equal Employment Opportunity legal disclaimer - text to be associated with all jobs, and - typically to be displayed in all roles. - - The maximum number of allowed characters is 500. - website_uri (str): - The URI representing the company's primary - web site or home page, for example, - "https://www.google.com". - The maximum number of allowed characters is 255. - career_site_uri (str): - The URI to employer's career site or careers - page on the employer's web site, for example, - "https://careers.google.com". - image_uri (str): - A URI that hosts the employer's company logo. - keyword_searchable_job_custom_attributes (Sequence[str]): - A list of keys of filterable - [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes], - whose corresponding ``string_values`` are used in keyword - searches. Jobs with ``string_values`` under these specified - field keys are returned if any of the values match the - search keyword. Custom field values with parenthesis, - brackets and special symbols are not searchable as-is, and - those keyword queries must be surrounded by quotes. - derived_info (google.cloud.talent_v4.types.Company.DerivedInfo): - Output only. Derived details about the - company. - suspended (bool): - Output only. Indicates whether a company is - flagged to be suspended from public availability - by the service when job content appears - suspicious, abusive, or spammy. - """ - - class DerivedInfo(proto.Message): - r"""Derived details about the company. - - Attributes: - headquarters_location (google.cloud.talent_v4.types.Location): - A structured headquarters location of the company, resolved - from - [Company.headquarters_address][google.cloud.talent.v4.Company.headquarters_address] - if provided. - """ - - headquarters_location = proto.Field( - proto.MESSAGE, - number=1, - message=common.Location, - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - display_name = proto.Field( - proto.STRING, - number=2, - ) - external_id = proto.Field( - proto.STRING, - number=3, - ) - size = proto.Field( - proto.ENUM, - number=4, - enum=common.CompanySize, - ) - headquarters_address = proto.Field( - proto.STRING, - number=5, - ) - hiring_agency = proto.Field( - proto.BOOL, - number=6, - ) - eeo_text = proto.Field( - proto.STRING, - number=7, - ) - website_uri = proto.Field( - proto.STRING, - number=8, - ) - career_site_uri = proto.Field( - proto.STRING, - number=9, - ) - image_uri = proto.Field( - proto.STRING, - number=10, - ) - keyword_searchable_job_custom_attributes = proto.RepeatedField( - proto.STRING, - number=11, - ) - derived_info = proto.Field( - proto.MESSAGE, - number=12, - message=DerivedInfo, - ) - suspended = proto.Field( - proto.BOOL, - number=13, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/company_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/company_service.py deleted file mode 100644 index 33423b9d..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/company_service.py +++ /dev/null @@ -1,210 +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 proto # type: ignore - -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import company as gct_company -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'CreateCompanyRequest', - 'GetCompanyRequest', - 'UpdateCompanyRequest', - 'DeleteCompanyRequest', - 'ListCompaniesRequest', - 'ListCompaniesResponse', - }, -) - - -class CreateCompanyRequest(proto.Message): - r"""The Request of the CreateCompany method. - - Attributes: - parent (str): - Required. Resource name of the tenant under which the - company is created. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - company (google.cloud.talent_v4.types.Company): - Required. The company to be created. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - company = proto.Field( - proto.MESSAGE, - number=2, - message=gct_company.Company, - ) - - -class GetCompanyRequest(proto.Message): - r"""Request for getting a company by name. - - Attributes: - name (str): - Required. The resource name of the company to be retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, - "projects/api-test-project/tenants/foo/companies/bar". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateCompanyRequest(proto.Message): - r"""Request for updating a specified company. - - Attributes: - company (google.cloud.talent_v4.types.Company): - Required. The company 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.v4.UpdateCompanyRequest.update_mask] - is provided, only the specified fields in - [company][google.cloud.talent.v4.UpdateCompanyRequest.company] - are updated. Otherwise all the fields are updated. - - A field mask to specify the company fields to be updated. - Only top level fields of - [Company][google.cloud.talent.v4.Company] are supported. - """ - - company = proto.Field( - proto.MESSAGE, - number=1, - message=gct_company.Company, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteCompanyRequest(proto.Message): - r"""Request to delete a company. - - Attributes: - name (str): - Required. The resource name of the company to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/baz". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCompaniesRequest(proto.Message): - r"""List companies for which the client has ACL visibility. - - Attributes: - parent (str): - Required. Resource name of the tenant under which the - company is created. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - page_token (str): - The starting indicator from which to return - results. - page_size (int): - The maximum number of companies to be - returned, at most 100. Default is 100 if a - non-positive number is provided. - require_open_jobs (bool): - Set to true if the companies requested must have open jobs. - - Defaults to false. - - If true, at most - [page_size][google.cloud.talent.v4.ListCompaniesRequest.page_size] - of companies are fetched, among which only those with open - jobs are returned. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_token = proto.Field( - proto.STRING, - number=2, - ) - page_size = proto.Field( - proto.INT32, - number=3, - ) - require_open_jobs = proto.Field( - proto.BOOL, - number=4, - ) - - -class ListCompaniesResponse(proto.Message): - r"""The List companies response object. - - Attributes: - companies (Sequence[google.cloud.talent_v4.types.Company]): - Companies for the current client. - next_page_token (str): - A token to retrieve the next page of results. - metadata (google.cloud.talent_v4.types.ResponseMetadata): - Additional information for the API - invocation, such as the request tracking id. - """ - - @property - def raw_page(self): - return self - - companies = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gct_company.Company, - ) - 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/owl-bot-staging/v4/google/cloud/talent_v4/types/completion_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/completion_service.py deleted file mode 100644 index b1fa141d..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/completion_service.py +++ /dev/null @@ -1,163 +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 proto # type: ignore - -from google.cloud.talent_v4.types import common - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'CompleteQueryRequest', - 'CompleteQueryResponse', - }, -) - - -class CompleteQueryRequest(proto.Message): - r"""Auto-complete parameters. - - Attributes: - tenant (str): - Required. Resource name of tenant the completion is - performed within. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - query (str): - Required. The query used to generate - suggestions. - The maximum number of allowed characters is 255. - language_codes (Sequence[str]): - The list of languages of the query. This is the BCP-47 - language code, such as "en-US" or "sr-Latn". For more - information, see `Tags for Identifying - Languages `__. - - The maximum number of allowed characters is 255. - page_size (int): - Required. Completion result count. - The maximum allowed page size is 10. - company (str): - If provided, restricts completion to specified company. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/baz". - scope (google.cloud.talent_v4.types.CompleteQueryRequest.CompletionScope): - The scope of the completion. The defaults is - [CompletionScope.PUBLIC][google.cloud.talent.v4.CompleteQueryRequest.CompletionScope.PUBLIC]. - type_ (google.cloud.talent_v4.types.CompleteQueryRequest.CompletionType): - The completion topic. The default is - [CompletionType.COMBINED][google.cloud.talent.v4.CompleteQueryRequest.CompletionType.COMBINED]. - """ - class CompletionScope(proto.Enum): - r"""Enum to specify the scope of completion.""" - COMPLETION_SCOPE_UNSPECIFIED = 0 - TENANT = 1 - PUBLIC = 2 - - class CompletionType(proto.Enum): - r"""Enum to specify auto-completion topics.""" - COMPLETION_TYPE_UNSPECIFIED = 0 - JOB_TITLE = 1 - COMPANY_NAME = 2 - COMBINED = 3 - - tenant = proto.Field( - proto.STRING, - number=1, - ) - query = proto.Field( - proto.STRING, - number=2, - ) - language_codes = proto.RepeatedField( - proto.STRING, - number=3, - ) - page_size = proto.Field( - proto.INT32, - number=4, - ) - company = proto.Field( - proto.STRING, - number=5, - ) - scope = proto.Field( - proto.ENUM, - number=6, - enum=CompletionScope, - ) - type_ = proto.Field( - proto.ENUM, - number=7, - enum=CompletionType, - ) - - -class CompleteQueryResponse(proto.Message): - r"""Response of auto-complete query. - - Attributes: - completion_results (Sequence[google.cloud.talent_v4.types.CompleteQueryResponse.CompletionResult]): - Results of the matching job/company - candidates. - metadata (google.cloud.talent_v4.types.ResponseMetadata): - Additional information for the API - invocation, such as the request tracking id. - """ - - class CompletionResult(proto.Message): - r"""Resource that represents completion results. - - Attributes: - suggestion (str): - The suggestion for the query. - type_ (google.cloud.talent_v4.types.CompleteQueryRequest.CompletionType): - The completion topic. - image_uri (str): - The URI of the company image for - [COMPANY_NAME][google.cloud.talent.v4.CompleteQueryRequest.CompletionType.COMPANY_NAME]. - """ - - suggestion = proto.Field( - proto.STRING, - number=1, - ) - type_ = proto.Field( - proto.ENUM, - number=2, - enum='CompleteQueryRequest.CompletionType', - ) - image_uri = proto.Field( - proto.STRING, - number=3, - ) - - completion_results = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=CompletionResult, - ) - metadata = proto.Field( - proto.MESSAGE, - number=2, - message=common.ResponseMetadata, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/event.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/event.py deleted file mode 100644 index a868c0cd..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/event.py +++ /dev/null @@ -1,143 +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 proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'ClientEvent', - 'JobEvent', - }, -) - - -class ClientEvent(proto.Message): - r"""An event issued when an end user interacts with the - application that implements Cloud Talent Solution. Providing - this information improves the quality of results for the API - clients, enabling the service to perform optimally. The number - of events sent must be consistent with other calls, such as job - searches, issued to the service by the client. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - request_id (str): - Strongly recommended for the best service experience. - - A unique ID generated in the API responses. It can be found - in - [ResponseMetadata.request_id][google.cloud.talent.v4.ResponseMetadata.request_id]. - event_id (str): - Required. A unique identifier, generated by - the client application. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Required. The timestamp of the event. - job_event (google.cloud.talent_v4.types.JobEvent): - An event issued when a job seeker 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 - or other users, for example, feedback on why a - job was bookmarked. - """ - - request_id = proto.Field( - proto.STRING, - number=1, - ) - event_id = proto.Field( - proto.STRING, - number=2, - ) - create_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - job_event = proto.Field( - proto.MESSAGE, - number=5, - oneof='event', - message='JobEvent', - ) - event_notes = proto.Field( - proto.STRING, - number=9, - ) - - -class JobEvent(proto.Message): - r"""An event issued when a job seeker interacts with the - application that implements Cloud Talent Solution. - - Attributes: - type_ (google.cloud.talent_v4.types.JobEvent.JobEventType): - Required. The type of the event (see - [JobEventType][google.cloud.talent.v4.JobEvent.JobEventType]). - jobs (Sequence[str]): - Required. The [job name(s)][google.cloud.talent.v4.Job.name] - associated with this event. For example, if this is an - [impression][google.cloud.talent.v4.JobEvent.JobEventType.IMPRESSION] - event, this field contains the identifiers of all jobs shown - to the job seeker. If this was a - [view][google.cloud.talent.v4.JobEvent.JobEventType.VIEW] - event, this field contains the identifier of the viewed job. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}", - for example, "projects/foo/tenants/bar/jobs/baz". - """ - class JobEventType(proto.Enum): - r"""An enumeration of an event attributed to the behavior of the - end user, such as a job seeker. - """ - JOB_EVENT_TYPE_UNSPECIFIED = 0 - IMPRESSION = 1 - VIEW = 2 - VIEW_REDIRECT = 3 - APPLICATION_START = 4 - APPLICATION_FINISH = 5 - APPLICATION_QUICK_SUBMISSION = 6 - APPLICATION_REDIRECT = 7 - APPLICATION_START_FROM_SEARCH = 8 - APPLICATION_REDIRECT_FROM_SEARCH = 9 - APPLICATION_COMPANY_SUBMIT = 10 - BOOKMARK = 11 - NOTIFICATION = 12 - HIRED = 13 - SENT_CV = 14 - INTERVIEW_GRANTED = 15 - - type_ = proto.Field( - proto.ENUM, - number=1, - enum=JobEventType, - ) - jobs = proto.RepeatedField( - proto.STRING, - number=2, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/event_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/event_service.py deleted file mode 100644 index 27446466..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/event_service.py +++ /dev/null @@ -1,56 +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 proto # type: ignore - -from google.cloud.talent_v4.types import event - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'CreateClientEventRequest', - }, -) - - -class CreateClientEventRequest(proto.Message): - r"""The report event request. - - Attributes: - parent (str): - Required. Resource name of the tenant under which the event - is created. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - client_event (google.cloud.talent_v4.types.ClientEvent): - Required. Events issued when end user - interacts with customer's application that uses - Cloud Talent Solution. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - client_event = proto.Field( - proto.MESSAGE, - number=2, - message=event.ClientEvent, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/filters.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/filters.py deleted file mode 100644 index 5fc3caae..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/filters.py +++ /dev/null @@ -1,499 +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 proto # type: ignore - -from google.cloud.talent_v4.types import common -from google.protobuf import duration_pb2 # type: ignore -from google.type import latlng_pb2 # type: ignore -from google.type import timeofday_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'JobQuery', - 'LocationFilter', - 'CompensationFilter', - 'CommuteFilter', - }, -) - - -class JobQuery(proto.Message): - r"""The query required to perform a search query. - - Attributes: - query (str): - The query string that matches against the job - title, description, and location fields. - - The maximum number of allowed characters is 255. - query_language_code (str): - The language code of - [query][google.cloud.talent.v4.JobQuery.query]. For example, - "en-US". This field helps to better interpret the query. - - If a value isn't specified, the query language code is - automatically detected, which may not be accurate. - - Language code should be in BCP-47 format, such as "en-US" or - "sr-Latn". For more information, see `Tags for Identifying - Languages `__. - companies (Sequence[str]): - This filter specifies the company entities to search - against. - - If a value isn't specified, jobs are searched for against - all companies. - - If multiple values are specified, jobs are searched against - the companies specified. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". - For example, "projects/foo/tenants/bar/companies/baz". - - At most 20 company filters are allowed. - location_filters (Sequence[google.cloud.talent_v4.types.LocationFilter]): - The location filter specifies geo-regions containing the - jobs to search against. See - [LocationFilter][google.cloud.talent.v4.LocationFilter] for - more information. - - If a location value isn't specified, jobs fitting the other - search criteria are retrieved regardless of where they're - located. - - If multiple values are specified, jobs are retrieved from - any of the specified locations. If different values are - specified for the - [LocationFilter.distance_in_miles][google.cloud.talent.v4.LocationFilter.distance_in_miles] - parameter, the maximum provided distance is used for all - locations. - - At most 5 location filters are allowed. - job_categories (Sequence[google.cloud.talent_v4.types.JobCategory]): - The category filter specifies the categories of jobs to - search against. See - [JobCategory][google.cloud.talent.v4.JobCategory] for more - information. - - If a value isn't specified, jobs from any category are - searched against. - - If multiple values are specified, jobs from any of the - specified categories are searched against. - commute_filter (google.cloud.talent_v4.types.CommuteFilter): - Allows filtering jobs by commute time with different travel - methods (for example, driving or public transit). - - Note: This only works when you specify a - [CommuteMethod][google.cloud.talent.v4.CommuteMethod]. In - this case, - [location_filters][google.cloud.talent.v4.JobQuery.location_filters] - is ignored. - - Currently we don't support sorting by commute time. - company_display_names (Sequence[str]): - This filter specifies the company - [Company.display_name][google.cloud.talent.v4.Company.display_name] - 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. - - If multiple values are specified, jobs within the search - results may be associated with any of the specified - companies. - - At most 20 company display name filters are allowed. - compensation_filter (google.cloud.talent_v4.types.CompensationFilter): - This search filter is applied only to - [Job.compensation_info][google.cloud.talent.v4.Job.compensation_info]. - For example, if the filter is specified as "Hourly job with - per-hour compensation > $15", only jobs meeting these - criteria are searched. If a filter isn't defined, all open - jobs are searched. - custom_attribute_filter (str): - This filter specifies a structured syntax to match against - the - [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes] - marked as ``filterable``. - - The syntax for this expression is a subset of SQL syntax. - - Supported operators are: ``=``, ``!=``, ``<``, ``<=``, - ``>``, and ``>=`` where the left of the operator is a custom - field key and the right of the operator is a number or a - quoted string. You must escape backslash (\) and quote (") - characters. - - Supported functions are ``LOWER([field_name])`` to perform a - case insensitive match and ``EMPTY([field_name])`` 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"), a maximum of 100 comparisons or functions are - allowed in the expression. The expression must be < 10000 - bytes in length. - - Sample Query: - ``(LOWER(driving_license)="class \"a\"" OR EMPTY(driving_license)) AND driving_years > 10`` - 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". - Defaults to false: a spell check is performed. - employment_types (Sequence[google.cloud.talent_v4.types.EmploymentType]): - The employment type filter specifies the employment type of - jobs to search against, such as - [EmploymentType.FULL_TIME][google.cloud.talent.v4.EmploymentType.FULL_TIME]. - - If a value isn't specified, jobs in the search results - includes any employment type. - - If multiple values are specified, jobs in the search results - include any of the specified employment types. - language_codes (Sequence[str]): - This filter specifies the locale of jobs to search against, - for example, "en-US". - - If a value isn't specified, the search results can contain - jobs in any locale. - - Language codes should be in BCP-47 format, such as "en-US" - or "sr-Latn". For more information, see `Tags for - Identifying - Languages `__. - - At most 10 language code filters are allowed. - publish_time_range (google.cloud.talent_v4.types.TimestampRange): - Jobs published within a range specified by - this filter are searched against. - excluded_jobs (Sequence[str]): - This filter specifies a list of job names to - be excluded during search. - At most 400 excluded job names are allowed. - """ - - query = proto.Field( - proto.STRING, - number=1, - ) - query_language_code = proto.Field( - proto.STRING, - number=14, - ) - companies = proto.RepeatedField( - proto.STRING, - number=2, - ) - location_filters = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='LocationFilter', - ) - job_categories = proto.RepeatedField( - proto.ENUM, - number=4, - enum=common.JobCategory, - ) - commute_filter = proto.Field( - proto.MESSAGE, - number=5, - message='CommuteFilter', - ) - company_display_names = proto.RepeatedField( - proto.STRING, - number=6, - ) - compensation_filter = proto.Field( - proto.MESSAGE, - number=7, - message='CompensationFilter', - ) - custom_attribute_filter = proto.Field( - proto.STRING, - number=8, - ) - disable_spell_check = proto.Field( - proto.BOOL, - number=9, - ) - employment_types = proto.RepeatedField( - proto.ENUM, - number=10, - enum=common.EmploymentType, - ) - language_codes = proto.RepeatedField( - proto.STRING, - number=11, - ) - publish_time_range = proto.Field( - proto.MESSAGE, - number=12, - message=common.TimestampRange, - ) - excluded_jobs = proto.RepeatedField( - proto.STRING, - number=13, - ) - - -class LocationFilter(proto.Message): - r"""Geographic region of the search. - - Attributes: - address (str): - The address name, such as "Mountain View" or - "Bay Area". - region_code (str): - 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://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 - provided. - distance_in_miles (float): - The distance_in_miles is applied when the location being - searched for is identified as a city or smaller. This field - is ignored if the location being searched for is a state or - larger. - telecommute_preference (google.cloud.talent_v4.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). - [Job.posting_region][google.cloud.talent.v4.Job.posting_region] - indicates if a job permits telecommuting. If this field is - set to - [TelecommutePreference.TELECOMMUTE_ALLOWED][google.cloud.talent.v4.LocationFilter.TelecommutePreference.TELECOMMUTE_ALLOWED], - telecommuting jobs are searched, and - [address][google.cloud.talent.v4.LocationFilter.address] and - [lat_lng][google.cloud.talent.v4.LocationFilter.lat_lng] are - ignored. If not set or set to - [TelecommutePreference.TELECOMMUTE_EXCLUDED][google.cloud.talent.v4.LocationFilter.TelecommutePreference.TELECOMMUTE_EXCLUDED], - the telecommute status of the jobs is ignored. Jobs that - have - [PostingRegion.TELECOMMUTE][google.cloud.talent.v4.PostingRegion.TELECOMMUTE] - and have additional - [Job.addresses][google.cloud.talent.v4.Job.addresses] may - still be matched based on other location filters using - [address][google.cloud.talent.v4.LocationFilter.address] or - [latlng][]. - - This filter can be used by itself to search exclusively for - telecommuting jobs, or it can be combined with another - location filter to search for a combination of job - locations, such as "Mountain View" or "telecommuting" jobs. - However, when used in combination with other location - filters, telecommuting jobs can be treated as less relevant - than other jobs in the search response. - - This field is only used for job search requests. - """ - class TelecommutePreference(proto.Enum): - r"""Specify whether to include telecommute jobs.""" - TELECOMMUTE_PREFERENCE_UNSPECIFIED = 0 - TELECOMMUTE_EXCLUDED = 1 - TELECOMMUTE_ALLOWED = 2 - TELECOMMUTE_JOBS_EXCLUDED = 3 - - address = proto.Field( - proto.STRING, - number=1, - ) - region_code = proto.Field( - proto.STRING, - number=2, - ) - lat_lng = proto.Field( - proto.MESSAGE, - number=3, - message=latlng_pb2.LatLng, - ) - distance_in_miles = proto.Field( - proto.DOUBLE, - number=4, - ) - telecommute_preference = proto.Field( - proto.ENUM, - number=5, - enum=TelecommutePreference, - ) - - -class CompensationFilter(proto.Message): - r"""Filter on job compensation type and amount. - - Attributes: - type_ (google.cloud.talent_v4.types.CompensationFilter.FilterType): - Required. Type of filter. - units (Sequence[google.cloud.talent_v4.types.CompensationInfo.CompensationUnit]): - Required. Specify desired ``base compensation entry's`` - [CompensationInfo.CompensationUnit][google.cloud.talent.v4.CompensationInfo.CompensationUnit]. - range_ (google.cloud.talent_v4.types.CompensationInfo.CompensationRange): - Compensation range. - include_jobs_with_unspecified_compensation_range (bool): - If set to true, jobs with unspecified - compensation range fields are included. - """ - class FilterType(proto.Enum): - r"""Specify the type of filtering.""" - FILTER_TYPE_UNSPECIFIED = 0 - UNIT_ONLY = 1 - UNIT_AND_AMOUNT = 2 - ANNUALIZED_BASE_AMOUNT = 3 - ANNUALIZED_TOTAL_AMOUNT = 4 - - type_ = proto.Field( - proto.ENUM, - number=1, - enum=FilterType, - ) - units = proto.RepeatedField( - proto.ENUM, - number=2, - enum=common.CompensationInfo.CompensationUnit, - ) - range_ = proto.Field( - proto.MESSAGE, - number=3, - message=common.CompensationInfo.CompensationRange, - ) - include_jobs_with_unspecified_compensation_range = proto.Field( - proto.BOOL, - number=4, - ) - - -class CommuteFilter(proto.Message): - r"""Parameters needed for commute search. - - 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: - commute_method (google.cloud.talent_v4.types.CommuteMethod): - Required. The method of transportation to - calculate the commute time for. - start_coordinates (google.type.latlng_pb2.LatLng): - Required. The latitude and longitude of the - location to calculate the commute time from. - travel_duration (google.protobuf.duration_pb2.Duration): - Required. The maximum travel time in seconds. The maximum - allowed value is ``3600s`` (one hour). Format is ``123s``. - allow_imprecise_addresses (bool): - If ``true``, jobs without street level addresses may also be - returned. For city level addresses, the city center is used. - For state and coarser level addresses, text matching is - used. If this field is set to ``false`` or isn't specified, - only jobs that include street level addresses will be - returned by commute search. - road_traffic (google.cloud.talent_v4.types.CommuteFilter.RoadTraffic): - Specifies the traffic density to use when - calculating commute time. - - This field is a member of `oneof`_ ``traffic_option``. - departure_time (google.type.timeofday_pb2.TimeOfDay): - The departure time used to calculate traffic impact, - represented as - [google.type.TimeOfDay][google.type.TimeOfDay] in local time - zone. - - Currently traffic model is restricted to hour level - resolution. - - This field is a member of `oneof`_ ``traffic_option``. - """ - class RoadTraffic(proto.Enum): - r"""The traffic density to use when calculating commute time.""" - ROAD_TRAFFIC_UNSPECIFIED = 0 - TRAFFIC_FREE = 1 - BUSY_HOUR = 2 - - commute_method = proto.Field( - proto.ENUM, - number=1, - enum=common.CommuteMethod, - ) - start_coordinates = proto.Field( - proto.MESSAGE, - number=2, - message=latlng_pb2.LatLng, - ) - travel_duration = proto.Field( - proto.MESSAGE, - number=3, - message=duration_pb2.Duration, - ) - allow_imprecise_addresses = proto.Field( - proto.BOOL, - number=4, - ) - road_traffic = proto.Field( - proto.ENUM, - number=5, - oneof='traffic_option', - enum=RoadTraffic, - ) - departure_time = proto.Field( - proto.MESSAGE, - number=6, - oneof='traffic_option', - message=timeofday_pb2.TimeOfDay, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/histogram.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/histogram.py deleted file mode 100644 index 3265766b..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/histogram.py +++ /dev/null @@ -1,82 +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 proto # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'HistogramQuery', - 'HistogramQueryResult', - }, -) - - -class HistogramQuery(proto.Message): - r"""The histogram request. - - Attributes: - histogram_query (str): - An expression specifies a histogram request against matching - jobs for searches. - - See - [SearchJobsRequest.histogram_queries][google.cloud.talent.v4.SearchJobsRequest.histogram_queries] - for details about syntax. - """ - - histogram_query = proto.Field( - proto.STRING, - number=1, - ) - - -class HistogramQueryResult(proto.Message): - r"""Histogram result that matches - [HistogramQuery][google.cloud.talent.v4.HistogramQuery] specified in - searches. - - Attributes: - histogram_query (str): - Requested histogram expression. - histogram (Mapping[str, int]): - A map from the values of the facet associated with distinct - values to the number of matching entries with corresponding - value. - - The key format is: - - - (for string histogram) string values stored in the field. - - (for named numeric bucket) name specified in ``bucket()`` - function, like for ``bucket(0, MAX, "non-negative")``, - the key will be ``non-negative``. - - (for anonymous numeric bucket) range formatted as - ``-``, for example, ``0-1000``, ``MIN-0``, and - ``0-MAX``. - """ - - histogram_query = proto.Field( - proto.STRING, - number=1, - ) - histogram = proto.MapField( - proto.STRING, - proto.INT64, - number=2, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/job.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/job.py deleted file mode 100644 index 501088e6..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/job.py +++ /dev/null @@ -1,569 +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 proto # type: ignore - -from google.cloud.talent_v4.types import common -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'Job', - }, -) - - -class Job(proto.Message): - r"""A Job resource represents a job posting (also referred to as a "job - listing" or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4.Company], which is the hiring - entity responsible for the job. - - Attributes: - name (str): - Required during job update. - - The resource name for the job. This is generated by the - service when a job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - Use of this field in job queries and API calls is preferred - over the use of - [requisition_id][google.cloud.talent.v4.Job.requisition_id] - since this value is unique. - company (str): - Required. The resource name of the company listing the job. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". - For example, "projects/foo/tenants/bar/companies/baz". - requisition_id (str): - Required. The requisition ID, also referred to as the - posting ID, is assigned by the client to identify a job. - This field is intended to be used by clients for client - identification and tracking of postings. A job isn't allowed - to be created if there is another job with the same - [company][google.cloud.talent.v4.Job.name], - [language_code][google.cloud.talent.v4.Job.language_code] - and - [requisition_id][google.cloud.talent.v4.Job.requisition_id]. - - The maximum number of allowed characters is 255. - title (str): - Required. The title of the job, such as - "Software Engineer" - The maximum number of allowed characters is 500. - description (str): - Required. The description of the job, which typically - includes a multi-paragraph description of the company and - related information. Separate fields are provided on the job - object for - [responsibilities][google.cloud.talent.v4.Job.responsibilities], - [qualifications][google.cloud.talent.v4.Job.qualifications], - and other job characteristics. Use of these separate job - fields is recommended. - - This field accepts and sanitizes HTML input, and also - accepts bold, italic, ordered list, and unordered list - markup tags. - - The maximum number of allowed characters is 100,000. - addresses (Sequence[str]): - Strongly recommended for the best service experience. - - Location(s) where the employer is looking to hire for this - job posting. - - Specifying the full street address(es) of the hiring - location enables better API results, especially job searches - by commute time. - - At most 50 locations are allowed for best search - performance. If a job has more locations, it is suggested to - split it into multiple jobs with unique - [requisition_id][google.cloud.talent.v4.Job.requisition_id]s - (e.g. 'ReqA' becomes 'ReqA-1', 'ReqA-2', and so on.) as - multiple jobs with the same - [company][google.cloud.talent.v4.Job.company], - [language_code][google.cloud.talent.v4.Job.language_code] - and - [requisition_id][google.cloud.talent.v4.Job.requisition_id] - are not allowed. If the original - [requisition_id][google.cloud.talent.v4.Job.requisition_id] - must be preserved, a custom field should be used for - storage. It is also suggested to group the locations that - close to each other in the same job for better search - experience. - - Jobs with multiple addresses must have their addresses with - the same [LocationType][] to allow location filtering to - work properly. (For example, a Job with addresses "1600 - Amphitheatre Parkway, Mountain View, CA, USA" and "London, - UK" may not have location filters applied correctly at - search time since the first is a - [LocationType.STREET_ADDRESS][] and the second is a - [LocationType.LOCALITY][].) If a job needs to have multiple - addresses, it is suggested to split it into multiple jobs - with same LocationTypes. - - The maximum number of allowed characters is 500. - application_info (google.cloud.talent_v4.types.Job.ApplicationInfo): - Job application information. - job_benefits (Sequence[google.cloud.talent_v4.types.JobBenefit]): - The benefits included with the job. - compensation_info (google.cloud.talent_v4.types.CompensationInfo): - Job compensation information (a.k.a. "pay - rate") i.e., the compensation that will paid to - the employee. - custom_attributes (Mapping[str, google.cloud.talent_v4.types.CustomAttribute]): - A map of fields to hold both filterable and non-filterable - custom job attributes that are not covered by the provided - structured fields. - - The keys of the map are strings up to 64 bytes and must - match the pattern: ``[a-zA-Z][a-zA-Z0-9_]*``. For example, - key0LikeThis or KEY_1_LIKE_THIS. - - At most 100 filterable and at most 100 unfilterable keys are - supported. For filterable ``string_values``, across all keys - at most 200 values are allowed, with each string no more - than 255 characters. For unfilterable ``string_values``, the - maximum total size of ``string_values`` across all keys is - 50KB. - degree_types (Sequence[google.cloud.talent_v4.types.DegreeType]): - The desired education degrees for the job, - such as Bachelors, Masters. - department (str): - The department or functional area within the - company with the open position. - - The maximum number of allowed characters is 255. - employment_types (Sequence[google.cloud.talent_v4.types.EmploymentType]): - The employment type(s) of a job, for example, [full - time][google.cloud.talent.v4.EmploymentType.FULL_TIME] or - [part - time][google.cloud.talent.v4.EmploymentType.PART_TIME]. - incentives (str): - A description of bonus, commission, and other - compensation incentives associated with the job - not including salary or pay. - The maximum number of allowed characters is - 10,000. - language_code (str): - The language of the posting. This field is distinct from any - requirements for fluency that are associated with the job. - - Language codes must be in BCP-47 format, such as "en-US" or - "sr-Latn". For more information, see `Tags for Identifying - Languages `__\ {: - class="external" target="_blank" }. - - If this field is unspecified and - [Job.description][google.cloud.talent.v4.Job.description] is - present, detected language code based on - [Job.description][google.cloud.talent.v4.Job.description] is - assigned, otherwise defaults to 'en_US'. - job_level (google.cloud.talent_v4.types.JobLevel): - The experience level associated with the job, - such as "Entry Level". - promotion_value (int): - A promotion value of the job, as determined by the client. - The value determines the sort order of the jobs returned - when searching for jobs using the featured jobs search call, - with higher promotional values being returned first and ties - being resolved by relevance sort. Only the jobs with a - promotionValue >0 are returned in a FEATURED_JOB_SEARCH. - - Default value is 0, and negative values are treated as 0. - qualifications (str): - A description of the qualifications required to perform the - job. The use of this field is recommended as an alternative - to using the more general - [description][google.cloud.talent.v4.Job.description] field. - - This field accepts and sanitizes HTML input, and also - accepts bold, italic, ordered list, and unordered list - markup tags. - - The maximum number of allowed characters is 10,000. - responsibilities (str): - A description of job responsibilities. The use of this field - is recommended as an alternative to using the more general - [description][google.cloud.talent.v4.Job.description] field. - - This field accepts and sanitizes HTML input, and also - accepts bold, italic, ordered list, and unordered list - markup tags. - - The maximum number of allowed characters is 10,000. - posting_region (google.cloud.talent_v4.types.PostingRegion): - The job - [PostingRegion][google.cloud.talent.v4.PostingRegion] (for - example, state, country) throughout which the job is - available. If this field is set, a - [LocationFilter][google.cloud.talent.v4.LocationFilter] in a - search query within the job region finds this job posting if - an exact location match isn't specified. If this field is - set to - [PostingRegion.NATION][google.cloud.talent.v4.PostingRegion.NATION] - or - [PostingRegion.ADMINISTRATIVE_AREA][google.cloud.talent.v4.PostingRegion.ADMINISTRATIVE_AREA], - setting job - [Job.addresses][google.cloud.talent.v4.Job.addresses] to the - same location level as this field is strongly recommended. - visibility (google.cloud.talent_v4.types.Visibility): - Deprecated. The job is only visible to the owner. - - The visibility of the job. - - Defaults to - [Visibility.ACCOUNT_ONLY][google.cloud.talent.v4.Visibility.ACCOUNT_ONLY] - if not specified. - job_start_time (google.protobuf.timestamp_pb2.Timestamp): - The start timestamp of the job in UTC time - zone. Typically this field is used for - contracting engagements. Invalid timestamps are - ignored. - job_end_time (google.protobuf.timestamp_pb2.Timestamp): - The end timestamp of the job. Typically this - field is used for contracting engagements. - Invalid timestamps are ignored. - posting_publish_time (google.protobuf.timestamp_pb2.Timestamp): - The timestamp this job posting was most - recently published. The default value is the - time the request arrives at the server. Invalid - timestamps are ignored. - posting_expire_time (google.protobuf.timestamp_pb2.Timestamp): - Strongly recommended for the best service experience. - - The expiration timestamp of the job. After this timestamp, - the job is marked as expired, and it no longer appears in - search results. The expired job can't be listed by the - [ListJobs][google.cloud.talent.v4.JobService.ListJobs] API, - but it can be retrieved with the - [GetJob][google.cloud.talent.v4.JobService.GetJob] API or - updated with the - [UpdateJob][google.cloud.talent.v4.JobService.UpdateJob] API - or deleted with the - [DeleteJob][google.cloud.talent.v4.JobService.DeleteJob] - API. An expired job can be updated and opened again by using - a future expiration timestamp. Updating an expired job fails - if there is another existing open job with same - [company][google.cloud.talent.v4.Job.company], - [language_code][google.cloud.talent.v4.Job.language_code] - and - [requisition_id][google.cloud.talent.v4.Job.requisition_id]. - - The expired jobs are retained in our system for 90 days. - However, the overall expired job count cannot exceed 3 times - the maximum number of open jobs over previous 7 days. If - this threshold is exceeded, expired jobs are cleaned out in - order of earliest expire time. Expired jobs are no longer - accessible after they are cleaned out. - - Invalid timestamps are ignored, and treated as expire time - not provided. - - If the timestamp is before the instant request is made, the - job is treated as expired immediately on creation. This kind - of job can not be updated. And when creating a job with past - timestamp, the - [posting_publish_time][google.cloud.talent.v4.Job.posting_publish_time] - must be set before - [posting_expire_time][google.cloud.talent.v4.Job.posting_expire_time]. - The purpose of this feature is to allow other objects, such - as [Application][], to refer a job that didn't exist in the - system prior to becoming expired. If you want to modify a - job that was expired on creation, delete it and create a new - one. - - If this value isn't provided at the time of job creation or - is invalid, the job posting expires after 30 days from the - job's creation time. For example, if the job was created on - 2017/01/01 13:00AM UTC with an unspecified expiration date, - the job expires after 2017/01/31 13:00AM UTC. - - If this value isn't provided on job update, it depends on - the field masks set by - [UpdateJobRequest.update_mask][google.cloud.talent.v4.UpdateJobRequest.update_mask]. - If the field masks include - [job_end_time][google.cloud.talent.v4.Job.job_end_time], or - the masks are empty meaning that every field is updated, the - job posting expires after 30 days from the job's last update - time. Otherwise the expiration date isn't updated. - posting_create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The timestamp when this job - posting was created. - posting_update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The timestamp when this job - posting was last updated. - company_display_name (str): - Output only. Display name of the company - listing the job. - derived_info (google.cloud.talent_v4.types.Job.DerivedInfo): - Output only. Derived details about the job - posting. - processing_options (google.cloud.talent_v4.types.Job.ProcessingOptions): - Options for job processing. - """ - - class ApplicationInfo(proto.Message): - r"""Application related details of a job posting. - - Attributes: - emails (Sequence[str]): - Use this field to specify email address(es) - to which resumes or applications can be sent. - The maximum number of allowed characters for - each entry is 255. - instruction (str): - Use this field to provide instructions, such - as "Mail your application to ...", that a - candidate can follow to apply for the job. - This field accepts and sanitizes HTML input, and - also accepts bold, italic, ordered list, and - unordered list markup tags. - The maximum number of allowed characters is - 3,000. - uris (Sequence[str]): - Use this URI field to direct an applicant to - a website, for example to link to an online - application form. - The maximum number of allowed characters for - each entry is 2,000. - """ - - emails = proto.RepeatedField( - proto.STRING, - number=1, - ) - instruction = proto.Field( - proto.STRING, - number=2, - ) - uris = proto.RepeatedField( - proto.STRING, - number=3, - ) - - class DerivedInfo(proto.Message): - r"""Derived details about the job posting. - - Attributes: - locations (Sequence[google.cloud.talent_v4.types.Location]): - Structured locations of the job, resolved from - [Job.addresses][google.cloud.talent.v4.Job.addresses]. - - [locations][google.cloud.talent.v4.Job.DerivedInfo.locations] - are exactly matched to - [Job.addresses][google.cloud.talent.v4.Job.addresses] in the - same order. - job_categories (Sequence[google.cloud.talent_v4.types.JobCategory]): - Job categories derived from - [Job.title][google.cloud.talent.v4.Job.title] and - [Job.description][google.cloud.talent.v4.Job.description]. - """ - - locations = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=common.Location, - ) - job_categories = proto.RepeatedField( - proto.ENUM, - number=3, - enum=common.JobCategory, - ) - - class ProcessingOptions(proto.Message): - r"""Options for job processing. - - Attributes: - disable_street_address_resolution (bool): - If set to ``true``, the service does not attempt to resolve - a more precise address for the job. - html_sanitization (google.cloud.talent_v4.types.HtmlSanitization): - Option for job HTML content sanitization. Applied fields - are: - - - description - - applicationInfo.instruction - - incentives - - qualifications - - responsibilities - - HTML tags in these fields may be stripped if sanitiazation - isn't disabled. - - Defaults to - [HtmlSanitization.SIMPLE_FORMATTING_ONLY][google.cloud.talent.v4.HtmlSanitization.SIMPLE_FORMATTING_ONLY]. - """ - - disable_street_address_resolution = proto.Field( - proto.BOOL, - number=1, - ) - html_sanitization = proto.Field( - proto.ENUM, - number=2, - enum=common.HtmlSanitization, - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - company = proto.Field( - proto.STRING, - number=2, - ) - requisition_id = proto.Field( - proto.STRING, - number=3, - ) - title = proto.Field( - proto.STRING, - number=4, - ) - description = proto.Field( - proto.STRING, - number=5, - ) - addresses = proto.RepeatedField( - proto.STRING, - number=6, - ) - application_info = proto.Field( - proto.MESSAGE, - number=7, - message=ApplicationInfo, - ) - job_benefits = proto.RepeatedField( - proto.ENUM, - number=8, - enum=common.JobBenefit, - ) - compensation_info = proto.Field( - proto.MESSAGE, - number=9, - message=common.CompensationInfo, - ) - custom_attributes = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=10, - message=common.CustomAttribute, - ) - degree_types = proto.RepeatedField( - proto.ENUM, - number=11, - enum=common.DegreeType, - ) - department = proto.Field( - proto.STRING, - number=12, - ) - employment_types = proto.RepeatedField( - proto.ENUM, - number=13, - enum=common.EmploymentType, - ) - incentives = proto.Field( - proto.STRING, - number=14, - ) - language_code = proto.Field( - proto.STRING, - number=15, - ) - job_level = proto.Field( - proto.ENUM, - number=16, - enum=common.JobLevel, - ) - promotion_value = proto.Field( - proto.INT32, - number=17, - ) - qualifications = proto.Field( - proto.STRING, - number=18, - ) - responsibilities = proto.Field( - proto.STRING, - number=19, - ) - posting_region = proto.Field( - proto.ENUM, - number=20, - enum=common.PostingRegion, - ) - visibility = proto.Field( - proto.ENUM, - number=21, - enum=common.Visibility, - ) - job_start_time = proto.Field( - proto.MESSAGE, - number=22, - message=timestamp_pb2.Timestamp, - ) - job_end_time = proto.Field( - proto.MESSAGE, - number=23, - message=timestamp_pb2.Timestamp, - ) - posting_publish_time = proto.Field( - proto.MESSAGE, - number=24, - message=timestamp_pb2.Timestamp, - ) - posting_expire_time = proto.Field( - proto.MESSAGE, - number=25, - message=timestamp_pb2.Timestamp, - ) - posting_create_time = proto.Field( - proto.MESSAGE, - number=26, - message=timestamp_pb2.Timestamp, - ) - posting_update_time = proto.Field( - proto.MESSAGE, - number=27, - message=timestamp_pb2.Timestamp, - ) - company_display_name = proto.Field( - proto.STRING, - number=28, - ) - derived_info = proto.Field( - proto.MESSAGE, - number=29, - message=DerivedInfo, - ) - processing_options = proto.Field( - proto.MESSAGE, - number=30, - message=ProcessingOptions, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/job_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/job_service.py deleted file mode 100644 index f5a308ee..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/job_service.py +++ /dev/null @@ -1,1126 +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 proto # type: ignore - -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import filters -from google.cloud.talent_v4.types import histogram -from google.cloud.talent_v4.types import job as gct_job -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.rpc import status_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'JobView', - 'CreateJobRequest', - 'GetJobRequest', - 'UpdateJobRequest', - 'DeleteJobRequest', - 'ListJobsRequest', - 'ListJobsResponse', - 'SearchJobsRequest', - 'SearchJobsResponse', - 'BatchCreateJobsRequest', - 'BatchUpdateJobsRequest', - 'BatchDeleteJobsRequest', - 'JobResult', - 'BatchCreateJobsResponse', - 'BatchUpdateJobsResponse', - 'BatchDeleteJobsResponse', - }, -) - - -class JobView(proto.Enum): - r"""An enum that specifies the job attributes that are returned in the - [MatchingJob.job][google.cloud.talent.v4.SearchJobsResponse.MatchingJob.job] - or - [ListJobsResponse.jobs][google.cloud.talent.v4.ListJobsResponse.jobs] - fields. - """ - JOB_VIEW_UNSPECIFIED = 0 - JOB_VIEW_ID_ONLY = 1 - JOB_VIEW_MINIMAL = 2 - JOB_VIEW_SMALL = 3 - JOB_VIEW_FULL = 4 - - -class CreateJobRequest(proto.Message): - r"""Create job request. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenants/bar". - job (google.cloud.talent_v4.types.Job): - Required. The Job to be created. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - job = proto.Field( - proto.MESSAGE, - number=2, - message=gct_job.Job, - ) - - -class GetJobRequest(proto.Message): - r"""Get job request. - - Attributes: - name (str): - Required. The resource name of the job to retrieve. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateJobRequest(proto.Message): - r"""Update job request. - - Attributes: - job (google.cloud.talent_v4.types.Job): - Required. The Job to be updated. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Strongly recommended for the best service experience. - - If - [update_mask][google.cloud.talent.v4.UpdateJobRequest.update_mask] - is provided, only the specified fields in - [job][google.cloud.talent.v4.UpdateJobRequest.job] are - updated. Otherwise all the fields are updated. - - A field mask to restrict the fields that are updated. Only - top level fields of [Job][google.cloud.talent.v4.Job] are - supported. - """ - - job = proto.Field( - proto.MESSAGE, - number=1, - message=gct_job.Job, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteJobRequest(proto.Message): - r"""Delete job request. - - Attributes: - name (str): - Required. The resource name of the job to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListJobsRequest(proto.Message): - r"""List jobs request. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenants/bar". - filter (str): - Required. The filter string specifies the jobs to be - enumerated. - - Supported operator: =, AND - - The fields eligible for filtering are: - - - ``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" - - requisitionId = "req-1" - - requisitionId = "req-1" AND status = "EXPIRED". - page_token (str): - The starting point of a query result. - page_size (int): - The maximum number of jobs to be returned per page of - results. - - If - [job_view][google.cloud.talent.v4.ListJobsRequest.job_view] - is set to - [JobView.JOB_VIEW_ID_ONLY][google.cloud.talent.v4.JobView.JOB_VIEW_ID_ONLY], - the maximum allowed page size is 1000. Otherwise, the - maximum allowed page size is 100. - - Default is 100 if empty or a number < 1 is specified. - job_view (google.cloud.talent_v4.types.JobView): - The desired job attributes returned for jobs in the search - response. Defaults to - [JobView.JOB_VIEW_FULL][google.cloud.talent.v4.JobView.JOB_VIEW_FULL] - if no value is specified. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - filter = proto.Field( - proto.STRING, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - page_size = proto.Field( - proto.INT32, - number=4, - ) - job_view = proto.Field( - proto.ENUM, - number=5, - enum='JobView', - ) - - -class ListJobsResponse(proto.Message): - r"""List jobs response. - - Attributes: - jobs (Sequence[google.cloud.talent_v4.types.Job]): - The Jobs for a given company. - The maximum number of items returned is based on - the limit field provided in the request. - next_page_token (str): - A token to retrieve the next page of results. - metadata (google.cloud.talent_v4.types.ResponseMetadata): - Additional information for the API - invocation, such as the request tracking id. - """ - - @property - def raw_page(self): - return self - - jobs = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gct_job.Job, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - metadata = proto.Field( - proto.MESSAGE, - number=3, - message=common.ResponseMetadata, - ) - - -class SearchJobsRequest(proto.Message): - r"""The Request body of the ``SearchJobs`` 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". - search_mode (google.cloud.talent_v4.types.SearchJobsRequest.SearchMode): - Mode of a search. - - Defaults to - [SearchMode.JOB_SEARCH][google.cloud.talent.v4.SearchJobsRequest.SearchMode.JOB_SEARCH]. - request_metadata (google.cloud.talent_v4.types.RequestMetadata): - Required. The meta information collected about the job - searcher, used to improve the search quality of the service. - The identifiers (such as ``user_id``) are provided by users, - and must be unique and consistent. - job_query (google.cloud.talent_v4.types.JobQuery): - Query used to search against jobs, such as - keyword, location filters, etc. - enable_broadening (bool): - Controls whether to broaden the search when - it produces sparse results. Broadened queries - append results to the end of the matching - results list. - - Defaults to false. - histogram_queries (Sequence[google.cloud.talent_v4.types.HistogramQuery]): - An expression specifies a histogram request against matching - jobs. - - Expression syntax is an aggregation function call with - histogram facets and other options. - - Available aggregation function calls are: - - - ``count(string_histogram_facet)``: Count the number of - matching entities, for each distinct attribute value. - - ``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 - ``[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 built-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). - - Job histogram facets: - - - company_display_name: histogram by - [Job.company_display_name][google.cloud.talent.v4.Job.company_display_name]. - - employment_type: histogram by - [Job.employment_types][google.cloud.talent.v4.Job.employment_types], - for example, "FULL_TIME", "PART_TIME". - - company_size: histogram by - [CompanySize][google.cloud.talent.v4.CompanySize], for - example, "SMALL", "MEDIUM", "BIG". - - publish_time_in_day: histogram by the - [Job.posting_publish_time][google.cloud.talent.v4.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.v4.Job.posting_publish_time] - in months. Must specify list of numeric buckets in spec. - - publish_time_in_year: histogram by the - [Job.posting_publish_time][google.cloud.talent.v4.Job.posting_publish_time] - in years. Must specify list of numeric buckets in spec. - - degree_types: histogram by the - [Job.degree_types][google.cloud.talent.v4.Job.degree_types], - for example, "Bachelors", "Masters". - - job_level: histogram by the - [Job.job_level][google.cloud.talent.v4.Job.job_level], - for example, "Entry Level". - - country: histogram by the country code of jobs, for - example, "US", "FR". - - admin1: histogram by the admin1 code of jobs, which is a - global placeholder referring to the state, province, or - the particular term a country uses to define the - geographic structure below the country level, for - example, "CA", "IL". - - city: histogram by a combination of the "city name, - admin1 code". For example, "Mountain View, CA", "New - York, NY". - - admin1_country: histogram by a combination of the "admin1 - code, country", for example, "CA, US", "IL, US". - - city_coordinate: histogram by the city center's GPS - coordinates (latitude and longitude), for example, - 37.4038522,-122.0987765. Since the coordinates of a city - center can change, customers may need to refresh them - periodically. - - locale: histogram by the - [Job.language_code][google.cloud.talent.v4.Job.language_code], - for example, "en-US", "fr-FR". - - language: histogram by the language subtag of the - [Job.language_code][google.cloud.talent.v4.Job.language_code], - for example, "en", "fr". - - category: histogram by the - [JobCategory][google.cloud.talent.v4.JobCategory], for - example, "COMPUTER_AND_IT", "HEALTHCARE". - - base_compensation_unit: histogram by the - [CompensationInfo.CompensationUnit][google.cloud.talent.v4.CompensationInfo.CompensationUnit] - of base salary, for example, "WEEKLY", "MONTHLY". - - base_compensation: histogram by the base salary. Must - specify list of numeric buckets to group results by. - - annualized_base_compensation: histogram by the base - annualized salary. Must specify list of numeric buckets - to group results by. - - annualized_total_compensation: histogram by the total - annualized salary. Must specify list of numeric buckets - to group results by. - - string_custom_attribute: histogram by string - [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes]. - Values can be accessed via square bracket notations like - string_custom_attribute["key1"]. - - numeric_custom_attribute: histogram by numeric - [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes]. - Values can be accessed via square bracket notations like - numeric_custom_attribute["key1"]. Must specify list of - numeric buckets to group results by. - - Example expressions: - - - ``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")])`` - job_view (google.cloud.talent_v4.types.JobView): - The desired job attributes returned for jobs in the search - response. Defaults to - [JobView.JOB_VIEW_SMALL][google.cloud.talent.v4.JobView.JOB_VIEW_SMALL] - if no value is specified. - offset (int): - An integer that specifies the current offset (that is, - starting result location, amongst the jobs deemed by the API - as relevant) in search results. This field is only - considered if - [page_token][google.cloud.talent.v4.SearchJobsRequest.page_token] - is unset. - - The maximum allowed value is 5000. Otherwise an error is - thrown. - - For example, 0 means to return results starting from the - first matching job, and 10 means to return from the 11th - job. This can be used for pagination, (for example, pageSize - = 10 and offset = 10 means to return from the second page). - max_page_size (int): - A limit on the number of jobs returned in the - search results. Increasing this value above the - default value of 10 can increase search response - time. The value can be between 1 and 100. - page_token (str): - The token specifying the current offset within search - results. See - [SearchJobsResponse.next_page_token][google.cloud.talent.v4.SearchJobsResponse.next_page_token] - for an explanation of how to obtain the next set of query - results. - order_by (str): - The criteria determining how search results are sorted. - Default is ``"relevance desc"``. - - Supported options are: - - - ``"relevance desc"``: By relevance descending, as - determined by the API algorithms. Relevance thresholding - of query results is only available with this ordering. - - ``"posting_publish_time desc"``: By - [Job.posting_publish_time][google.cloud.talent.v4.Job.posting_publish_time] - descending. - - ``"posting_update_time desc"``: By - [Job.posting_update_time][google.cloud.talent.v4.Job.posting_update_time] - descending. - - ``"title"``: By - [Job.title][google.cloud.talent.v4.Job.title] ascending. - - ``"title desc"``: By - [Job.title][google.cloud.talent.v4.Job.title] descending. - - ``"annualized_base_compensation"``: By job's - [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range] - ascending. Jobs whose annualized base compensation is - unspecified are put at the end of search results. - - ``"annualized_base_compensation desc"``: By job's - [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range] - descending. Jobs whose annualized base compensation is - unspecified are put at the end of search results. - - ``"annualized_total_compensation"``: By job's - [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range] - ascending. Jobs whose annualized base compensation is - unspecified are put at the end of search results. - - ``"annualized_total_compensation desc"``: By job's - [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range] - descending. Jobs whose annualized base compensation is - unspecified are put at the end of search results. - - ``"custom_ranking desc"``: By the relevance score - adjusted to the - [SearchJobsRequest.CustomRankingInfo.ranking_expression][google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression] - with weight factor assigned by - [SearchJobsRequest.CustomRankingInfo.importance_level][google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.importance_level] - in descending order. - - Location sorting: Use the special syntax to order jobs by - distance: ``"distance_from('Hawaii')"``: Order by - distance from Hawaii. ``"distance_from(19.89, 155.5)"``: - Order by distance from a coordinate. - ``"distance_from('Hawaii'), distance_from('Puerto Rico')"``: - Order by multiple locations. See details below. - ``"distance_from('Hawaii'), distance_from(19.89, 155.5)"``: - Order by multiple locations. See details below. The - string can have a maximum of 256 characters. When - multiple distance centers are provided, a job that is - close to any of the distance centers would have a high - rank. When a job has multiple locations, the job location - closest to one of the distance centers will be used. Jobs - that don't have locations will be ranked at the bottom. - Distance is calculated with a precision of 11.3 meters - (37.4 feet). Diversification strategy is still applied - unless explicitly disabled in - [diversification_level][google.cloud.talent.v4.SearchJobsRequest.diversification_level]. - diversification_level (google.cloud.talent_v4.types.SearchJobsRequest.DiversificationLevel): - Controls whether highly similar jobs are returned next to - each other in the search results. Jobs are identified as - highly similar based on their titles, job categories, and - locations. Highly similar results are clustered so that only - one representative job of the cluster is displayed to the - job seeker higher up in the results, with the other jobs - being displayed lower down in the results. - - Defaults to - [DiversificationLevel.SIMPLE][google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel.SIMPLE] - if no value is specified. - custom_ranking_info (google.cloud.talent_v4.types.SearchJobsRequest.CustomRankingInfo): - Controls over how job documents get ranked on - 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.v4.SearchJobsRequest.keyword_match_mode] - going forward. - - To migrate, disable_keyword_match set to false maps to - [KeywordMatchMode.KEYWORD_MATCH_ALL][google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL], - and disable_keyword_match set to true maps to - [KeywordMatchMode.KEYWORD_MATCH_DISABLED][google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED]. - If - [SearchJobsRequest.keyword_match_mode][google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode] - is set, this field is ignored. - - Controls whether to disable exact keyword match on - [Job.title][google.cloud.talent.v4.Job.title], - [Job.description][google.cloud.talent.v4.Job.description], - [Job.company_display_name][google.cloud.talent.v4.Job.company_display_name], - [Job.addresses][google.cloud.talent.v4.Job.addresses], - [Job.qualifications][google.cloud.talent.v4.Job.qualifications]. - When disable keyword match is turned off, a keyword match - returns jobs that do not match given category filters when - there are matching keywords. For example, for the query - "program manager," a result is returned even if the job - posting has the title "software developer," which doesn't - fall into "program manager" ontology, but does have "program - manager" appearing in its description. - - For queries like "cloud" that don't contain title or - location specific ontology, jobs with "cloud" keyword - matches are returned regardless of this flag's value. - - Use - [Company.keyword_searchable_job_custom_attributes][google.cloud.talent.v4.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. - - Defaults to false. - keyword_match_mode (google.cloud.talent_v4.types.SearchJobsRequest.KeywordMatchMode): - Controls what keyword match options to use. If both - keyword_match_mode and disable_keyword_match are set, - keyword_match_mode will take precedence. - - Defaults to - [KeywordMatchMode.KEYWORD_MATCH_ALL][google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL] - if no value is specified. - """ - class SearchMode(proto.Enum): - r"""A string-represented enumeration of the job search mode. The - service operate differently for different modes of service. - """ - SEARCH_MODE_UNSPECIFIED = 0 - JOB_SEARCH = 1 - FEATURED_JOB_SEARCH = 2 - - class DiversificationLevel(proto.Enum): - r"""Controls whether highly similar jobs are returned next to - each other in the search results. Jobs are identified as highly - similar based on their titles, job categories, and locations. - Highly similar results are clustered so that only one - representative job of the cluster is displayed to the job seeker - higher up in the results, with the other jobs being displayed - lower down in the results. - - If you are using pageToken to page through the result set, - latency might be lower but we can't guarantee that all results - are returned. If you are using page offset, latency might be - higher but all results are returned. - """ - DIVERSIFICATION_LEVEL_UNSPECIFIED = 0 - DISABLED = 1 - SIMPLE = 2 - ONE_PER_COMPANY = 3 - TWO_PER_COMPANY = 4 - DIVERSIFY_BY_LOOSER_SIMILARITY = 5 - - 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.v4.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.v4.SearchJobsRequest]. - - Attributes: - importance_level (google.cloud.talent_v4.types.SearchJobsRequest.CustomRankingInfo.ImportanceLevel): - Required. Controls over how important the score of - [CustomRankingInfo.ranking_expression][google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression] - gets applied to job's final ranking position. - - An error is thrown if not specified. - ranking_expression (str): - Required. Controls over how job documents get ranked on top - of existing relevance score (determined by API algorithm). A - combination of the ranking expression and relevance score is - used to determine job's final ranking position. - - The syntax for this expression is a subset of Google SQL - syntax. - - Supported operators are: +, -, \*, /, where the left and - right side of the operator is either a numeric - [Job.custom_attributes][google.cloud.talent.v4.Job.custom_attributes] - key, integer/double value or an expression that can be - evaluated to a number. - - Parenthesis are supported to adjust calculation precedence. - 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 - populated on the job or if the expression results in a - divide by zero. If an expression is invalid for a job, that - job is demoted to the end of the results. - - Sample ranking expression (year + 25) \* 0.25 - (freshness / - 0.5) - """ - class ImportanceLevel(proto.Enum): - r"""The importance level for - [CustomRankingInfo.ranking_expression][google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression]. - """ - IMPORTANCE_LEVEL_UNSPECIFIED = 0 - NONE = 1 - LOW = 2 - MILD = 3 - MEDIUM = 4 - HIGH = 5 - EXTREME = 6 - - importance_level = proto.Field( - proto.ENUM, - number=1, - enum='SearchJobsRequest.CustomRankingInfo.ImportanceLevel', - ) - ranking_expression = proto.Field( - proto.STRING, - number=2, - ) - - parent = proto.Field( - proto.STRING, - number=1, - ) - search_mode = proto.Field( - proto.ENUM, - number=2, - enum=SearchMode, - ) - request_metadata = proto.Field( - proto.MESSAGE, - number=3, - message=common.RequestMetadata, - ) - job_query = proto.Field( - proto.MESSAGE, - number=4, - message=filters.JobQuery, - ) - enable_broadening = proto.Field( - proto.BOOL, - number=5, - ) - histogram_queries = proto.RepeatedField( - proto.MESSAGE, - number=7, - message=histogram.HistogramQuery, - ) - job_view = proto.Field( - proto.ENUM, - number=8, - enum='JobView', - ) - offset = proto.Field( - proto.INT32, - number=9, - ) - max_page_size = proto.Field( - proto.INT32, - number=10, - ) - page_token = proto.Field( - proto.STRING, - number=11, - ) - order_by = proto.Field( - proto.STRING, - number=12, - ) - diversification_level = proto.Field( - proto.ENUM, - number=13, - enum=DiversificationLevel, - ) - custom_ranking_info = proto.Field( - proto.MESSAGE, - number=14, - message=CustomRankingInfo, - ) - disable_keyword_match = proto.Field( - proto.BOOL, - number=16, - ) - keyword_match_mode = proto.Field( - proto.ENUM, - number=18, - enum=KeywordMatchMode, - ) - - -class SearchJobsResponse(proto.Message): - r"""Response for SearchJob method. - - Attributes: - matching_jobs (Sequence[google.cloud.talent_v4.types.SearchJobsResponse.MatchingJob]): - The Job entities that match the specified - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - histogram_query_results (Sequence[google.cloud.talent_v4.types.HistogramQueryResult]): - The histogram results that match with specified - [SearchJobsRequest.histogram_queries][google.cloud.talent.v4.SearchJobsRequest.histogram_queries]. - next_page_token (str): - The token that specifies the starting - position of the next page of results. This field - is empty if there are no more results. - location_filters (Sequence[google.cloud.talent_v4.types.Location]): - The location filters that the service applied to the - specified query. If any filters are lat-lng based, the - [Location.location_type][google.cloud.talent.v4.Location.location_type] - is - [Location.LocationType.LOCATION_TYPE_UNSPECIFIED][google.cloud.talent.v4.Location.LocationType.LOCATION_TYPE_UNSPECIFIED]. - total_size (int): - Number of jobs that match the specified - query. - Note: This size is precise only if the total is - less than 100,000. - metadata (google.cloud.talent_v4.types.ResponseMetadata): - Additional information for the API - invocation, such as the request tracking id. - broadened_query_jobs_count (int): - If query broadening is enabled, we may append - additional results from the broadened query. - This number indicates how many of the jobs - returned in the jobs field are from the - broadened query. These results are always at the - end of the jobs list. In particular, a value of - 0, or if the field isn't set, all the jobs in - the jobs list are from the original (without - broadening) query. If this field is non-zero, - subsequent requests with offset after this - result set should contain all broadened results. - spell_correction (google.cloud.talent_v4.types.SpellingCorrection): - The spell checking result, and correction. - """ - - class MatchingJob(proto.Message): - r"""Job entry with metadata inside - [SearchJobsResponse][google.cloud.talent.v4.SearchJobsResponse]. - - Attributes: - job (google.cloud.talent_v4.types.Job): - Job resource that matches the specified - [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - job_summary (str): - A summary of the job with core information - that's displayed on the search results listing - page. - job_title_snippet (str): - Contains snippets of text from the - [Job.title][google.cloud.talent.v4.Job.title] field most - closely matching a search query's keywords, if available. - The matching query keywords are enclosed in HTML bold tags. - search_text_snippet (str): - Contains snippets of text from the - [Job.description][google.cloud.talent.v4.Job.description] - and similar fields that most closely match a search query's - keywords, if available. All HTML tags in the original fields - are stripped when returned in this field, and matching query - keywords are enclosed in HTML bold tags. - commute_info (google.cloud.talent_v4.types.SearchJobsResponse.CommuteInfo): - Commute information which is generated based on specified - [CommuteFilter][google.cloud.talent.v4.CommuteFilter]. - """ - - job = proto.Field( - proto.MESSAGE, - number=1, - message=gct_job.Job, - ) - job_summary = proto.Field( - proto.STRING, - number=2, - ) - job_title_snippet = proto.Field( - proto.STRING, - number=3, - ) - search_text_snippet = proto.Field( - proto.STRING, - number=4, - ) - commute_info = proto.Field( - proto.MESSAGE, - number=5, - message='SearchJobsResponse.CommuteInfo', - ) - - class CommuteInfo(proto.Message): - r"""Commute details related to this job. - - Attributes: - job_location (google.cloud.talent_v4.types.Location): - Location used as the destination in the - commute calculation. - travel_duration (google.protobuf.duration_pb2.Duration): - The number of seconds required to travel to - the job location from the query location. A - duration of 0 seconds indicates that the job - isn't reachable within the requested duration, - but was returned as part of an expanded query. - """ - - job_location = proto.Field( - proto.MESSAGE, - number=1, - message=common.Location, - ) - travel_duration = proto.Field( - proto.MESSAGE, - number=2, - message=duration_pb2.Duration, - ) - - @property - def raw_page(self): - return self - - matching_jobs = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=MatchingJob, - ) - histogram_query_results = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=histogram.HistogramQueryResult, - ) - next_page_token = proto.Field( - proto.STRING, - number=3, - ) - location_filters = proto.RepeatedField( - proto.MESSAGE, - number=4, - message=common.Location, - ) - total_size = proto.Field( - proto.INT32, - number=6, - ) - metadata = proto.Field( - proto.MESSAGE, - number=7, - message=common.ResponseMetadata, - ) - broadened_query_jobs_count = proto.Field( - proto.INT32, - number=8, - ) - spell_correction = proto.Field( - proto.MESSAGE, - number=9, - message=common.SpellingCorrection, - ) - - -class BatchCreateJobsRequest(proto.Message): - r"""Request to create a batch of jobs. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenants/bar". - jobs (Sequence[google.cloud.talent_v4.types.Job]): - Required. The jobs to be created. - A maximum of 200 jobs can be created in a batch. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - jobs = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=gct_job.Job, - ) - - -class BatchUpdateJobsRequest(proto.Message): - r"""Request to update a batch of jobs. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenants/bar". - jobs (Sequence[google.cloud.talent_v4.types.Job]): - Required. The jobs to be updated. - A maximum of 200 jobs can be updated in a batch. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Strongly recommended for the best service experience. Be - aware that it will also increase latency when checking the - status of a batch operation. - - If - [update_mask][google.cloud.talent.v4.BatchUpdateJobsRequest.update_mask] - is provided, only the specified fields in - [Job][google.cloud.talent.v4.Job] are updated. Otherwise all - the fields are updated. - - A field mask to restrict the fields that are updated. Only - top level fields of [Job][google.cloud.talent.v4.Job] are - supported. - - If - [update_mask][google.cloud.talent.v4.BatchUpdateJobsRequest.update_mask] - is provided, The [Job][google.cloud.talent.v4.Job] inside - [JobResult][JobOperationResult.JobResult] will only contains - fields that is updated, plus the Id of the Job. Otherwise, - [Job][google.cloud.talent.v4.Job] will include all fields, - which can yield a very large response. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - jobs = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=gct_job.Job, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) - - -class BatchDeleteJobsRequest(proto.Message): - r"""Request to delete a batch of jobs. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenants/bar". - - The parent of all of the jobs specified in ``names`` must - match this field. - names (Sequence[str]): - The names of the jobs to delete. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - A maximum of 200 jobs can be deleted in a batch. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - names = proto.RepeatedField( - proto.STRING, - number=2, - ) - - -class JobResult(proto.Message): - r"""Mutation result of a job from a batch operation. - - Attributes: - job (google.cloud.talent_v4.types.Job): - Here [Job][google.cloud.talent.v4.Job] only contains basic - information including - [name][google.cloud.talent.v4.Job.name], - [company][google.cloud.talent.v4.Job.company], - [language_code][google.cloud.talent.v4.Job.language_code] - and - [requisition_id][google.cloud.talent.v4.Job.requisition_id], - use getJob method to retrieve detailed information of the - created/updated job. - status (google.rpc.status_pb2.Status): - The status of the job processed. This field is populated if - the processing of the - [job][google.cloud.talent.v4.JobResult.job] fails. - """ - - job = proto.Field( - proto.MESSAGE, - number=1, - message=gct_job.Job, - ) - status = proto.Field( - proto.MESSAGE, - number=2, - message=status_pb2.Status, - ) - - -class BatchCreateJobsResponse(proto.Message): - r"""The result of - [JobService.BatchCreateJobs][google.cloud.talent.v4.JobService.BatchCreateJobs]. - It's used to replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - Attributes: - job_results (Sequence[google.cloud.talent_v4.types.JobResult]): - List of job mutation results from a batch - create operation. It can change until operation - status is FINISHED, FAILED or CANCELLED. - """ - - job_results = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='JobResult', - ) - - -class BatchUpdateJobsResponse(proto.Message): - r"""The result of - [JobService.BatchUpdateJobs][google.cloud.talent.v4.JobService.BatchUpdateJobs]. - It's used to replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - Attributes: - job_results (Sequence[google.cloud.talent_v4.types.JobResult]): - List of job mutation results from a batch - update operation. It can change until operation - status is FINISHED, FAILED or CANCELLED. - """ - - job_results = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='JobResult', - ) - - -class BatchDeleteJobsResponse(proto.Message): - r"""The result of - [JobService.BatchDeleteJobs][google.cloud.talent.v4.JobService.BatchDeleteJobs]. - It's used to replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - Attributes: - job_results (Sequence[google.cloud.talent_v4.types.JobResult]): - List of job mutation results from a batch - delete operation. It can change until operation - status is FINISHED, FAILED or CANCELLED. - """ - - job_results = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='JobResult', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant.py deleted file mode 100644 index c4f3349a..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant.py +++ /dev/null @@ -1,58 +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 proto # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'Tenant', - }, -) - - -class Tenant(proto.Message): - r"""A Tenant resource represents a tenant in the service. A - tenant is a group or entity that shares common access with - specific privileges for resources like jobs. Customer may create - multiple tenants to provide data isolation for different groups. - - Attributes: - name (str): - Required during tenant update. - - The resource name for a tenant. This is generated by the - service when a tenant is created. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - external_id (str): - Required. Client side tenant identifier, used - to uniquely identify the tenant. - The maximum number of allowed characters is 255. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - external_id = proto.Field( - proto.STRING, - number=2, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant_service.py b/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant_service.py deleted file mode 100644 index 27492553..00000000 --- a/owl-bot-staging/v4/google/cloud/talent_v4/types/tenant_service.py +++ /dev/null @@ -1,194 +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 proto # type: ignore - -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import tenant as gct_tenant -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4', - manifest={ - 'CreateTenantRequest', - 'GetTenantRequest', - 'UpdateTenantRequest', - 'DeleteTenantRequest', - 'ListTenantsRequest', - 'ListTenantsResponse', - }, -) - - -class CreateTenantRequest(proto.Message): - r"""The Request of the CreateTenant method. - - Attributes: - parent (str): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - tenant (google.cloud.talent_v4.types.Tenant): - Required. The tenant to be created. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - tenant = proto.Field( - proto.MESSAGE, - number=2, - message=gct_tenant.Tenant, - ) - - -class GetTenantRequest(proto.Message): - r"""Request for getting a tenant by name. - - Attributes: - name (str): - Required. The resource name of the tenant to be retrieved. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateTenantRequest(proto.Message): - r"""Request for updating a specified tenant. - - Attributes: - tenant (google.cloud.talent_v4.types.Tenant): - Required. The tenant 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.v4.UpdateTenantRequest.update_mask] - is provided, only the specified fields in - [tenant][google.cloud.talent.v4.UpdateTenantRequest.tenant] - are updated. Otherwise all the fields are updated. - - A field mask to specify the tenant fields to be updated. - Only top level fields of - [Tenant][google.cloud.talent.v4.Tenant] are supported. - """ - - tenant = proto.Field( - proto.MESSAGE, - number=1, - message=gct_tenant.Tenant, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteTenantRequest(proto.Message): - r"""Request to delete a tenant. - - Attributes: - name (str): - Required. The resource name of the tenant to be deleted. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListTenantsRequest(proto.Message): - r"""List tenants for which the client has ACL visibility. - - Attributes: - parent (str): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - page_token (str): - The starting indicator from which to return - results. - page_size (int): - The maximum number of tenants 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 ListTenantsResponse(proto.Message): - r"""The List tenants response object. - - Attributes: - tenants (Sequence[google.cloud.talent_v4.types.Tenant]): - Tenants for the current client. - next_page_token (str): - A token to retrieve the next page of results. - metadata (google.cloud.talent_v4.types.ResponseMetadata): - Additional information for the API - invocation, such as the request tracking id. - """ - - @property - def raw_page(self): - return self - - tenants = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gct_tenant.Tenant, - ) - 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/owl-bot-staging/v4/mypy.ini b/owl-bot-staging/v4/mypy.ini deleted file mode 100644 index 574c5aed..00000000 --- a/owl-bot-staging/v4/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.7 -namespace_packages = True diff --git a/owl-bot-staging/v4/noxfile.py b/owl-bot-staging/v4/noxfile.py deleted file mode 100644 index 68bf7fef..00000000 --- a/owl-bot-staging/v4/noxfile.py +++ /dev/null @@ -1,179 +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 -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -ALL_PYTHON = [ - "3.7", - "3.8", - "3.9", - "3.10", -] - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - -BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] -DEFAULT_PYTHON_VERSION = "3.10" - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", - "blacken", - "lint", - "lint_setup_py", -] - -@nox.session(python=ALL_PYTHON) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/talent_v4/', - '--cov=tests/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - 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", "erase") - - -@nox.session(python=ALL_PYTHON) -def mypy(session): - """Run the type checker.""" - session.install('mypy', 'types-pkg_resources') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx==4.0.1", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): - """Run linters. - - Returns a failure if the linters find linting errors or sufficiently - serious code quality issues. - """ - session.install("flake8", BLACK_VERSION) - session.run( - "black", - "--check", - *BLACK_PATHS, - ) - session.run("flake8", "google", "tests", "samples") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def blacken(session): - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - session.run( - "black", - *BLACK_PATHS, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint_setup_py(session): - """Verify that setup.py is valid (including RST check).""" - session.install("docutils", "pygments") - session.run("python", "setup.py", "check", "--restructuredtext", "--strict") diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py deleted file mode 100644 index 3d8f0347..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py +++ /dev/null @@ -1,57 +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 CreateCompany -# 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_v4_generated_CompanyService_CreateCompany_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_create_company(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - company = talent_v4.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4.CreateCompanyRequest( - parent="parent_value", - company=company, - ) - - # Make the request - response = await client.create_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_CompanyService_CreateCompany_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py deleted file mode 100644 index 27af7ae7..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py +++ /dev/null @@ -1,57 +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 CreateCompany -# 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_v4_generated_CompanyService_CreateCompany_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_create_company(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - company = talent_v4.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4.CreateCompanyRequest( - parent="parent_value", - company=company, - ) - - # Make the request - response = client.create_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_CompanyService_CreateCompany_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py deleted file mode 100644 index caa9c658..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_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 DeleteCompany -# 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_v4_generated_CompanyService_DeleteCompany_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_delete_company(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.DeleteCompanyRequest( - name="name_value", - ) - - # Make the request - await client.delete_company(request=request) - - -# [END jobs_v4_generated_CompanyService_DeleteCompany_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py deleted file mode 100644 index b2340952..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_delete_company_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 DeleteCompany -# 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_v4_generated_CompanyService_DeleteCompany_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_delete_company(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4.DeleteCompanyRequest( - name="name_value", - ) - - # Make the request - client.delete_company(request=request) - - -# [END jobs_v4_generated_CompanyService_DeleteCompany_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py deleted file mode 100644 index 413260e0..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py +++ /dev/null @@ -1,52 +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 GetCompany -# 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_v4_generated_CompanyService_GetCompany_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_get_company(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.GetCompanyRequest( - name="name_value", - ) - - # Make the request - response = await client.get_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_CompanyService_GetCompany_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py deleted file mode 100644 index d7a20735..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py +++ /dev/null @@ -1,52 +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 GetCompany -# 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_v4_generated_CompanyService_GetCompany_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_get_company(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4.GetCompanyRequest( - name="name_value", - ) - - # Make the request - response = client.get_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_CompanyService_GetCompany_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py deleted file mode 100644 index acfa5f8c..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py +++ /dev/null @@ -1,53 +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 ListCompanies -# 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_v4_generated_CompanyService_ListCompanies_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_list_companies(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.ListCompaniesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_companies(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4_generated_CompanyService_ListCompanies_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py deleted file mode 100644 index 8fc4f9a4..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py +++ /dev/null @@ -1,53 +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 ListCompanies -# 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_v4_generated_CompanyService_ListCompanies_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_list_companies(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4.ListCompaniesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_companies(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4_generated_CompanyService_ListCompanies_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py deleted file mode 100644 index 15895bf7..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py +++ /dev/null @@ -1,56 +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 UpdateCompany -# 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_v4_generated_CompanyService_UpdateCompany_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_update_company(): - # Create a client - client = talent_v4.CompanyServiceAsyncClient() - - # Initialize request argument(s) - company = talent_v4.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4.UpdateCompanyRequest( - company=company, - ) - - # Make the request - response = await client.update_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_CompanyService_UpdateCompany_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py deleted file mode 100644 index f382f1d7..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py +++ /dev/null @@ -1,56 +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 UpdateCompany -# 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_v4_generated_CompanyService_UpdateCompany_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_update_company(): - # Create a client - client = talent_v4.CompanyServiceClient() - - # Initialize request argument(s) - company = talent_v4.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4.UpdateCompanyRequest( - company=company, - ) - - # Make the request - response = client.update_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_CompanyService_UpdateCompany_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py deleted file mode 100644 index 9e06a6b2..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py +++ /dev/null @@ -1,54 +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 CompleteQuery -# 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_v4_generated_Completion_CompleteQuery_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_complete_query(): - # Create a client - client = talent_v4.CompletionAsyncClient() - - # Initialize request argument(s) - request = talent_v4.CompleteQueryRequest( - tenant="tenant_value", - query="query_value", - page_size=951, - ) - - # Make the request - response = await client.complete_query(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_Completion_CompleteQuery_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py deleted file mode 100644 index 8859bc96..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py +++ /dev/null @@ -1,54 +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 CompleteQuery -# 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_v4_generated_Completion_CompleteQuery_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_complete_query(): - # Create a client - client = talent_v4.CompletionClient() - - # Initialize request argument(s) - request = talent_v4.CompleteQueryRequest( - tenant="tenant_value", - query="query_value", - page_size=951, - ) - - # Make the request - response = client.complete_query(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_Completion_CompleteQuery_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py deleted file mode 100644 index cbb8a812..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py +++ /dev/null @@ -1,58 +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 CreateClientEvent -# 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_v4_generated_EventService_CreateClientEvent_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_create_client_event(): - # Create a client - client = talent_v4.EventServiceAsyncClient() - - # Initialize request argument(s) - client_event = talent_v4.ClientEvent() - client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] - client_event.event_id = "event_id_value" - - request = talent_v4.CreateClientEventRequest( - parent="parent_value", - client_event=client_event, - ) - - # Make the request - response = await client.create_client_event(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_EventService_CreateClientEvent_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py deleted file mode 100644 index 21337ce6..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py +++ /dev/null @@ -1,58 +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 CreateClientEvent -# 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_v4_generated_EventService_CreateClientEvent_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_create_client_event(): - # Create a client - client = talent_v4.EventServiceClient() - - # Initialize request argument(s) - client_event = talent_v4.ClientEvent() - client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] - client_event.event_id = "event_id_value" - - request = talent_v4.CreateClientEventRequest( - parent="parent_value", - client_event=client_event, - ) - - # Make the request - response = client.create_client_event(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_EventService_CreateClientEvent_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py deleted file mode 100644 index 489582dd..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py +++ /dev/null @@ -1,63 +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 BatchCreateJobs -# 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_v4_generated_JobService_BatchCreateJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_batch_create_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - jobs = talent_v4.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4.BatchCreateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_create_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_BatchCreateJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py deleted file mode 100644 index b6d2524a..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py +++ /dev/null @@ -1,63 +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 BatchCreateJobs -# 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_v4_generated_JobService_BatchCreateJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_batch_create_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - jobs = talent_v4.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4.BatchCreateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_create_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_BatchCreateJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py deleted file mode 100644 index 3fc26c7d..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py +++ /dev/null @@ -1,56 +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 BatchDeleteJobs -# 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_v4_generated_JobService_BatchDeleteJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_batch_delete_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.BatchDeleteJobsRequest( - parent="parent_value", - ) - - # Make the request - operation = client.batch_delete_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_BatchDeleteJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py deleted file mode 100644 index d9be665a..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py +++ /dev/null @@ -1,56 +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 BatchDeleteJobs -# 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_v4_generated_JobService_BatchDeleteJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_batch_delete_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.BatchDeleteJobsRequest( - parent="parent_value", - ) - - # Make the request - operation = client.batch_delete_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_BatchDeleteJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py deleted file mode 100644 index 780f7ddd..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py +++ /dev/null @@ -1,63 +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 BatchUpdateJobs -# 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_v4_generated_JobService_BatchUpdateJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_batch_update_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - jobs = talent_v4.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4.BatchUpdateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_update_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_BatchUpdateJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py deleted file mode 100644 index 952a835e..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py +++ /dev/null @@ -1,63 +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 BatchUpdateJobs -# 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_v4_generated_JobService_BatchUpdateJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_batch_update_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - jobs = talent_v4.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4.BatchUpdateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_update_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_BatchUpdateJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py deleted file mode 100644 index d5c1f62e..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py +++ /dev/null @@ -1,59 +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 CreateJob -# 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_v4_generated_JobService_CreateJob_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_create_job(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - job = talent_v4.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4.CreateJobRequest( - parent="parent_value", - job=job, - ) - - # Make the request - response = await client.create_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_CreateJob_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py deleted file mode 100644 index b9a794a1..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py +++ /dev/null @@ -1,59 +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 CreateJob -# 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_v4_generated_JobService_CreateJob_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_create_job(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - job = talent_v4.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4.CreateJobRequest( - parent="parent_value", - job=job, - ) - - # Make the request - response = client.create_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_CreateJob_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py deleted file mode 100644 index 9bf6acb8..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_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 DeleteJob -# 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_v4_generated_JobService_DeleteJob_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_delete_job(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.DeleteJobRequest( - name="name_value", - ) - - # Make the request - await client.delete_job(request=request) - - -# [END jobs_v4_generated_JobService_DeleteJob_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py deleted file mode 100644 index 88bd9f96..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_delete_job_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 DeleteJob -# 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_v4_generated_JobService_DeleteJob_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_delete_job(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.DeleteJobRequest( - name="name_value", - ) - - # Make the request - client.delete_job(request=request) - - -# [END jobs_v4_generated_JobService_DeleteJob_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py deleted file mode 100644 index d69b7c04..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py +++ /dev/null @@ -1,52 +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 GetJob -# 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_v4_generated_JobService_GetJob_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_get_job(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.GetJobRequest( - name="name_value", - ) - - # Make the request - response = await client.get_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_GetJob_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py deleted file mode 100644 index f757ceea..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py +++ /dev/null @@ -1,52 +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 GetJob -# 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_v4_generated_JobService_GetJob_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_get_job(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.GetJobRequest( - name="name_value", - ) - - # Make the request - response = client.get_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_GetJob_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py deleted file mode 100644 index 2bf1f6cd..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py +++ /dev/null @@ -1,54 +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 ListJobs -# 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_v4_generated_JobService_ListJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_list_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.ListJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - page_result = client.list_jobs(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4_generated_JobService_ListJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py deleted file mode 100644 index 5537f71f..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py +++ /dev/null @@ -1,54 +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 ListJobs -# 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_v4_generated_JobService_ListJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_list_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.ListJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - page_result = client.list_jobs(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4_generated_JobService_ListJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py deleted file mode 100644 index 76fb33fd..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py +++ /dev/null @@ -1,52 +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 SearchJobs -# 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_v4_generated_JobService_SearchJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_search_jobs(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - response = await client.search_jobs(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_SearchJobs_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py deleted file mode 100644 index fb28ec78..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py +++ /dev/null @@ -1,52 +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 SearchJobsForAlert -# 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_v4_generated_JobService_SearchJobsForAlert_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_search_jobs_for_alert(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - response = await client.search_jobs_for_alert(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_SearchJobsForAlert_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py deleted file mode 100644 index 65151219..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py +++ /dev/null @@ -1,52 +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 SearchJobsForAlert -# 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_v4_generated_JobService_SearchJobsForAlert_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_search_jobs_for_alert(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - response = client.search_jobs_for_alert(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_SearchJobsForAlert_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py deleted file mode 100644 index b629c86d..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py +++ /dev/null @@ -1,52 +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 SearchJobs -# 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_v4_generated_JobService_SearchJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_search_jobs(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - response = client.search_jobs(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_SearchJobs_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py deleted file mode 100644 index 295e6fde..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py +++ /dev/null @@ -1,58 +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 UpdateJob -# 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_v4_generated_JobService_UpdateJob_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_update_job(): - # Create a client - client = talent_v4.JobServiceAsyncClient() - - # Initialize request argument(s) - job = talent_v4.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4.UpdateJobRequest( - job=job, - ) - - # Make the request - response = await client.update_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_UpdateJob_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py deleted file mode 100644 index b0488902..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py +++ /dev/null @@ -1,58 +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 UpdateJob -# 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_v4_generated_JobService_UpdateJob_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_update_job(): - # Create a client - client = talent_v4.JobServiceClient() - - # Initialize request argument(s) - job = talent_v4.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4.UpdateJobRequest( - job=job, - ) - - # Make the request - response = client.update_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_JobService_UpdateJob_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py deleted file mode 100644 index 6dc93795..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py +++ /dev/null @@ -1,56 +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 CreateTenant -# 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_v4_generated_TenantService_CreateTenant_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_create_tenant(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - tenant = talent_v4.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4.CreateTenantRequest( - parent="parent_value", - tenant=tenant, - ) - - # Make the request - response = await client.create_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_TenantService_CreateTenant_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py deleted file mode 100644 index 350b7d5b..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py +++ /dev/null @@ -1,56 +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 CreateTenant -# 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_v4_generated_TenantService_CreateTenant_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_create_tenant(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - tenant = talent_v4.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4.CreateTenantRequest( - parent="parent_value", - tenant=tenant, - ) - - # Make the request - response = client.create_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_TenantService_CreateTenant_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py deleted file mode 100644 index 4938c7d5..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_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 DeleteTenant -# 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_v4_generated_TenantService_DeleteTenant_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_delete_tenant(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.DeleteTenantRequest( - name="name_value", - ) - - # Make the request - await client.delete_tenant(request=request) - - -# [END jobs_v4_generated_TenantService_DeleteTenant_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py deleted file mode 100644 index 948fb992..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_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 DeleteTenant -# 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_v4_generated_TenantService_DeleteTenant_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_delete_tenant(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4.DeleteTenantRequest( - name="name_value", - ) - - # Make the request - client.delete_tenant(request=request) - - -# [END jobs_v4_generated_TenantService_DeleteTenant_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py deleted file mode 100644 index 329d4493..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py +++ /dev/null @@ -1,52 +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 GetTenant -# 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_v4_generated_TenantService_GetTenant_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_get_tenant(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.GetTenantRequest( - name="name_value", - ) - - # Make the request - response = await client.get_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_TenantService_GetTenant_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py deleted file mode 100644 index d6b4a785..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py +++ /dev/null @@ -1,52 +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 GetTenant -# 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_v4_generated_TenantService_GetTenant_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_get_tenant(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4.GetTenantRequest( - name="name_value", - ) - - # Make the request - response = client.get_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_TenantService_GetTenant_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py deleted file mode 100644 index 1be0cc08..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py +++ /dev/null @@ -1,53 +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 ListTenants -# 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_v4_generated_TenantService_ListTenants_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_list_tenants(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4.ListTenantsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_tenants(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4_generated_TenantService_ListTenants_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py deleted file mode 100644 index df7fa906..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py +++ /dev/null @@ -1,53 +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 ListTenants -# 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_v4_generated_TenantService_ListTenants_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_list_tenants(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4.ListTenantsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_tenants(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4_generated_TenantService_ListTenants_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py deleted file mode 100644 index 4098de41..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py +++ /dev/null @@ -1,55 +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 UpdateTenant -# 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_v4_generated_TenantService_UpdateTenant_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -async def sample_update_tenant(): - # Create a client - client = talent_v4.TenantServiceAsyncClient() - - # Initialize request argument(s) - tenant = talent_v4.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4.UpdateTenantRequest( - tenant=tenant, - ) - - # Make the request - response = await client.update_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_TenantService_UpdateTenant_async] diff --git a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py b/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py deleted file mode 100644 index d70a2de6..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py +++ /dev/null @@ -1,55 +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 UpdateTenant -# 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_v4_generated_TenantService_UpdateTenant_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4 - - -def sample_update_tenant(): - # Create a client - client = talent_v4.TenantServiceClient() - - # Initialize request argument(s) - tenant = talent_v4.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4.UpdateTenantRequest( - tenant=tenant, - ) - - # Make the request - response = client.update_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4_generated_TenantService_UpdateTenant_sync] diff --git a/owl-bot-staging/v4/samples/generated_samples/snippet_metadata_talent_v4.json b/owl-bot-staging/v4/samples/generated_samples/snippet_metadata_talent_v4.json deleted file mode 100644 index abf91447..00000000 --- a/owl-bot-staging/v4/samples/generated_samples/snippet_metadata_talent_v4.json +++ /dev/null @@ -1,3602 +0,0 @@ -{ - "clientLibrary": { - "apis": [ - { - "id": "google.cloud.talent.v4", - "version": "v4" - } - ], - "language": "PYTHON", - "name": "google-cloud-talent" - }, - "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.create_company", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.CreateCompany", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "CreateCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.CreateCompanyRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "company", - "type": "google.cloud.talent_v4.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_v4.types.Company", - "shortName": "create_company" - }, - "description": "Sample for CreateCompany", - "file": "jobs_v4_generated_company_service_create_company_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_CreateCompany_async", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_create_company_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceClient.create_company", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.CreateCompany", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "CreateCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.CreateCompanyRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "company", - "type": "google.cloud.talent_v4.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_v4.types.Company", - "shortName": "create_company" - }, - "description": "Sample for CreateCompany", - "file": "jobs_v4_generated_company_service_create_company_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_CreateCompany_sync", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_create_company_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.delete_company", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.DeleteCompany", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "DeleteCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4_generated_company_service_delete_company_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_DeleteCompany_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_delete_company_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceClient.delete_company", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.DeleteCompany", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "DeleteCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4_generated_company_service_delete_company_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_DeleteCompany_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_delete_company_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.get_company", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.GetCompany", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "GetCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4.types.Company", - "shortName": "get_company" - }, - "description": "Sample for GetCompany", - "file": "jobs_v4_generated_company_service_get_company_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_GetCompany_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_get_company_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceClient.get_company", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.GetCompany", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "GetCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4.types.Company", - "shortName": "get_company" - }, - "description": "Sample for GetCompany", - "file": "jobs_v4_generated_company_service_get_company_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_GetCompany_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_get_company_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.list_companies", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.ListCompanies", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "ListCompanies" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4.services.company_service.pagers.ListCompaniesAsyncPager", - "shortName": "list_companies" - }, - "description": "Sample for ListCompanies", - "file": "jobs_v4_generated_company_service_list_companies_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_ListCompanies_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_list_companies_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceClient.list_companies", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.ListCompanies", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "ListCompanies" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4.services.company_service.pagers.ListCompaniesPager", - "shortName": "list_companies" - }, - "description": "Sample for ListCompanies", - "file": "jobs_v4_generated_company_service_list_companies_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_ListCompanies_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_list_companies_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceAsyncClient.update_company", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.UpdateCompany", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "UpdateCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.UpdateCompanyRequest" - }, - { - "name": "company", - "type": "google.cloud.talent_v4.types.Company" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.Company", - "shortName": "update_company" - }, - "description": "Sample for UpdateCompany", - "file": "jobs_v4_generated_company_service_update_company_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_UpdateCompany_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_update_company_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "fullName": "google.cloud.talent_v4.CompanyServiceClient.update_company", - "method": { - "fullName": "google.cloud.talent.v4.CompanyService.UpdateCompany", - "service": { - "fullName": "google.cloud.talent.v4.CompanyService", - "shortName": "CompanyService" - }, - "shortName": "UpdateCompany" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.UpdateCompanyRequest" - }, - { - "name": "company", - "type": "google.cloud.talent_v4.types.Company" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.Company", - "shortName": "update_company" - }, - "description": "Sample for UpdateCompany", - "file": "jobs_v4_generated_company_service_update_company_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_CompanyService_UpdateCompany_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_company_service_update_company_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.CompletionAsyncClient", - "shortName": "CompletionAsyncClient" - }, - "fullName": "google.cloud.talent_v4.CompletionAsyncClient.complete_query", - "method": { - "fullName": "google.cloud.talent.v4.Completion.CompleteQuery", - "service": { - "fullName": "google.cloud.talent.v4.Completion", - "shortName": "Completion" - }, - "shortName": "CompleteQuery" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4.types.CompleteQueryResponse", - "shortName": "complete_query" - }, - "description": "Sample for CompleteQuery", - "file": "jobs_v4_generated_completion_complete_query_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_Completion_CompleteQuery_async", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_completion_complete_query_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.CompletionClient", - "shortName": "CompletionClient" - }, - "fullName": "google.cloud.talent_v4.CompletionClient.complete_query", - "method": { - "fullName": "google.cloud.talent.v4.Completion.CompleteQuery", - "service": { - "fullName": "google.cloud.talent.v4.Completion", - "shortName": "Completion" - }, - "shortName": "CompleteQuery" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4.types.CompleteQueryResponse", - "shortName": "complete_query" - }, - "description": "Sample for CompleteQuery", - "file": "jobs_v4_generated_completion_complete_query_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_Completion_CompleteQuery_sync", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_completion_complete_query_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.EventServiceAsyncClient", - "shortName": "EventServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.EventServiceAsyncClient.create_client_event", - "method": { - "fullName": "google.cloud.talent.v4.EventService.CreateClientEvent", - "service": { - "fullName": "google.cloud.talent.v4.EventService", - "shortName": "EventService" - }, - "shortName": "CreateClientEvent" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.CreateClientEventRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "client_event", - "type": "google.cloud.talent_v4.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_v4.types.ClientEvent", - "shortName": "create_client_event" - }, - "description": "Sample for CreateClientEvent", - "file": "jobs_v4_generated_event_service_create_client_event_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_EventService_CreateClientEvent_async", - "segments": [ - { - "end": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_event_service_create_client_event_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.EventServiceClient", - "shortName": "EventServiceClient" - }, - "fullName": "google.cloud.talent_v4.EventServiceClient.create_client_event", - "method": { - "fullName": "google.cloud.talent.v4.EventService.CreateClientEvent", - "service": { - "fullName": "google.cloud.talent.v4.EventService", - "shortName": "EventService" - }, - "shortName": "CreateClientEvent" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.CreateClientEventRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "client_event", - "type": "google.cloud.talent_v4.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_v4.types.ClientEvent", - "shortName": "create_client_event" - }, - "description": "Sample for CreateClientEvent", - "file": "jobs_v4_generated_event_service_create_client_event_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_EventService_CreateClientEvent_sync", - "segments": [ - { - "end": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_event_service_create_client_event_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.batch_create_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.BatchCreateJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "BatchCreateJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.BatchCreateJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "jobs", - "type": "Sequence[google.cloud.talent_v4.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_v4_generated_job_service_batch_create_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_BatchCreateJobs_async", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_batch_create_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.batch_create_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.BatchCreateJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "BatchCreateJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.BatchCreateJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "jobs", - "type": "Sequence[google.cloud.talent_v4.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_v4_generated_job_service_batch_create_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_BatchCreateJobs_sync", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_batch_create_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.batch_delete_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.BatchDeleteJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "BatchDeleteJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.BatchDeleteJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "names", - "type": "Sequence[str]" - }, - { - "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_delete_jobs" - }, - "description": "Sample for BatchDeleteJobs", - "file": "jobs_v4_generated_job_service_batch_delete_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_BatchDeleteJobs_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_batch_delete_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.batch_delete_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.BatchDeleteJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "BatchDeleteJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.BatchDeleteJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "names", - "type": "Sequence[str]" - }, - { - "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_delete_jobs" - }, - "description": "Sample for BatchDeleteJobs", - "file": "jobs_v4_generated_job_service_batch_delete_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_BatchDeleteJobs_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_batch_delete_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.batch_update_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.BatchUpdateJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "BatchUpdateJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.BatchUpdateJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "jobs", - "type": "Sequence[google.cloud.talent_v4.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_v4_generated_job_service_batch_update_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_BatchUpdateJobs_async", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_batch_update_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.batch_update_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.BatchUpdateJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "BatchUpdateJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.BatchUpdateJobsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "jobs", - "type": "Sequence[google.cloud.talent_v4.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_v4_generated_job_service_batch_update_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_BatchUpdateJobs_sync", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_batch_update_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.create_job", - "method": { - "fullName": "google.cloud.talent.v4.JobService.CreateJob", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "CreateJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.CreateJobRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "job", - "type": "google.cloud.talent_v4.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_v4.types.Job", - "shortName": "create_job" - }, - "description": "Sample for CreateJob", - "file": "jobs_v4_generated_job_service_create_job_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_CreateJob_async", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_create_job_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.create_job", - "method": { - "fullName": "google.cloud.talent.v4.JobService.CreateJob", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "CreateJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.CreateJobRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "job", - "type": "google.cloud.talent_v4.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_v4.types.Job", - "shortName": "create_job" - }, - "description": "Sample for CreateJob", - "file": "jobs_v4_generated_job_service_create_job_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_CreateJob_sync", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_create_job_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.delete_job", - "method": { - "fullName": "google.cloud.talent.v4.JobService.DeleteJob", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "DeleteJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4_generated_job_service_delete_job_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_DeleteJob_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_delete_job_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.delete_job", - "method": { - "fullName": "google.cloud.talent.v4.JobService.DeleteJob", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "DeleteJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.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_v4_generated_job_service_delete_job_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_DeleteJob_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_delete_job_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.get_job", - "method": { - "fullName": "google.cloud.talent.v4.JobService.GetJob", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "GetJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.GetJobRequest" - }, - { - "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_v4.types.Job", - "shortName": "get_job" - }, - "description": "Sample for GetJob", - "file": "jobs_v4_generated_job_service_get_job_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_GetJob_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_get_job_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.get_job", - "method": { - "fullName": "google.cloud.talent.v4.JobService.GetJob", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "GetJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.GetJobRequest" - }, - { - "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_v4.types.Job", - "shortName": "get_job" - }, - "description": "Sample for GetJob", - "file": "jobs_v4_generated_job_service_get_job_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_GetJob_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_get_job_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.list_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.ListJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "ListJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.ListJobsRequest" - }, - { - "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]" - } - ], - "resultType": "google.cloud.talent_v4.services.job_service.pagers.ListJobsAsyncPager", - "shortName": "list_jobs" - }, - "description": "Sample for ListJobs", - "file": "jobs_v4_generated_job_service_list_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_ListJobs_async", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_list_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.list_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.ListJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "ListJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.ListJobsRequest" - }, - { - "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]" - } - ], - "resultType": "google.cloud.talent_v4.services.job_service.pagers.ListJobsPager", - "shortName": "list_jobs" - }, - "description": "Sample for ListJobs", - "file": "jobs_v4_generated_job_service_list_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_ListJobs_sync", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_list_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.search_jobs_for_alert", - "method": { - "fullName": "google.cloud.talent.v4.JobService.SearchJobsForAlert", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "SearchJobsForAlert" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.SearchJobsRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", - "shortName": "search_jobs_for_alert" - }, - "description": "Sample for SearchJobsForAlert", - "file": "jobs_v4_generated_job_service_search_jobs_for_alert_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_SearchJobsForAlert_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_search_jobs_for_alert_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.search_jobs_for_alert", - "method": { - "fullName": "google.cloud.talent.v4.JobService.SearchJobsForAlert", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "SearchJobsForAlert" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.SearchJobsRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", - "shortName": "search_jobs_for_alert" - }, - "description": "Sample for SearchJobsForAlert", - "file": "jobs_v4_generated_job_service_search_jobs_for_alert_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_SearchJobsForAlert_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_search_jobs_for_alert_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.search_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.SearchJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "SearchJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.SearchJobsRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", - "shortName": "search_jobs" - }, - "description": "Sample for SearchJobs", - "file": "jobs_v4_generated_job_service_search_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_SearchJobs_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_search_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.search_jobs", - "method": { - "fullName": "google.cloud.talent.v4.JobService.SearchJobs", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "SearchJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.SearchJobsRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", - "shortName": "search_jobs" - }, - "description": "Sample for SearchJobs", - "file": "jobs_v4_generated_job_service_search_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_SearchJobs_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_search_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceAsyncClient.update_job", - "method": { - "fullName": "google.cloud.talent.v4.JobService.UpdateJob", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "UpdateJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.UpdateJobRequest" - }, - { - "name": "job", - "type": "google.cloud.talent_v4.types.Job" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.Job", - "shortName": "update_job" - }, - "description": "Sample for UpdateJob", - "file": "jobs_v4_generated_job_service_update_job_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_UpdateJob_async", - "segments": [ - { - "end": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_update_job_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4.JobServiceClient.update_job", - "method": { - "fullName": "google.cloud.talent.v4.JobService.UpdateJob", - "service": { - "fullName": "google.cloud.talent.v4.JobService", - "shortName": "JobService" - }, - "shortName": "UpdateJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.UpdateJobRequest" - }, - { - "name": "job", - "type": "google.cloud.talent_v4.types.Job" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.Job", - "shortName": "update_job" - }, - "description": "Sample for UpdateJob", - "file": "jobs_v4_generated_job_service_update_job_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_JobService_UpdateJob_sync", - "segments": [ - { - "end": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_job_service_update_job_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.create_tenant", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.CreateTenant", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "CreateTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.CreateTenantRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "tenant", - "type": "google.cloud.talent_v4.types.Tenant" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.Tenant", - "shortName": "create_tenant" - }, - "description": "Sample for CreateTenant", - "file": "jobs_v4_generated_tenant_service_create_tenant_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_CreateTenant_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_create_tenant_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceClient.create_tenant", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.CreateTenant", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "CreateTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.CreateTenantRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "tenant", - "type": "google.cloud.talent_v4.types.Tenant" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.Tenant", - "shortName": "create_tenant" - }, - "description": "Sample for CreateTenant", - "file": "jobs_v4_generated_tenant_service_create_tenant_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_CreateTenant_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_create_tenant_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.delete_tenant", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.DeleteTenant", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "DeleteTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.DeleteTenantRequest" - }, - { - "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_tenant" - }, - "description": "Sample for DeleteTenant", - "file": "jobs_v4_generated_tenant_service_delete_tenant_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_DeleteTenant_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_delete_tenant_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceClient.delete_tenant", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.DeleteTenant", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "DeleteTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.DeleteTenantRequest" - }, - { - "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_tenant" - }, - "description": "Sample for DeleteTenant", - "file": "jobs_v4_generated_tenant_service_delete_tenant_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_DeleteTenant_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_delete_tenant_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.get_tenant", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.GetTenant", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "GetTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.GetTenantRequest" - }, - { - "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_v4.types.Tenant", - "shortName": "get_tenant" - }, - "description": "Sample for GetTenant", - "file": "jobs_v4_generated_tenant_service_get_tenant_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_GetTenant_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_get_tenant_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceClient.get_tenant", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.GetTenant", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "GetTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.GetTenantRequest" - }, - { - "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_v4.types.Tenant", - "shortName": "get_tenant" - }, - "description": "Sample for GetTenant", - "file": "jobs_v4_generated_tenant_service_get_tenant_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_GetTenant_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_get_tenant_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.list_tenants", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.ListTenants", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "ListTenants" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.ListTenantsRequest" - }, - { - "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_v4.services.tenant_service.pagers.ListTenantsAsyncPager", - "shortName": "list_tenants" - }, - "description": "Sample for ListTenants", - "file": "jobs_v4_generated_tenant_service_list_tenants_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_ListTenants_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_list_tenants_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceClient.list_tenants", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.ListTenants", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "ListTenants" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.ListTenantsRequest" - }, - { - "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_v4.services.tenant_service.pagers.ListTenantsPager", - "shortName": "list_tenants" - }, - "description": "Sample for ListTenants", - "file": "jobs_v4_generated_tenant_service_list_tenants_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_ListTenants_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_list_tenants_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceAsyncClient.update_tenant", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.UpdateTenant", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "UpdateTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.UpdateTenantRequest" - }, - { - "name": "tenant", - "type": "google.cloud.talent_v4.types.Tenant" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.Tenant", - "shortName": "update_tenant" - }, - "description": "Sample for UpdateTenant", - "file": "jobs_v4_generated_tenant_service_update_tenant_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_UpdateTenant_async", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_update_tenant_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4.TenantServiceClient.update_tenant", - "method": { - "fullName": "google.cloud.talent.v4.TenantService.UpdateTenant", - "service": { - "fullName": "google.cloud.talent.v4.TenantService", - "shortName": "TenantService" - }, - "shortName": "UpdateTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4.types.UpdateTenantRequest" - }, - { - "name": "tenant", - "type": "google.cloud.talent_v4.types.Tenant" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.talent_v4.types.Tenant", - "shortName": "update_tenant" - }, - "description": "Sample for UpdateTenant", - "file": "jobs_v4_generated_tenant_service_update_tenant_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4_generated_TenantService_UpdateTenant_sync", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4_generated_tenant_service_update_tenant_sync.py" - } - ] -} diff --git a/owl-bot-staging/v4/scripts/fixup_talent_v4_keywords.py b/owl-bot-staging/v4/scripts/fixup_talent_v4_keywords.py deleted file mode 100644 index 29540143..00000000 --- a/owl-bot-staging/v4/scripts/fixup_talent_v4_keywords.py +++ /dev/null @@ -1,197 +0,0 @@ -#! /usr/bin/env python3 -# -*- 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 argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class talentCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'batch_create_jobs': ('parent', 'jobs', ), - 'batch_delete_jobs': ('parent', 'names', ), - 'batch_update_jobs': ('parent', 'jobs', 'update_mask', ), - 'complete_query': ('tenant', 'query', 'page_size', 'language_codes', 'company', 'scope', 'type_', ), - 'create_client_event': ('parent', 'client_event', ), - 'create_company': ('parent', 'company', ), - 'create_job': ('parent', 'job', ), - 'create_tenant': ('parent', 'tenant', ), - 'delete_company': ('name', ), - 'delete_job': ('name', ), - 'delete_tenant': ('name', ), - 'get_company': ('name', ), - 'get_job': ('name', ), - 'get_tenant': ('name', ), - 'list_companies': ('parent', 'page_token', 'page_size', 'require_open_jobs', ), - 'list_jobs': ('parent', 'filter', 'page_token', 'page_size', 'job_view', ), - 'list_tenants': ('parent', 'page_token', 'page_size', ), - 'search_jobs': ('parent', 'request_metadata', 'search_mode', 'job_query', 'enable_broadening', 'histogram_queries', 'job_view', 'offset', 'max_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', 'histogram_queries', 'job_view', 'offset', 'max_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_tenant': ('tenant', 'update_mask', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: a.keyword.value not in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=talentCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the talent client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v4/setup.py b/owl-bot-staging/v4/setup.py deleted file mode 100644 index ddcd0c82..00000000 --- a/owl-bot-staging/v4/setup.py +++ /dev/null @@ -1,58 +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 io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-talent', - author="Google LLC", - author_email="googleapis-packages@google.com", - url="https://github.com/googleapis/python-google-cloud-talent", - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 2.10.0, < 3.0.0dev', - 'libcst >= 0.2.5', - 'googleapis-common-protos >= 1.55.0, <2.0.0dev', - 'proto-plus >= 1.19.7', - ), - python_requires='>=3.7', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v4/tests/__init__.py b/owl-bot-staging/v4/tests/__init__.py deleted file mode 100644 index 231bc125..00000000 --- a/owl-bot-staging/v4/tests/__init__.py +++ /dev/null @@ -1,16 +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. -# diff --git a/owl-bot-staging/v4/tests/unit/__init__.py b/owl-bot-staging/v4/tests/unit/__init__.py deleted file mode 100644 index 231bc125..00000000 --- a/owl-bot-staging/v4/tests/unit/__init__.py +++ /dev/null @@ -1,16 +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. -# diff --git a/owl-bot-staging/v4/tests/unit/gapic/__init__.py b/owl-bot-staging/v4/tests/unit/gapic/__init__.py deleted file mode 100644 index 231bc125..00000000 --- a/owl-bot-staging/v4/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +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. -# diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/__init__.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/__init__.py deleted file mode 100644 index 231bc125..00000000 --- a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/__init__.py +++ /dev/null @@ -1,16 +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. -# diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_company_service.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_company_service.py deleted file mode 100644 index fe019c6b..00000000 --- a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_company_service.py +++ /dev/null @@ -1,2687 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4.services.company_service import CompanyServiceAsyncClient -from google.cloud.talent_v4.services.company_service import CompanyServiceClient -from google.cloud.talent_v4.services.company_service import pagers -from google.cloud.talent_v4.services.company_service import transports -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import company -from google.cloud.talent_v4.types import company as gct_company -from google.cloud.talent_v4.types import company_service -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -from google.type import latlng_pb2 # type: ignore -from google.type import postal_address_pb2 # type: ignore -import google.auth - - -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 CompanyServiceClient._get_default_mtls_endpoint(None) is None - assert CompanyServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert CompanyServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert CompanyServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert CompanyServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert CompanyServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (CompanyServiceClient, "grpc"), - (CompanyServiceAsyncClient, "grpc_asyncio"), -]) -def test_company_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.CompanyServiceGrpcTransport, "grpc"), - (transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_company_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", [ - (CompanyServiceClient, "grpc"), - (CompanyServiceAsyncClient, "grpc_asyncio"), -]) -def test_company_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_company_service_client_get_transport_class(): - transport = CompanyServiceClient.get_transport_class() - available_transports = [ - transports.CompanyServiceGrpcTransport, - ] - assert transport in available_transports - - transport = CompanyServiceClient.get_transport_class("grpc") - assert transport == transports.CompanyServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc"), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) -@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) -def test_company_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(CompanyServiceClient, '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(CompanyServiceClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", "true"), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", "false"), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) -@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_company_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - CompanyServiceClient, CompanyServiceAsyncClient -]) -@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) -@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) -def test_company_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", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc"), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_company_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", grpc_helpers), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_company_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, - api_audience=None, - ) - -def test_company_service_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4.services.company_service.transports.CompanyServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = CompanyServiceClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", grpc_helpers), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_company_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, - api_audience=None, - ) - - # 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", [ - company_service.CreateCompanyRequest, - dict, -]) -def test_create_company(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - ) - response = client.create_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.CreateCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -def test_create_company_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 = CompanyServiceClient( - 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_company), - '__call__') as call: - client.create_company() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.CreateCompanyRequest() - -@pytest.mark.asyncio -async def test_create_company_async(transport: str = 'grpc_asyncio', request_type=company_service.CreateCompanyRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - )) - response = await client.create_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.CreateCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -@pytest.mark.asyncio -async def test_create_company_async_from_dict(): - await test_create_company_async(request_type=dict) - - -def test_create_company_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 = company_service.CreateCompanyRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_company), - '__call__') as call: - call.return_value = gct_company.Company() - client.create_company(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_company_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 = company_service.CreateCompanyRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_company), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) - await client.create_company(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_company_flattened(): - 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.create_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_company( - parent='parent_value', - company=gct_company.Company(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].company - mock_val = gct_company.Company(name='name_value') - assert arg == mock_val - - -def test_create_company_flattened_error(): - client = CompanyServiceClient( - 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_company( - company_service.CreateCompanyRequest(), - parent='parent_value', - company=gct_company.Company(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_company_flattened_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.create_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_company( - parent='parent_value', - company=gct_company.Company(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].company - mock_val = gct_company.Company(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_company_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_company( - company_service.CreateCompanyRequest(), - parent='parent_value', - company=gct_company.Company(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - company_service.GetCompanyRequest, - dict, -]) -def test_get_company(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - ) - response = client.get_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.GetCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -def test_get_company_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 = CompanyServiceClient( - 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_company), - '__call__') as call: - client.get_company() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.GetCompanyRequest() - -@pytest.mark.asyncio -async def test_get_company_async(transport: str = 'grpc_asyncio', request_type=company_service.GetCompanyRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - )) - response = await client.get_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.GetCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -@pytest.mark.asyncio -async def test_get_company_async_from_dict(): - await test_get_company_async(request_type=dict) - - -def test_get_company_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 = company_service.GetCompanyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_company), - '__call__') as call: - call.return_value = company.Company() - client.get_company(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_company_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 = company_service.GetCompanyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_company), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) - await client.get_company(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_company_flattened(): - 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_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company.Company() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_company( - 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_company_flattened_error(): - client = CompanyServiceClient( - 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_company( - company_service.GetCompanyRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_company_flattened_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_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company.Company() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_company( - 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_company_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_company( - company_service.GetCompanyRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - company_service.UpdateCompanyRequest, - dict, -]) -def test_update_company(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - ) - response = client.update_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.UpdateCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -def test_update_company_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 = CompanyServiceClient( - 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_company), - '__call__') as call: - client.update_company() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.UpdateCompanyRequest() - -@pytest.mark.asyncio -async def test_update_company_async(transport: str = 'grpc_asyncio', request_type=company_service.UpdateCompanyRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - )) - response = await client.update_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.UpdateCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -@pytest.mark.asyncio -async def test_update_company_async_from_dict(): - await test_update_company_async(request_type=dict) - - -def test_update_company_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 = company_service.UpdateCompanyRequest() - - request.company.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_company), - '__call__') as call: - call.return_value = gct_company.Company() - client.update_company(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', - 'company.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_company_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 = company_service.UpdateCompanyRequest() - - request.company.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_company), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) - await client.update_company(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', - 'company.name=name_value', - ) in kw['metadata'] - - -def test_update_company_flattened(): - 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.update_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_company( - company=gct_company.Company(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_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].company - mock_val = gct_company.Company(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_company_flattened_error(): - client = CompanyServiceClient( - 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_company( - company_service.UpdateCompanyRequest(), - company=gct_company.Company(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_company_flattened_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.update_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_company( - company=gct_company.Company(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_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].company - mock_val = gct_company.Company(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_company_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_company( - company_service.UpdateCompanyRequest(), - company=gct_company.Company(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - company_service.DeleteCompanyRequest, - dict, -]) -def test_delete_company(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.DeleteCompanyRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_company_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 = CompanyServiceClient( - 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_company), - '__call__') as call: - client.delete_company() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.DeleteCompanyRequest() - -@pytest.mark.asyncio -async def test_delete_company_async(transport: str = 'grpc_asyncio', request_type=company_service.DeleteCompanyRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.DeleteCompanyRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_company_async_from_dict(): - await test_delete_company_async(request_type=dict) - - -def test_delete_company_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 = company_service.DeleteCompanyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_company), - '__call__') as call: - call.return_value = None - client.delete_company(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_company_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 = company_service.DeleteCompanyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_company), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_company(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_company_flattened(): - 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.delete_company), - '__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_company( - 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_company_flattened_error(): - client = CompanyServiceClient( - 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_company( - company_service.DeleteCompanyRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_company_flattened_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.delete_company), - '__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_company( - 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_company_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_company( - company_service.DeleteCompanyRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - company_service.ListCompaniesRequest, - dict, -]) -def test_list_companies(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_companies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company_service.ListCompaniesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_companies(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.ListCompaniesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCompaniesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_companies_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 = CompanyServiceClient( - 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_companies), - '__call__') as call: - client.list_companies() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.ListCompaniesRequest() - -@pytest.mark.asyncio -async def test_list_companies_async(transport: str = 'grpc_asyncio', request_type=company_service.ListCompaniesRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_companies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_companies(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.ListCompaniesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCompaniesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_companies_async_from_dict(): - await test_list_companies_async(request_type=dict) - - -def test_list_companies_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 = company_service.ListCompaniesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_companies), - '__call__') as call: - call.return_value = company_service.ListCompaniesResponse() - client.list_companies(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_companies_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 = company_service.ListCompaniesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_companies), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse()) - await client.list_companies(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_companies_flattened(): - 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.list_companies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company_service.ListCompaniesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_companies( - 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_companies_flattened_error(): - client = CompanyServiceClient( - 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_companies( - company_service.ListCompaniesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_companies_flattened_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.list_companies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company_service.ListCompaniesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_companies( - 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_companies_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_companies( - company_service.ListCompaniesRequest(), - parent='parent_value', - ) - - -def test_list_companies_pager(transport_name: str = "grpc"): - client = CompanyServiceClient( - 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_companies), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - company.Company(), - ], - next_page_token='abc', - ), - company_service.ListCompaniesResponse( - companies=[], - next_page_token='def', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - ], - next_page_token='ghi', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_companies(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, company.Company) - for i in results) -def test_list_companies_pages(transport_name: str = "grpc"): - client = CompanyServiceClient( - 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_companies), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - company.Company(), - ], - next_page_token='abc', - ), - company_service.ListCompaniesResponse( - companies=[], - next_page_token='def', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - ], - next_page_token='ghi', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - ], - ), - RuntimeError, - ) - pages = list(client.list_companies(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_companies_async_pager(): - 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.list_companies), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - company.Company(), - ], - next_page_token='abc', - ), - company_service.ListCompaniesResponse( - companies=[], - next_page_token='def', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - ], - next_page_token='ghi', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_companies(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, company.Company) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_companies_async_pages(): - 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.list_companies), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - company.Company(), - ], - next_page_token='abc', - ), - company_service.ListCompaniesResponse( - companies=[], - next_page_token='def', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - ], - next_page_token='ghi', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_companies(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.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompanyServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompanyServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CompanyServiceClient( - 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 = CompanyServiceClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompanyServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = CompanyServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.CompanyServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.CompanyServiceGrpcTransport, - transports.CompanyServiceGrpcAsyncIOTransport, -]) -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 = CompanyServiceClient.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 = CompanyServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CompanyServiceGrpcTransport, - ) - -def test_company_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CompanyServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_company_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4.services.company_service.transports.CompanyServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.CompanyServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_company', - 'get_company', - 'update_company', - 'delete_company', - 'list_companies', - ) - 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_company_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_v4.services.company_service.transports.CompanyServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CompanyServiceTransport( - 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_company_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_v4.services.company_service.transports.CompanyServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CompanyServiceTransport() - adc.assert_called_once() - - -def test_company_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) - CompanyServiceClient() - 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.CompanyServiceGrpcTransport, - transports.CompanyServiceGrpcAsyncIOTransport, - ], -) -def test_company_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", - [ - 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", - [ - (transports.CompanyServiceGrpcTransport, grpc_helpers), - (transports.CompanyServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_company_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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) -def test_company_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_company_service_host_no_port(transport_name): - client = CompanyServiceClient( - 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_company_service_host_with_port(transport_name): - client = CompanyServiceClient( - 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_company_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CompanyServiceGrpcTransport( - 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_company_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CompanyServiceGrpcAsyncIOTransport( - 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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) -def test_company_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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) -def test_company_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_company_path(): - project = "squid" - tenant = "clam" - company = "whelk" - expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) - actual = CompanyServiceClient.company_path(project, tenant, company) - assert expected == actual - - -def test_parse_company_path(): - expected = { - "project": "octopus", - "tenant": "oyster", - "company": "nudibranch", - } - path = CompanyServiceClient.company_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.parse_company_path(path) - assert expected == actual - -def test_tenant_path(): - project = "cuttlefish" - tenant = "mussel" - expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) - actual = CompanyServiceClient.tenant_path(project, tenant) - assert expected == actual - - -def test_parse_tenant_path(): - expected = { - "project": "winkle", - "tenant": "nautilus", - } - path = CompanyServiceClient.tenant_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.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 = CompanyServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "abalone", - } - path = CompanyServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "squid" - expected = "folders/{folder}".format(folder=folder, ) - actual = CompanyServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "clam", - } - path = CompanyServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "whelk" - expected = "organizations/{organization}".format(organization=organization, ) - actual = CompanyServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "octopus", - } - path = CompanyServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "oyster" - expected = "projects/{project}".format(project=project, ) - actual = CompanyServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nudibranch", - } - path = CompanyServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.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 = CompanyServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "winkle", - "location": "nautilus", - } - path = CompanyServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.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.CompanyServiceTransport, '_prep_wrapped_messages') as prep: - client = CompanyServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.CompanyServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = CompanyServiceClient.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 = CompanyServiceAsyncClient( - 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 = CompanyServiceClient( - 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 = CompanyServiceClient( - 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", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_completion.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_completion.py deleted file mode 100644 index af11befb..00000000 --- a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_completion.py +++ /dev/null @@ -1,1328 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4.services.completion import CompletionAsyncClient -from google.cloud.talent_v4.services.completion import CompletionClient -from google.cloud.talent_v4.services.completion import transports -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import completion_service -from google.oauth2 import service_account -import google.auth - - -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 CompletionClient._get_default_mtls_endpoint(None) is None - assert CompletionClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert CompletionClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert CompletionClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert CompletionClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert CompletionClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (CompletionClient, "grpc"), - (CompletionAsyncClient, "grpc_asyncio"), -]) -def test_completion_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.CompletionGrpcTransport, "grpc"), - (transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_completion_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", [ - (CompletionClient, "grpc"), - (CompletionAsyncClient, "grpc_asyncio"), -]) -def test_completion_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_completion_client_get_transport_class(): - transport = CompletionClient.get_transport_class() - available_transports = [ - transports.CompletionGrpcTransport, - ] - assert transport in available_transports - - transport = CompletionClient.get_transport_class("grpc") - assert transport == transports.CompletionGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc"), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) -@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) -def test_completion_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(CompletionClient, '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(CompletionClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc", "true"), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (CompletionClient, transports.CompletionGrpcTransport, "grpc", "false"), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) -@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_completion_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - CompletionClient, CompletionAsyncClient -]) -@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) -@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) -def test_completion_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", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc"), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_completion_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc", grpc_helpers), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_completion_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, - api_audience=None, - ) - -def test_completion_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4.services.completion.transports.CompletionGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = CompletionClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc", grpc_helpers), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_completion_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, - api_audience=None, - ) - - # 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", [ - completion_service.CompleteQueryRequest, - dict, -]) -def test_complete_query(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.complete_query), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = completion_service.CompleteQueryResponse( - ) - response = client.complete_query(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == completion_service.CompleteQueryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, completion_service.CompleteQueryResponse) - - -def test_complete_query_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 = CompletionClient( - 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.complete_query), - '__call__') as call: - client.complete_query() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == completion_service.CompleteQueryRequest() - -@pytest.mark.asyncio -async def test_complete_query_async(transport: str = 'grpc_asyncio', request_type=completion_service.CompleteQueryRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.complete_query), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(completion_service.CompleteQueryResponse( - )) - response = await client.complete_query(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == completion_service.CompleteQueryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, completion_service.CompleteQueryResponse) - - -@pytest.mark.asyncio -async def test_complete_query_async_from_dict(): - await test_complete_query_async(request_type=dict) - - -def test_complete_query_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 = completion_service.CompleteQueryRequest() - - request.tenant = 'tenant_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.complete_query), - '__call__') as call: - call.return_value = completion_service.CompleteQueryResponse() - client.complete_query(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', - 'tenant=tenant_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_complete_query_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 = completion_service.CompleteQueryRequest() - - request.tenant = 'tenant_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.complete_query), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(completion_service.CompleteQueryResponse()) - await client.complete_query(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', - 'tenant=tenant_value', - ) in kw['metadata'] - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompletionClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompletionClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CompletionClient( - 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 = CompletionClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompletionClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = CompletionClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.CompletionGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.CompletionGrpcTransport, - transports.CompletionGrpcAsyncIOTransport, -]) -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 = CompletionClient.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 = CompletionClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CompletionGrpcTransport, - ) - -def test_completion_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CompletionTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_completion_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4.services.completion.transports.CompletionTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.CompletionTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'complete_query', - ) - 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_completion_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_v4.services.completion.transports.CompletionTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CompletionTransport( - 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_completion_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_v4.services.completion.transports.CompletionTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CompletionTransport() - adc.assert_called_once() - - -def test_completion_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) - CompletionClient() - 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.CompletionGrpcTransport, - transports.CompletionGrpcAsyncIOTransport, - ], -) -def test_completion_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", - [ - 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", - [ - (transports.CompletionGrpcTransport, grpc_helpers), - (transports.CompletionGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_completion_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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) -def test_completion_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_completion_host_no_port(transport_name): - client = CompletionClient( - 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_completion_host_with_port(transport_name): - client = CompletionClient( - 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_completion_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CompletionGrpcTransport( - 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_completion_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CompletionGrpcAsyncIOTransport( - 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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) -def test_completion_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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) -def test_completion_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_company_path(): - project = "squid" - tenant = "clam" - company = "whelk" - expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) - actual = CompletionClient.company_path(project, tenant, company) - assert expected == actual - - -def test_parse_company_path(): - expected = { - "project": "octopus", - "tenant": "oyster", - "company": "nudibranch", - } - path = CompletionClient.company_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.parse_company_path(path) - assert expected == actual - -def test_tenant_path(): - project = "cuttlefish" - tenant = "mussel" - expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) - actual = CompletionClient.tenant_path(project, tenant) - assert expected == actual - - -def test_parse_tenant_path(): - expected = { - "project": "winkle", - "tenant": "nautilus", - } - path = CompletionClient.tenant_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.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 = CompletionClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "abalone", - } - path = CompletionClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "squid" - expected = "folders/{folder}".format(folder=folder, ) - actual = CompletionClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "clam", - } - path = CompletionClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "whelk" - expected = "organizations/{organization}".format(organization=organization, ) - actual = CompletionClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "octopus", - } - path = CompletionClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "oyster" - expected = "projects/{project}".format(project=project, ) - actual = CompletionClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nudibranch", - } - path = CompletionClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.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 = CompletionClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "winkle", - "location": "nautilus", - } - path = CompletionClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.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.CompletionTransport, '_prep_wrapped_messages') as prep: - client = CompletionClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.CompletionTransport, '_prep_wrapped_messages') as prep: - transport_class = CompletionClient.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 = CompletionAsyncClient( - 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 = CompletionClient( - 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 = CompletionClient( - 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", [ - (CompletionClient, transports.CompletionGrpcTransport), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_event_service.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_event_service.py deleted file mode 100644 index 5ea08b83..00000000 --- a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_event_service.py +++ /dev/null @@ -1,1413 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4.services.event_service import EventServiceAsyncClient -from google.cloud.talent_v4.services.event_service import EventServiceClient -from google.cloud.talent_v4.services.event_service import transports -from google.cloud.talent_v4.types import event -from google.cloud.talent_v4.types import event_service -from google.oauth2 import service_account -from google.protobuf import timestamp_pb2 # type: ignore -import google.auth - - -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 EventServiceClient._get_default_mtls_endpoint(None) is None - assert EventServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert EventServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert EventServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert EventServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert EventServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (EventServiceClient, "grpc"), - (EventServiceAsyncClient, "grpc_asyncio"), -]) -def test_event_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.EventServiceGrpcTransport, "grpc"), - (transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_event_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", [ - (EventServiceClient, "grpc"), - (EventServiceAsyncClient, "grpc_asyncio"), -]) -def test_event_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_event_service_client_get_transport_class(): - transport = EventServiceClient.get_transport_class() - available_transports = [ - transports.EventServiceGrpcTransport, - ] - assert transport in available_transports - - transport = EventServiceClient.get_transport_class("grpc") - assert transport == transports.EventServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc"), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) -@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) -def test_event_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(EventServiceClient, '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(EventServiceClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", "true"), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", "false"), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) -@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_event_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - EventServiceClient, EventServiceAsyncClient -]) -@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) -@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) -def test_event_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", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc"), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_event_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", grpc_helpers), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_event_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, - api_audience=None, - ) - -def test_event_service_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4.services.event_service.transports.EventServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = EventServiceClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", grpc_helpers), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_event_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, - api_audience=None, - ) - - # 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", [ - event_service.CreateClientEventRequest, - dict, -]) -def test_create_client_event(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_client_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = event.ClientEvent( - request_id='request_id_value', - event_id='event_id_value', - event_notes='event_notes_value', - job_event=event.JobEvent(type_=event.JobEvent.JobEventType.IMPRESSION), - ) - response = client.create_client_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == event_service.CreateClientEventRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, event.ClientEvent) - assert response.request_id == 'request_id_value' - assert response.event_id == 'event_id_value' - assert response.event_notes == 'event_notes_value' - - -def test_create_client_event_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 = EventServiceClient( - 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_client_event), - '__call__') as call: - client.create_client_event() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == event_service.CreateClientEventRequest() - -@pytest.mark.asyncio -async def test_create_client_event_async(transport: str = 'grpc_asyncio', request_type=event_service.CreateClientEventRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_client_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent( - request_id='request_id_value', - event_id='event_id_value', - event_notes='event_notes_value', - )) - response = await client.create_client_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == event_service.CreateClientEventRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, event.ClientEvent) - assert response.request_id == 'request_id_value' - assert response.event_id == 'event_id_value' - assert response.event_notes == 'event_notes_value' - - -@pytest.mark.asyncio -async def test_create_client_event_async_from_dict(): - await test_create_client_event_async(request_type=dict) - - -def test_create_client_event_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 = event_service.CreateClientEventRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_client_event), - '__call__') as call: - call.return_value = event.ClientEvent() - client.create_client_event(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_client_event_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 = event_service.CreateClientEventRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_client_event), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) - await client.create_client_event(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_client_event_flattened(): - 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.create_client_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = event.ClientEvent() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_client_event( - parent='parent_value', - client_event=event.ClientEvent(request_id='request_id_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].client_event - mock_val = event.ClientEvent(request_id='request_id_value') - assert arg == mock_val - - -def test_create_client_event_flattened_error(): - client = EventServiceClient( - 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_client_event( - event_service.CreateClientEventRequest(), - parent='parent_value', - client_event=event.ClientEvent(request_id='request_id_value'), - ) - -@pytest.mark.asyncio -async def test_create_client_event_flattened_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.create_client_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = event.ClientEvent() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_client_event( - parent='parent_value', - client_event=event.ClientEvent(request_id='request_id_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].client_event - mock_val = event.ClientEvent(request_id='request_id_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_client_event_flattened_error_async(): - client = EventServiceAsyncClient( - 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_client_event( - event_service.CreateClientEventRequest(), - parent='parent_value', - client_event=event.ClientEvent(request_id='request_id_value'), - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = EventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = EventServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = EventServiceClient( - 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 = EventServiceClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = EventServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = EventServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.EventServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.EventServiceGrpcTransport, - transports.EventServiceGrpcAsyncIOTransport, -]) -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 = EventServiceClient.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 = EventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.EventServiceGrpcTransport, - ) - -def test_event_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.EventServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_event_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4.services.event_service.transports.EventServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.EventServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_client_event', - ) - 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_event_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_v4.services.event_service.transports.EventServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.EventServiceTransport( - 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_event_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_v4.services.event_service.transports.EventServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.EventServiceTransport() - adc.assert_called_once() - - -def test_event_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) - EventServiceClient() - 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.EventServiceGrpcTransport, - transports.EventServiceGrpcAsyncIOTransport, - ], -) -def test_event_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", - [ - 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", - [ - (transports.EventServiceGrpcTransport, grpc_helpers), - (transports.EventServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_event_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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) -def test_event_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_event_service_host_no_port(transport_name): - client = EventServiceClient( - 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_event_service_host_with_port(transport_name): - client = EventServiceClient( - 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_event_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.EventServiceGrpcTransport( - 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_event_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.EventServiceGrpcAsyncIOTransport( - 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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) -def test_event_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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) -def test_event_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_tenant_path(): - project = "squid" - tenant = "clam" - expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) - actual = EventServiceClient.tenant_path(project, tenant) - assert expected == actual - - -def test_parse_tenant_path(): - expected = { - "project": "whelk", - "tenant": "octopus", - } - path = EventServiceClient.tenant_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_tenant_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = EventServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "nudibranch", - } - path = EventServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder, ) - actual = EventServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "mussel", - } - path = EventServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "winkle" - expected = "organizations/{organization}".format(organization=organization, ) - actual = EventServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nautilus", - } - path = EventServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "scallop" - expected = "projects/{project}".format(project=project, ) - actual = EventServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "abalone", - } - path = EventServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "squid" - location = "clam" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = EventServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "whelk", - "location": "octopus", - } - path = EventServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.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.EventServiceTransport, '_prep_wrapped_messages') as prep: - client = EventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.EventServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = EventServiceClient.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 = EventServiceAsyncClient( - 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 = EventServiceClient( - 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 = EventServiceClient( - 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", [ - (EventServiceClient, transports.EventServiceGrpcTransport), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_job_service.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_job_service.py deleted file mode 100644 index fb8b018e..00000000 --- a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_job_service.py +++ /dev/null @@ -1,3895 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation -from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4.services.job_service import JobServiceAsyncClient -from google.cloud.talent_v4.services.job_service import JobServiceClient -from google.cloud.talent_v4.services.job_service import pagers -from google.cloud.talent_v4.services.job_service import transports -from google.cloud.talent_v4.types import common -from google.cloud.talent_v4.types import filters -from google.cloud.talent_v4.types import histogram -from google.cloud.talent_v4.types import job -from google.cloud.talent_v4.types import job as gct_job -from google.cloud.talent_v4.types import job_service -from google.longrunning import operations_pb2 -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 latlng_pb2 # type: ignore -from google.type import money_pb2 # type: ignore -from google.type import postal_address_pb2 # type: ignore -from google.type import timeofday_pb2 # type: ignore -import google.auth - - -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 JobServiceClient._get_default_mtls_endpoint(None) is None - assert JobServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert JobServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert JobServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert JobServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert JobServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (JobServiceClient, "grpc"), - (JobServiceAsyncClient, "grpc_asyncio"), -]) -def test_job_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.JobServiceGrpcTransport, "grpc"), - (transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_job_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", [ - (JobServiceClient, "grpc"), - (JobServiceAsyncClient, "grpc_asyncio"), -]) -def test_job_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_job_service_client_get_transport_class(): - transport = JobServiceClient.get_transport_class() - available_transports = [ - transports.JobServiceGrpcTransport, - ] - assert transport in available_transports - - transport = JobServiceClient.get_transport_class("grpc") - assert transport == transports.JobServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc"), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) -@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) -def test_job_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(JobServiceClient, '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(JobServiceClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", "true"), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", "false"), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) -@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_job_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - JobServiceClient, JobServiceAsyncClient -]) -@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) -@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) -def test_job_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", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc"), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_job_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", grpc_helpers), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_job_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, - api_audience=None, - ) - -def test_job_service_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4.services.job_service.transports.JobServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = JobServiceClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", grpc_helpers), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_job_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, - api_audience=None, - ) - - # 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", [ - job_service.CreateJobRequest, - dict, -]) -def test_create_job(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - ) - response = client.create_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -def test_create_job_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 = JobServiceClient( - 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_job), - '__call__') as call: - client.create_job() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateJobRequest() - -@pytest.mark.asyncio -async def test_create_job_async(transport: str = 'grpc_asyncio', request_type=job_service.CreateJobRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - )) - response = await client.create_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -@pytest.mark.asyncio -async def test_create_job_async_from_dict(): - await test_create_job_async(request_type=dict) - - -def test_create_job_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 = job_service.CreateJobRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_job), - '__call__') as call: - call.return_value = gct_job.Job() - client.create_job(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_job_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 = job_service.CreateJobRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_job), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) - await client.create_job(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_job_flattened(): - 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.create_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_job( - parent='parent_value', - job=gct_job.Job(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].job - mock_val = gct_job.Job(name='name_value') - assert arg == mock_val - - -def test_create_job_flattened_error(): - client = JobServiceClient( - 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_job( - job_service.CreateJobRequest(), - parent='parent_value', - job=gct_job.Job(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_job_flattened_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.create_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_job( - parent='parent_value', - job=gct_job.Job(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].job - mock_val = gct_job.Job(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_job_flattened_error_async(): - client = JobServiceAsyncClient( - 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_job( - job_service.CreateJobRequest(), - parent='parent_value', - job=gct_job.Job(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.BatchCreateJobsRequest, - dict, -]) -def test_batch_create_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.batch_create_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchCreateJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_batch_create_jobs_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 = JobServiceClient( - 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.batch_create_jobs), - '__call__') as call: - client.batch_create_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchCreateJobsRequest() - -@pytest.mark.asyncio -async def test_batch_create_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchCreateJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.batch_create_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchCreateJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_batch_create_jobs_async_from_dict(): - await test_batch_create_jobs_async(request_type=dict) - - -def test_batch_create_jobs_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 = job_service.BatchCreateJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_jobs), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.batch_create_jobs(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_batch_create_jobs_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 = job_service.BatchCreateJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.batch_create_jobs(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_batch_create_jobs_flattened(): - 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.batch_create_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.batch_create_jobs( - parent='parent_value', - jobs=[job.Job(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].jobs - mock_val = [job.Job(name='name_value')] - assert arg == mock_val - - -def test_batch_create_jobs_flattened_error(): - client = JobServiceClient( - 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.batch_create_jobs( - job_service.BatchCreateJobsRequest(), - parent='parent_value', - jobs=[job.Job(name='name_value')], - ) - -@pytest.mark.asyncio -async def test_batch_create_jobs_flattened_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.batch_create_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.batch_create_jobs( - parent='parent_value', - jobs=[job.Job(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].jobs - mock_val = [job.Job(name='name_value')] - assert arg == mock_val - -@pytest.mark.asyncio -async def test_batch_create_jobs_flattened_error_async(): - client = JobServiceAsyncClient( - 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.batch_create_jobs( - job_service.BatchCreateJobsRequest(), - parent='parent_value', - jobs=[job.Job(name='name_value')], - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.GetJobRequest, - dict, -]) -def test_get_job(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - ) - response = client.get_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -def test_get_job_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 = JobServiceClient( - 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_job), - '__call__') as call: - client.get_job() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetJobRequest() - -@pytest.mark.asyncio -async def test_get_job_async(transport: str = 'grpc_asyncio', request_type=job_service.GetJobRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - )) - response = await client.get_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -@pytest.mark.asyncio -async def test_get_job_async_from_dict(): - await test_get_job_async(request_type=dict) - - -def test_get_job_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 = job_service.GetJobRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_job), - '__call__') as call: - call.return_value = job.Job() - client.get_job(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_job_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 = job_service.GetJobRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_job), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) - await client.get_job(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_job_flattened(): - 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_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job.Job() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_job( - 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_job_flattened_error(): - client = JobServiceClient( - 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_job( - job_service.GetJobRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_job_flattened_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_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job.Job() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_job( - 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_job_flattened_error_async(): - client = JobServiceAsyncClient( - 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_job( - job_service.GetJobRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.UpdateJobRequest, - dict, -]) -def test_update_job(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - ) - response = client.update_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.UpdateJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -def test_update_job_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 = JobServiceClient( - 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_job), - '__call__') as call: - client.update_job() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.UpdateJobRequest() - -@pytest.mark.asyncio -async def test_update_job_async(transport: str = 'grpc_asyncio', request_type=job_service.UpdateJobRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - )) - response = await client.update_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.UpdateJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -@pytest.mark.asyncio -async def test_update_job_async_from_dict(): - await test_update_job_async(request_type=dict) - - -def test_update_job_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 = job_service.UpdateJobRequest() - - request.job.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_job), - '__call__') as call: - call.return_value = gct_job.Job() - client.update_job(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', - 'job.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_job_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 = job_service.UpdateJobRequest() - - request.job.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_job), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) - await client.update_job(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', - 'job.name=name_value', - ) in kw['metadata'] - - -def test_update_job_flattened(): - 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.update_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_job( - job=gct_job.Job(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_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].job - mock_val = gct_job.Job(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_job_flattened_error(): - client = JobServiceClient( - 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_job( - job_service.UpdateJobRequest(), - job=gct_job.Job(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_job_flattened_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.update_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_job( - job=gct_job.Job(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_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].job - mock_val = gct_job.Job(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_job_flattened_error_async(): - client = JobServiceAsyncClient( - 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_job( - job_service.UpdateJobRequest(), - job=gct_job.Job(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.BatchUpdateJobsRequest, - dict, -]) -def test_batch_update_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.batch_update_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchUpdateJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_batch_update_jobs_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 = JobServiceClient( - 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.batch_update_jobs), - '__call__') as call: - client.batch_update_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchUpdateJobsRequest() - -@pytest.mark.asyncio -async def test_batch_update_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchUpdateJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.batch_update_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchUpdateJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_batch_update_jobs_async_from_dict(): - await test_batch_update_jobs_async(request_type=dict) - - -def test_batch_update_jobs_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 = job_service.BatchUpdateJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_jobs), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.batch_update_jobs(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_batch_update_jobs_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 = job_service.BatchUpdateJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.batch_update_jobs(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_batch_update_jobs_flattened(): - 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.batch_update_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.batch_update_jobs( - parent='parent_value', - jobs=[job.Job(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].jobs - mock_val = [job.Job(name='name_value')] - assert arg == mock_val - - -def test_batch_update_jobs_flattened_error(): - client = JobServiceClient( - 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.batch_update_jobs( - job_service.BatchUpdateJobsRequest(), - parent='parent_value', - jobs=[job.Job(name='name_value')], - ) - -@pytest.mark.asyncio -async def test_batch_update_jobs_flattened_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.batch_update_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.batch_update_jobs( - parent='parent_value', - jobs=[job.Job(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].jobs - mock_val = [job.Job(name='name_value')] - assert arg == mock_val - -@pytest.mark.asyncio -async def test_batch_update_jobs_flattened_error_async(): - client = JobServiceAsyncClient( - 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.batch_update_jobs( - job_service.BatchUpdateJobsRequest(), - parent='parent_value', - jobs=[job.Job(name='name_value')], - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.DeleteJobRequest, - dict, -]) -def test_delete_job(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteJobRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_job_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 = JobServiceClient( - 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_job), - '__call__') as call: - client.delete_job() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteJobRequest() - -@pytest.mark.asyncio -async def test_delete_job_async(transport: str = 'grpc_asyncio', request_type=job_service.DeleteJobRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteJobRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_job_async_from_dict(): - await test_delete_job_async(request_type=dict) - - -def test_delete_job_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 = job_service.DeleteJobRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_job), - '__call__') as call: - call.return_value = None - client.delete_job(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_job_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 = job_service.DeleteJobRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_job), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_job(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_job_flattened(): - 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.delete_job), - '__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_job( - 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_job_flattened_error(): - client = JobServiceClient( - 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_job( - job_service.DeleteJobRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_job_flattened_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.delete_job), - '__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_job( - 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_job_flattened_error_async(): - client = JobServiceAsyncClient( - 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_job( - job_service.DeleteJobRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.BatchDeleteJobsRequest, - dict, -]) -def test_batch_delete_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.batch_delete_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchDeleteJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_batch_delete_jobs_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 = JobServiceClient( - 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.batch_delete_jobs), - '__call__') as call: - client.batch_delete_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchDeleteJobsRequest() - -@pytest.mark.asyncio -async def test_batch_delete_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchDeleteJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.batch_delete_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchDeleteJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_batch_delete_jobs_async_from_dict(): - await test_batch_delete_jobs_async(request_type=dict) - - -def test_batch_delete_jobs_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 = job_service.BatchDeleteJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_jobs), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.batch_delete_jobs(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_batch_delete_jobs_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 = job_service.BatchDeleteJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.batch_delete_jobs(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_batch_delete_jobs_flattened(): - 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.batch_delete_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.batch_delete_jobs( - parent='parent_value', - names=['names_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].names - mock_val = ['names_value'] - assert arg == mock_val - - -def test_batch_delete_jobs_flattened_error(): - client = JobServiceClient( - 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.batch_delete_jobs( - job_service.BatchDeleteJobsRequest(), - parent='parent_value', - names=['names_value'], - ) - -@pytest.mark.asyncio -async def test_batch_delete_jobs_flattened_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.batch_delete_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.batch_delete_jobs( - parent='parent_value', - names=['names_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].names - mock_val = ['names_value'] - assert arg == mock_val - -@pytest.mark.asyncio -async def test_batch_delete_jobs_flattened_error_async(): - client = JobServiceAsyncClient( - 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.batch_delete_jobs( - job_service.BatchDeleteJobsRequest(), - parent='parent_value', - names=['names_value'], - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.ListJobsRequest, - dict, -]) -def test_list_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.ListJobsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListJobsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_jobs_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 = JobServiceClient( - 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_jobs), - '__call__') as call: - client.list_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListJobsRequest() - -@pytest.mark.asyncio -async def test_list_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.ListJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListJobsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_jobs_async_from_dict(): - await test_list_jobs_async(request_type=dict) - - -def test_list_jobs_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 = job_service.ListJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_jobs), - '__call__') as call: - call.return_value = job_service.ListJobsResponse() - client.list_jobs(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_jobs_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 = job_service.ListJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse()) - await client.list_jobs(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_jobs_flattened(): - 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.list_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.ListJobsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_jobs( - parent='parent_value', - filter='filter_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].filter - mock_val = 'filter_value' - assert arg == mock_val - - -def test_list_jobs_flattened_error(): - client = JobServiceClient( - 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_jobs( - job_service.ListJobsRequest(), - parent='parent_value', - filter='filter_value', - ) - -@pytest.mark.asyncio -async def test_list_jobs_flattened_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.list_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.ListJobsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_jobs( - parent='parent_value', - filter='filter_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].filter - mock_val = 'filter_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_jobs_flattened_error_async(): - client = JobServiceAsyncClient( - 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_jobs( - job_service.ListJobsRequest(), - parent='parent_value', - filter='filter_value', - ) - - -def test_list_jobs_pager(transport_name: str = "grpc"): - client = JobServiceClient( - 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_jobs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - job.Job(), - ], - next_page_token='abc', - ), - job_service.ListJobsResponse( - jobs=[], - next_page_token='def', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - ], - next_page_token='ghi', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_jobs(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, job.Job) - for i in results) -def test_list_jobs_pages(transport_name: str = "grpc"): - client = JobServiceClient( - 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_jobs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - job.Job(), - ], - next_page_token='abc', - ), - job_service.ListJobsResponse( - jobs=[], - next_page_token='def', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - ], - next_page_token='ghi', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - ], - ), - RuntimeError, - ) - pages = list(client.list_jobs(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_jobs_async_pager(): - 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.list_jobs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - job.Job(), - ], - next_page_token='abc', - ), - job_service.ListJobsResponse( - jobs=[], - next_page_token='def', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - ], - next_page_token='ghi', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_jobs(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, job.Job) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_jobs_async_pages(): - 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.list_jobs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - job.Job(), - ], - next_page_token='abc', - ), - job_service.ListJobsResponse( - jobs=[], - next_page_token='def', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - ], - next_page_token='ghi', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_jobs(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", [ - job_service.SearchJobsRequest, - dict, -]) -def test_search_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.SearchJobsResponse( - next_page_token='next_page_token_value', - total_size=1086, - broadened_query_jobs_count=2766, - ) - response = client.search_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - - # Establish that the response is the type that we expect. - assert response.raw_page is response - assert isinstance(response, job_service.SearchJobsResponse) - assert response.next_page_token == 'next_page_token_value' - assert response.total_size == 1086 - assert response.broadened_query_jobs_count == 2766 - - -def test_search_jobs_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 = JobServiceClient( - 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_jobs), - '__call__') as call: - client.search_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - -@pytest.mark.asyncio -async def test_search_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.SearchJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse( - next_page_token='next_page_token_value', - total_size=1086, - broadened_query_jobs_count=2766, - )) - response = await client.search_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, job_service.SearchJobsResponse) - assert response.next_page_token == 'next_page_token_value' - assert response.total_size == 1086 - assert response.broadened_query_jobs_count == 2766 - - -@pytest.mark.asyncio -async def test_search_jobs_async_from_dict(): - await test_search_jobs_async(request_type=dict) - - -def test_search_jobs_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 = job_service.SearchJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs), - '__call__') as call: - call.return_value = job_service.SearchJobsResponse() - client.search_jobs(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_jobs_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 = job_service.SearchJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse()) - await client.search_jobs(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'] - - -@pytest.mark.parametrize("request_type", [ - job_service.SearchJobsRequest, - dict, -]) -def test_search_jobs_for_alert(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs_for_alert), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.SearchJobsResponse( - next_page_token='next_page_token_value', - total_size=1086, - broadened_query_jobs_count=2766, - ) - response = client.search_jobs_for_alert(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - - # Establish that the response is the type that we expect. - assert response.raw_page is response - assert isinstance(response, job_service.SearchJobsResponse) - assert response.next_page_token == 'next_page_token_value' - assert response.total_size == 1086 - assert response.broadened_query_jobs_count == 2766 - - -def test_search_jobs_for_alert_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 = JobServiceClient( - 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_jobs_for_alert), - '__call__') as call: - client.search_jobs_for_alert() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - -@pytest.mark.asyncio -async def test_search_jobs_for_alert_async(transport: str = 'grpc_asyncio', request_type=job_service.SearchJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs_for_alert), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse( - next_page_token='next_page_token_value', - total_size=1086, - broadened_query_jobs_count=2766, - )) - response = await client.search_jobs_for_alert(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, job_service.SearchJobsResponse) - assert response.next_page_token == 'next_page_token_value' - assert response.total_size == 1086 - assert response.broadened_query_jobs_count == 2766 - - -@pytest.mark.asyncio -async def test_search_jobs_for_alert_async_from_dict(): - await test_search_jobs_for_alert_async(request_type=dict) - - -def test_search_jobs_for_alert_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 = job_service.SearchJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs_for_alert), - '__call__') as call: - call.return_value = job_service.SearchJobsResponse() - client.search_jobs_for_alert(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_jobs_for_alert_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 = job_service.SearchJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs_for_alert), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse()) - await client.search_jobs_for_alert(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_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = JobServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = JobServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = JobServiceClient( - 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 = JobServiceClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = JobServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = JobServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.JobServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.JobServiceGrpcTransport, - transports.JobServiceGrpcAsyncIOTransport, -]) -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 = JobServiceClient.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 = JobServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.JobServiceGrpcTransport, - ) - -def test_job_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.JobServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_job_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4.services.job_service.transports.JobServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.JobServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_job', - 'batch_create_jobs', - 'get_job', - 'update_job', - 'batch_update_jobs', - 'delete_job', - 'batch_delete_jobs', - 'list_jobs', - 'search_jobs', - 'search_jobs_for_alert', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - # Catch all for all remaining methods and properties - remainder = [ - 'kind', - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_job_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_v4.services.job_service.transports.JobServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.JobServiceTransport( - 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_job_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_v4.services.job_service.transports.JobServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.JobServiceTransport() - adc.assert_called_once() - - -def test_job_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) - JobServiceClient() - 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.JobServiceGrpcTransport, - transports.JobServiceGrpcAsyncIOTransport, - ], -) -def test_job_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", - [ - 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", - [ - (transports.JobServiceGrpcTransport, grpc_helpers), - (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_job_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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) -def test_job_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_job_service_host_no_port(transport_name): - client = JobServiceClient( - 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_job_service_host_with_port(transport_name): - client = JobServiceClient( - 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_job_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.JobServiceGrpcTransport( - 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_job_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.JobServiceGrpcAsyncIOTransport( - 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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) -def test_job_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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) -def test_job_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_job_service_grpc_lro_client(): - client = JobServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_job_service_grpc_lro_async_client(): - client = JobServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_company_path(): - project = "squid" - tenant = "clam" - company = "whelk" - expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) - actual = JobServiceClient.company_path(project, tenant, company) - assert expected == actual - - -def test_parse_company_path(): - expected = { - "project": "octopus", - "tenant": "oyster", - "company": "nudibranch", - } - path = JobServiceClient.company_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_company_path(path) - assert expected == actual - -def test_job_path(): - project = "cuttlefish" - tenant = "mussel" - job = "winkle" - expected = "projects/{project}/tenants/{tenant}/jobs/{job}".format(project=project, tenant=tenant, job=job, ) - actual = JobServiceClient.job_path(project, tenant, job) - assert expected == actual - - -def test_parse_job_path(): - expected = { - "project": "nautilus", - "tenant": "scallop", - "job": "abalone", - } - path = JobServiceClient.job_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_job_path(path) - assert expected == actual - -def test_tenant_path(): - project = "squid" - tenant = "clam" - expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) - actual = JobServiceClient.tenant_path(project, tenant) - assert expected == actual - - -def test_parse_tenant_path(): - expected = { - "project": "whelk", - "tenant": "octopus", - } - path = JobServiceClient.tenant_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_tenant_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = JobServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "nudibranch", - } - path = JobServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder, ) - actual = JobServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "mussel", - } - path = JobServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "winkle" - expected = "organizations/{organization}".format(organization=organization, ) - actual = JobServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nautilus", - } - path = JobServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "scallop" - expected = "projects/{project}".format(project=project, ) - actual = JobServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "abalone", - } - path = JobServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "squid" - location = "clam" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = JobServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "whelk", - "location": "octopus", - } - path = JobServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.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.JobServiceTransport, '_prep_wrapped_messages') as prep: - client = JobServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.JobServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = JobServiceClient.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 = JobServiceAsyncClient( - 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 = JobServiceClient( - 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 = JobServiceClient( - 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", [ - (JobServiceClient, transports.JobServiceGrpcTransport), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_tenant_service.py b/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_tenant_service.py deleted file mode 100644 index e2d7945c..00000000 --- a/owl-bot-staging/v4/tests/unit/gapic/talent_v4/test_tenant_service.py +++ /dev/null @@ -1,2543 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4.services.tenant_service import TenantServiceAsyncClient -from google.cloud.talent_v4.services.tenant_service import TenantServiceClient -from google.cloud.talent_v4.services.tenant_service import pagers -from google.cloud.talent_v4.services.tenant_service import transports -from google.cloud.talent_v4.types import tenant -from google.cloud.talent_v4.types import tenant as gct_tenant -from google.cloud.talent_v4.types import tenant_service -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -import google.auth - - -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 TenantServiceClient._get_default_mtls_endpoint(None) is None - assert TenantServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert TenantServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert TenantServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert TenantServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert TenantServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (TenantServiceClient, "grpc"), - (TenantServiceAsyncClient, "grpc_asyncio"), -]) -def test_tenant_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.TenantServiceGrpcTransport, "grpc"), - (transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_tenant_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", [ - (TenantServiceClient, "grpc"), - (TenantServiceAsyncClient, "grpc_asyncio"), -]) -def test_tenant_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_tenant_service_client_get_transport_class(): - transport = TenantServiceClient.get_transport_class() - available_transports = [ - transports.TenantServiceGrpcTransport, - ] - assert transport in available_transports - - transport = TenantServiceClient.get_transport_class("grpc") - assert transport == transports.TenantServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc"), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) -@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) -def test_tenant_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(TenantServiceClient, '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(TenantServiceClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", "true"), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", "false"), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) -@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_tenant_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - TenantServiceClient, TenantServiceAsyncClient -]) -@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) -@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) -def test_tenant_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", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc"), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_tenant_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", grpc_helpers), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_tenant_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, - api_audience=None, - ) - -def test_tenant_service_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4.services.tenant_service.transports.TenantServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = TenantServiceClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", grpc_helpers), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_tenant_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, - api_audience=None, - ) - - # 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", [ - tenant_service.CreateTenantRequest, - dict, -]) -def test_create_tenant(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant( - name='name_value', - external_id='external_id_value', - ) - response = client.create_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.CreateTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - - -def test_create_tenant_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 = TenantServiceClient( - 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_tenant), - '__call__') as call: - client.create_tenant() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.CreateTenantRequest() - -@pytest.mark.asyncio -async def test_create_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.CreateTenantRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant( - name='name_value', - external_id='external_id_value', - )) - response = await client.create_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.CreateTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - - -@pytest.mark.asyncio -async def test_create_tenant_async_from_dict(): - await test_create_tenant_async(request_type=dict) - - -def test_create_tenant_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 = tenant_service.CreateTenantRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tenant), - '__call__') as call: - call.return_value = gct_tenant.Tenant() - client.create_tenant(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_tenant_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 = tenant_service.CreateTenantRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tenant), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) - await client.create_tenant(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_tenant_flattened(): - 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.create_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_tenant( - parent='parent_value', - tenant=gct_tenant.Tenant(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].tenant - mock_val = gct_tenant.Tenant(name='name_value') - assert arg == mock_val - - -def test_create_tenant_flattened_error(): - client = TenantServiceClient( - 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_tenant( - tenant_service.CreateTenantRequest(), - parent='parent_value', - tenant=gct_tenant.Tenant(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_tenant_flattened_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.create_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_tenant( - parent='parent_value', - tenant=gct_tenant.Tenant(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].tenant - mock_val = gct_tenant.Tenant(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_tenant_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenant( - tenant_service.CreateTenantRequest(), - parent='parent_value', - tenant=gct_tenant.Tenant(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - tenant_service.GetTenantRequest, - dict, -]) -def test_get_tenant(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant.Tenant( - name='name_value', - external_id='external_id_value', - ) - response = client.get_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.GetTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - - -def test_get_tenant_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 = TenantServiceClient( - 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_tenant), - '__call__') as call: - client.get_tenant() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.GetTenantRequest() - -@pytest.mark.asyncio -async def test_get_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.GetTenantRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant( - name='name_value', - external_id='external_id_value', - )) - response = await client.get_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.GetTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - - -@pytest.mark.asyncio -async def test_get_tenant_async_from_dict(): - await test_get_tenant_async(request_type=dict) - - -def test_get_tenant_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 = tenant_service.GetTenantRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tenant), - '__call__') as call: - call.return_value = tenant.Tenant() - client.get_tenant(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_tenant_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 = tenant_service.GetTenantRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tenant), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) - await client.get_tenant(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_tenant_flattened(): - 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_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant.Tenant() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_tenant( - 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_tenant_flattened_error(): - client = TenantServiceClient( - 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_tenant( - tenant_service.GetTenantRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_tenant_flattened_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_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant.Tenant() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_tenant( - 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_tenant_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenant( - tenant_service.GetTenantRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - tenant_service.UpdateTenantRequest, - dict, -]) -def test_update_tenant(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant( - name='name_value', - external_id='external_id_value', - ) - response = client.update_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.UpdateTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - - -def test_update_tenant_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 = TenantServiceClient( - 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_tenant), - '__call__') as call: - client.update_tenant() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.UpdateTenantRequest() - -@pytest.mark.asyncio -async def test_update_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.UpdateTenantRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant( - name='name_value', - external_id='external_id_value', - )) - response = await client.update_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.UpdateTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - - -@pytest.mark.asyncio -async def test_update_tenant_async_from_dict(): - await test_update_tenant_async(request_type=dict) - - -def test_update_tenant_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 = tenant_service.UpdateTenantRequest() - - request.tenant.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tenant), - '__call__') as call: - call.return_value = gct_tenant.Tenant() - client.update_tenant(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', - 'tenant.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_tenant_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 = tenant_service.UpdateTenantRequest() - - request.tenant.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tenant), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) - await client.update_tenant(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', - 'tenant.name=name_value', - ) in kw['metadata'] - - -def test_update_tenant_flattened(): - 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.update_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_tenant( - tenant=gct_tenant.Tenant(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_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].tenant - mock_val = gct_tenant.Tenant(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_tenant_flattened_error(): - client = TenantServiceClient( - 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_tenant( - tenant_service.UpdateTenantRequest(), - tenant=gct_tenant.Tenant(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_tenant_flattened_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.update_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_tenant( - tenant=gct_tenant.Tenant(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_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].tenant - mock_val = gct_tenant.Tenant(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_tenant_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenant( - tenant_service.UpdateTenantRequest(), - tenant=gct_tenant.Tenant(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - tenant_service.DeleteTenantRequest, - dict, -]) -def test_delete_tenant(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.DeleteTenantRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_tenant_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 = TenantServiceClient( - 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_tenant), - '__call__') as call: - client.delete_tenant() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.DeleteTenantRequest() - -@pytest.mark.asyncio -async def test_delete_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.DeleteTenantRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.DeleteTenantRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_tenant_async_from_dict(): - await test_delete_tenant_async(request_type=dict) - - -def test_delete_tenant_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 = tenant_service.DeleteTenantRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tenant), - '__call__') as call: - call.return_value = None - client.delete_tenant(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_tenant_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 = tenant_service.DeleteTenantRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tenant), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_tenant(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_tenant_flattened(): - 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.delete_tenant), - '__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_tenant( - 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_tenant_flattened_error(): - client = TenantServiceClient( - 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_tenant( - tenant_service.DeleteTenantRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_tenant_flattened_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.delete_tenant), - '__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_tenant( - 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_tenant_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenant( - tenant_service.DeleteTenantRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - tenant_service.ListTenantsRequest, - dict, -]) -def test_list_tenants(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tenants), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant_service.ListTenantsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_tenants(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.ListTenantsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTenantsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_tenants_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 = TenantServiceClient( - 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_tenants), - '__call__') as call: - client.list_tenants() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.ListTenantsRequest() - -@pytest.mark.asyncio -async def test_list_tenants_async(transport: str = 'grpc_asyncio', request_type=tenant_service.ListTenantsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tenants), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_tenants(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.ListTenantsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTenantsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_tenants_async_from_dict(): - await test_list_tenants_async(request_type=dict) - - -def test_list_tenants_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 = tenant_service.ListTenantsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tenants), - '__call__') as call: - call.return_value = tenant_service.ListTenantsResponse() - client.list_tenants(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_tenants_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 = tenant_service.ListTenantsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tenants), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse()) - await client.list_tenants(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_tenants_flattened(): - 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.list_tenants), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant_service.ListTenantsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_tenants( - 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_tenants_flattened_error(): - client = TenantServiceClient( - 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_tenants( - tenant_service.ListTenantsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_tenants_flattened_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.list_tenants), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant_service.ListTenantsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_tenants( - 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_tenants_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenants( - tenant_service.ListTenantsRequest(), - parent='parent_value', - ) - - -def test_list_tenants_pager(transport_name: str = "grpc"): - client = TenantServiceClient( - 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_tenants), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - tenant.Tenant(), - ], - next_page_token='abc', - ), - tenant_service.ListTenantsResponse( - tenants=[], - next_page_token='def', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - ], - next_page_token='ghi', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_tenants(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, tenant.Tenant) - for i in results) -def test_list_tenants_pages(transport_name: str = "grpc"): - client = TenantServiceClient( - 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_tenants), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - tenant.Tenant(), - ], - next_page_token='abc', - ), - tenant_service.ListTenantsResponse( - tenants=[], - next_page_token='def', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - ], - next_page_token='ghi', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - ], - ), - RuntimeError, - ) - pages = list(client.list_tenants(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_tenants_async_pager(): - 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.list_tenants), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - tenant.Tenant(), - ], - next_page_token='abc', - ), - tenant_service.ListTenantsResponse( - tenants=[], - next_page_token='def', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - ], - next_page_token='ghi', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_tenants(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, tenant.Tenant) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_tenants_async_pages(): - 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.list_tenants), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - tenant.Tenant(), - ], - next_page_token='abc', - ), - tenant_service.ListTenantsResponse( - tenants=[], - next_page_token='def', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - ], - next_page_token='ghi', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_tenants(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.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = TenantServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = TenantServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = TenantServiceClient( - 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 = TenantServiceClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = TenantServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = TenantServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.TenantServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.TenantServiceGrpcTransport, - transports.TenantServiceGrpcAsyncIOTransport, -]) -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 = TenantServiceClient.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 = TenantServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.TenantServiceGrpcTransport, - ) - -def test_tenant_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.TenantServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_tenant_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4.services.tenant_service.transports.TenantServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.TenantServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_tenant', - 'get_tenant', - 'update_tenant', - 'delete_tenant', - 'list_tenants', - ) - 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_tenant_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_v4.services.tenant_service.transports.TenantServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.TenantServiceTransport( - 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_tenant_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_v4.services.tenant_service.transports.TenantServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.TenantServiceTransport() - adc.assert_called_once() - - -def test_tenant_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) - TenantServiceClient() - 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.TenantServiceGrpcTransport, - transports.TenantServiceGrpcAsyncIOTransport, - ], -) -def test_tenant_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", - [ - 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", - [ - (transports.TenantServiceGrpcTransport, grpc_helpers), - (transports.TenantServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_tenant_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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) -def test_tenant_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_tenant_service_host_no_port(transport_name): - client = TenantServiceClient( - 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_tenant_service_host_with_port(transport_name): - client = TenantServiceClient( - 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_tenant_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.TenantServiceGrpcTransport( - 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_tenant_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.TenantServiceGrpcAsyncIOTransport( - 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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) -def test_tenant_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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) -def test_tenant_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_tenant_path(): - project = "squid" - tenant = "clam" - expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) - actual = TenantServiceClient.tenant_path(project, tenant) - assert expected == actual - - -def test_parse_tenant_path(): - expected = { - "project": "whelk", - "tenant": "octopus", - } - path = TenantServiceClient.tenant_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_tenant_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = TenantServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "nudibranch", - } - path = TenantServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder, ) - actual = TenantServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "mussel", - } - path = TenantServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "winkle" - expected = "organizations/{organization}".format(organization=organization, ) - actual = TenantServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nautilus", - } - path = TenantServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "scallop" - expected = "projects/{project}".format(project=project, ) - actual = TenantServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "abalone", - } - path = TenantServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "squid" - location = "clam" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = TenantServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "whelk", - "location": "octopus", - } - path = TenantServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.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.TenantServiceTransport, '_prep_wrapped_messages') as prep: - client = TenantServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.TenantServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = TenantServiceClient.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 = TenantServiceAsyncClient( - 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 = TenantServiceClient( - 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 = TenantServiceClient( - 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", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/owl-bot-staging/v4beta1/.coveragerc b/owl-bot-staging/v4beta1/.coveragerc deleted file mode 100644 index 4ad22152..00000000 --- a/owl-bot-staging/v4beta1/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/talent/__init__.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v4beta1/.flake8 b/owl-bot-staging/v4beta1/.flake8 deleted file mode 100644 index 29227d4c..00000000 --- a/owl-bot-staging/v4beta1/.flake8 +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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 by synthtool. DO NOT EDIT! -[flake8] -ignore = E203, E266, E501, W503 -exclude = - # Exclude generated code. - **/proto/** - **/gapic/** - **/services/** - **/types/** - *_pb2.py - - # Standard linting exemptions. - **/.nox/** - __pycache__, - .git, - *.pyc, - conf.py diff --git a/owl-bot-staging/v4beta1/MANIFEST.in b/owl-bot-staging/v4beta1/MANIFEST.in deleted file mode 100644 index 2dd6511d..00000000 --- a/owl-bot-staging/v4beta1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/talent *.py -recursive-include google/cloud/talent_v4beta1 *.py diff --git a/owl-bot-staging/v4beta1/README.rst b/owl-bot-staging/v4beta1/README.rst deleted file mode 100644 index 97bb9aff..00000000 --- a/owl-bot-staging/v4beta1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Talent API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Talent API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v4beta1/docs/conf.py b/owl-bot-staging/v4beta1/docs/conf.py deleted file mode 100644 index 3dd2f845..00000000 --- a/owl-bot-staging/v4beta1/docs/conf.py +++ /dev/null @@ -1,376 +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. -# -# -# google-cloud-talent documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "4.0.1" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The root toctree document. -root_doc = "index" - -# General information about the project. -project = u"google-cloud-talent" -copyright = u"2022, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-talent-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - root_doc, - "google-cloud-talent.tex", - u"google-cloud-talent Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - root_doc, - "google-cloud-talent", - u"Google Cloud Talent Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - root_doc, - "google-cloud-talent", - u"google-cloud-talent Documentation", - author, - "google-cloud-talent", - "GAPIC library for Google Cloud Talent API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/v4beta1/docs/index.rst b/owl-bot-staging/v4beta1/docs/index.rst deleted file mode 100644 index 67a267d0..00000000 --- a/owl-bot-staging/v4beta1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - talent_v4beta1/services - talent_v4beta1/types diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/company_service.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/company_service.rst deleted file mode 100644 index b77843f6..00000000 --- a/owl-bot-staging/v4beta1/docs/talent_v4beta1/company_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -CompanyService --------------------------------- - -.. automodule:: google.cloud.talent_v4beta1.services.company_service - :members: - :inherited-members: - -.. automodule:: google.cloud.talent_v4beta1.services.company_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/completion.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/completion.rst deleted file mode 100644 index 764a23f3..00000000 --- a/owl-bot-staging/v4beta1/docs/talent_v4beta1/completion.rst +++ /dev/null @@ -1,6 +0,0 @@ -Completion ----------------------------- - -.. automodule:: google.cloud.talent_v4beta1.services.completion - :members: - :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/event_service.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/event_service.rst deleted file mode 100644 index 8e489d4c..00000000 --- a/owl-bot-staging/v4beta1/docs/talent_v4beta1/event_service.rst +++ /dev/null @@ -1,6 +0,0 @@ -EventService ------------------------------- - -.. automodule:: google.cloud.talent_v4beta1.services.event_service - :members: - :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/job_service.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/job_service.rst deleted file mode 100644 index 605042c2..00000000 --- a/owl-bot-staging/v4beta1/docs/talent_v4beta1/job_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -JobService ----------------------------- - -.. automodule:: google.cloud.talent_v4beta1.services.job_service - :members: - :inherited-members: - -.. automodule:: google.cloud.talent_v4beta1.services.job_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/services.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/services.rst deleted file mode 100644 index f7b55d45..00000000 --- a/owl-bot-staging/v4beta1/docs/talent_v4beta1/services.rst +++ /dev/null @@ -1,10 +0,0 @@ -Services for Google Cloud Talent v4beta1 API -============================================ -.. toctree:: - :maxdepth: 2 - - company_service - completion - event_service - job_service - tenant_service diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/tenant_service.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/tenant_service.rst deleted file mode 100644 index cc5630b3..00000000 --- a/owl-bot-staging/v4beta1/docs/talent_v4beta1/tenant_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -TenantService -------------------------------- - -.. automodule:: google.cloud.talent_v4beta1.services.tenant_service - :members: - :inherited-members: - -.. automodule:: google.cloud.talent_v4beta1.services.tenant_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v4beta1/docs/talent_v4beta1/types.rst b/owl-bot-staging/v4beta1/docs/talent_v4beta1/types.rst deleted file mode 100644 index e6abbcac..00000000 --- a/owl-bot-staging/v4beta1/docs/talent_v4beta1/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Talent v4beta1 API -========================================= - -.. automodule:: google.cloud.talent_v4beta1.types - :members: - :undoc-members: - :show-inheritance: diff --git a/owl-bot-staging/v4beta1/google/cloud/talent/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent/__init__.py deleted file mode 100644 index babd23c7..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent/__init__.py +++ /dev/null @@ -1,155 +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.cloud.talent_v4beta1.services.company_service.client import CompanyServiceClient -from google.cloud.talent_v4beta1.services.company_service.async_client import CompanyServiceAsyncClient -from google.cloud.talent_v4beta1.services.completion.client import CompletionClient -from google.cloud.talent_v4beta1.services.completion.async_client import CompletionAsyncClient -from google.cloud.talent_v4beta1.services.event_service.client import EventServiceClient -from google.cloud.talent_v4beta1.services.event_service.async_client import EventServiceAsyncClient -from google.cloud.talent_v4beta1.services.job_service.client import JobServiceClient -from google.cloud.talent_v4beta1.services.job_service.async_client import JobServiceAsyncClient -from google.cloud.talent_v4beta1.services.tenant_service.client import TenantServiceClient -from google.cloud.talent_v4beta1.services.tenant_service.async_client import TenantServiceAsyncClient - -from google.cloud.talent_v4beta1.types.common import BatchOperationMetadata -from google.cloud.talent_v4beta1.types.common import CompensationInfo -from google.cloud.talent_v4beta1.types.common import CustomAttribute -from google.cloud.talent_v4beta1.types.common import DeviceInfo -from google.cloud.talent_v4beta1.types.common import Location -from google.cloud.talent_v4beta1.types.common import RequestMetadata -from google.cloud.talent_v4beta1.types.common import ResponseMetadata -from google.cloud.talent_v4beta1.types.common import SpellingCorrection -from google.cloud.talent_v4beta1.types.common import TimestampRange -from google.cloud.talent_v4beta1.types.common import CommuteMethod -from google.cloud.talent_v4beta1.types.common import CompanySize -from google.cloud.talent_v4beta1.types.common import DegreeType -from google.cloud.talent_v4beta1.types.common import EmploymentType -from google.cloud.talent_v4beta1.types.common import HtmlSanitization -from google.cloud.talent_v4beta1.types.common import JobBenefit -from google.cloud.talent_v4beta1.types.common import JobCategory -from google.cloud.talent_v4beta1.types.common import JobLevel -from google.cloud.talent_v4beta1.types.common import PostingRegion -from google.cloud.talent_v4beta1.types.common import Visibility -from google.cloud.talent_v4beta1.types.company import Company -from google.cloud.talent_v4beta1.types.company_service import CreateCompanyRequest -from google.cloud.talent_v4beta1.types.company_service import DeleteCompanyRequest -from google.cloud.talent_v4beta1.types.company_service import GetCompanyRequest -from google.cloud.talent_v4beta1.types.company_service import ListCompaniesRequest -from google.cloud.talent_v4beta1.types.company_service import ListCompaniesResponse -from google.cloud.talent_v4beta1.types.company_service import UpdateCompanyRequest -from google.cloud.talent_v4beta1.types.completion_service import CompleteQueryRequest -from google.cloud.talent_v4beta1.types.completion_service import CompleteQueryResponse -from google.cloud.talent_v4beta1.types.event import ClientEvent -from google.cloud.talent_v4beta1.types.event import JobEvent -from google.cloud.talent_v4beta1.types.event_service import CreateClientEventRequest -from google.cloud.talent_v4beta1.types.filters import CommuteFilter -from google.cloud.talent_v4beta1.types.filters import CompensationFilter -from google.cloud.talent_v4beta1.types.filters import JobQuery -from google.cloud.talent_v4beta1.types.filters import LocationFilter -from google.cloud.talent_v4beta1.types.histogram import HistogramQuery -from google.cloud.talent_v4beta1.types.histogram import HistogramQueryResult -from google.cloud.talent_v4beta1.types.job import Job -from google.cloud.talent_v4beta1.types.job_service import BatchCreateJobsRequest -from google.cloud.talent_v4beta1.types.job_service import BatchDeleteJobsRequest -from google.cloud.talent_v4beta1.types.job_service import BatchUpdateJobsRequest -from google.cloud.talent_v4beta1.types.job_service import CreateJobRequest -from google.cloud.talent_v4beta1.types.job_service import DeleteJobRequest -from google.cloud.talent_v4beta1.types.job_service import GetJobRequest -from google.cloud.talent_v4beta1.types.job_service import JobOperationResult -from google.cloud.talent_v4beta1.types.job_service import ListJobsRequest -from google.cloud.talent_v4beta1.types.job_service import ListJobsResponse -from google.cloud.talent_v4beta1.types.job_service import SearchJobsRequest -from google.cloud.talent_v4beta1.types.job_service import SearchJobsResponse -from google.cloud.talent_v4beta1.types.job_service import UpdateJobRequest -from google.cloud.talent_v4beta1.types.job_service import JobView -from google.cloud.talent_v4beta1.types.tenant import Tenant -from google.cloud.talent_v4beta1.types.tenant_service import CreateTenantRequest -from google.cloud.talent_v4beta1.types.tenant_service import DeleteTenantRequest -from google.cloud.talent_v4beta1.types.tenant_service import GetTenantRequest -from google.cloud.talent_v4beta1.types.tenant_service import ListTenantsRequest -from google.cloud.talent_v4beta1.types.tenant_service import ListTenantsResponse -from google.cloud.talent_v4beta1.types.tenant_service import UpdateTenantRequest - -__all__ = ('CompanyServiceClient', - 'CompanyServiceAsyncClient', - 'CompletionClient', - 'CompletionAsyncClient', - 'EventServiceClient', - 'EventServiceAsyncClient', - 'JobServiceClient', - 'JobServiceAsyncClient', - 'TenantServiceClient', - 'TenantServiceAsyncClient', - 'BatchOperationMetadata', - 'CompensationInfo', - 'CustomAttribute', - 'DeviceInfo', - 'Location', - 'RequestMetadata', - 'ResponseMetadata', - 'SpellingCorrection', - 'TimestampRange', - 'CommuteMethod', - 'CompanySize', - 'DegreeType', - 'EmploymentType', - 'HtmlSanitization', - 'JobBenefit', - 'JobCategory', - 'JobLevel', - 'PostingRegion', - 'Visibility', - 'Company', - 'CreateCompanyRequest', - 'DeleteCompanyRequest', - 'GetCompanyRequest', - 'ListCompaniesRequest', - 'ListCompaniesResponse', - 'UpdateCompanyRequest', - 'CompleteQueryRequest', - 'CompleteQueryResponse', - 'ClientEvent', - 'JobEvent', - 'CreateClientEventRequest', - 'CommuteFilter', - 'CompensationFilter', - 'JobQuery', - 'LocationFilter', - 'HistogramQuery', - 'HistogramQueryResult', - 'Job', - 'BatchCreateJobsRequest', - 'BatchDeleteJobsRequest', - 'BatchUpdateJobsRequest', - 'CreateJobRequest', - 'DeleteJobRequest', - 'GetJobRequest', - 'JobOperationResult', - 'ListJobsRequest', - 'ListJobsResponse', - 'SearchJobsRequest', - 'SearchJobsResponse', - 'UpdateJobRequest', - 'JobView', - 'Tenant', - 'CreateTenantRequest', - 'DeleteTenantRequest', - 'GetTenantRequest', - 'ListTenantsRequest', - 'ListTenantsResponse', - 'UpdateTenantRequest', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent/py.typed b/owl-bot-staging/v4beta1/google/cloud/talent/py.typed deleted file mode 100644 index d9645927..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-talent package uses inline types. diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/__init__.py deleted file mode 100644 index d9a40828..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/__init__.py +++ /dev/null @@ -1,156 +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 .services.company_service import CompanyServiceClient -from .services.company_service import CompanyServiceAsyncClient -from .services.completion import CompletionClient -from .services.completion import CompletionAsyncClient -from .services.event_service import EventServiceClient -from .services.event_service import EventServiceAsyncClient -from .services.job_service import JobServiceClient -from .services.job_service import JobServiceAsyncClient -from .services.tenant_service import TenantServiceClient -from .services.tenant_service import TenantServiceAsyncClient - -from .types.common import BatchOperationMetadata -from .types.common import CompensationInfo -from .types.common import CustomAttribute -from .types.common import DeviceInfo -from .types.common import Location -from .types.common import RequestMetadata -from .types.common import ResponseMetadata -from .types.common import SpellingCorrection -from .types.common import TimestampRange -from .types.common import CommuteMethod -from .types.common import CompanySize -from .types.common import DegreeType -from .types.common import EmploymentType -from .types.common import HtmlSanitization -from .types.common import JobBenefit -from .types.common import JobCategory -from .types.common import JobLevel -from .types.common import PostingRegion -from .types.common import Visibility -from .types.company import Company -from .types.company_service import CreateCompanyRequest -from .types.company_service import DeleteCompanyRequest -from .types.company_service import GetCompanyRequest -from .types.company_service import ListCompaniesRequest -from .types.company_service import ListCompaniesResponse -from .types.company_service import UpdateCompanyRequest -from .types.completion_service import CompleteQueryRequest -from .types.completion_service import CompleteQueryResponse -from .types.event import ClientEvent -from .types.event import JobEvent -from .types.event_service import CreateClientEventRequest -from .types.filters import CommuteFilter -from .types.filters import CompensationFilter -from .types.filters import JobQuery -from .types.filters import LocationFilter -from .types.histogram import HistogramQuery -from .types.histogram import HistogramQueryResult -from .types.job import Job -from .types.job_service import BatchCreateJobsRequest -from .types.job_service import BatchDeleteJobsRequest -from .types.job_service import BatchUpdateJobsRequest -from .types.job_service import CreateJobRequest -from .types.job_service import DeleteJobRequest -from .types.job_service import GetJobRequest -from .types.job_service import JobOperationResult -from .types.job_service import ListJobsRequest -from .types.job_service import ListJobsResponse -from .types.job_service import SearchJobsRequest -from .types.job_service import SearchJobsResponse -from .types.job_service import UpdateJobRequest -from .types.job_service import JobView -from .types.tenant import Tenant -from .types.tenant_service import CreateTenantRequest -from .types.tenant_service import DeleteTenantRequest -from .types.tenant_service import GetTenantRequest -from .types.tenant_service import ListTenantsRequest -from .types.tenant_service import ListTenantsResponse -from .types.tenant_service import UpdateTenantRequest - -__all__ = ( - 'CompanyServiceAsyncClient', - 'CompletionAsyncClient', - 'EventServiceAsyncClient', - 'JobServiceAsyncClient', - 'TenantServiceAsyncClient', -'BatchCreateJobsRequest', -'BatchDeleteJobsRequest', -'BatchOperationMetadata', -'BatchUpdateJobsRequest', -'ClientEvent', -'CommuteFilter', -'CommuteMethod', -'Company', -'CompanyServiceClient', -'CompanySize', -'CompensationFilter', -'CompensationInfo', -'CompleteQueryRequest', -'CompleteQueryResponse', -'CompletionClient', -'CreateClientEventRequest', -'CreateCompanyRequest', -'CreateJobRequest', -'CreateTenantRequest', -'CustomAttribute', -'DegreeType', -'DeleteCompanyRequest', -'DeleteJobRequest', -'DeleteTenantRequest', -'DeviceInfo', -'EmploymentType', -'EventServiceClient', -'GetCompanyRequest', -'GetJobRequest', -'GetTenantRequest', -'HistogramQuery', -'HistogramQueryResult', -'HtmlSanitization', -'Job', -'JobBenefit', -'JobCategory', -'JobEvent', -'JobLevel', -'JobOperationResult', -'JobQuery', -'JobServiceClient', -'JobView', -'ListCompaniesRequest', -'ListCompaniesResponse', -'ListJobsRequest', -'ListJobsResponse', -'ListTenantsRequest', -'ListTenantsResponse', -'Location', -'LocationFilter', -'PostingRegion', -'RequestMetadata', -'ResponseMetadata', -'SearchJobsRequest', -'SearchJobsResponse', -'SpellingCorrection', -'Tenant', -'TenantServiceClient', -'TimestampRange', -'UpdateCompanyRequest', -'UpdateJobRequest', -'UpdateTenantRequest', -'Visibility', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/gapic_metadata.json b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/gapic_metadata.json deleted file mode 100644 index ca15e97b..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/gapic_metadata.json +++ /dev/null @@ -1,299 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.talent_v4beta1", - "protoPackage": "google.cloud.talent.v4beta1", - "schema": "1.0", - "services": { - "CompanyService": { - "clients": { - "grpc": { - "libraryClient": "CompanyServiceClient", - "rpcs": { - "CreateCompany": { - "methods": [ - "create_company" - ] - }, - "DeleteCompany": { - "methods": [ - "delete_company" - ] - }, - "GetCompany": { - "methods": [ - "get_company" - ] - }, - "ListCompanies": { - "methods": [ - "list_companies" - ] - }, - "UpdateCompany": { - "methods": [ - "update_company" - ] - } - } - }, - "grpc-async": { - "libraryClient": "CompanyServiceAsyncClient", - "rpcs": { - "CreateCompany": { - "methods": [ - "create_company" - ] - }, - "DeleteCompany": { - "methods": [ - "delete_company" - ] - }, - "GetCompany": { - "methods": [ - "get_company" - ] - }, - "ListCompanies": { - "methods": [ - "list_companies" - ] - }, - "UpdateCompany": { - "methods": [ - "update_company" - ] - } - } - } - } - }, - "Completion": { - "clients": { - "grpc": { - "libraryClient": "CompletionClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "complete_query" - ] - } - } - }, - "grpc-async": { - "libraryClient": "CompletionAsyncClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "complete_query" - ] - } - } - } - } - }, - "EventService": { - "clients": { - "grpc": { - "libraryClient": "EventServiceClient", - "rpcs": { - "CreateClientEvent": { - "methods": [ - "create_client_event" - ] - } - } - }, - "grpc-async": { - "libraryClient": "EventServiceAsyncClient", - "rpcs": { - "CreateClientEvent": { - "methods": [ - "create_client_event" - ] - } - } - } - } - }, - "JobService": { - "clients": { - "grpc": { - "libraryClient": "JobServiceClient", - "rpcs": { - "BatchCreateJobs": { - "methods": [ - "batch_create_jobs" - ] - }, - "BatchDeleteJobs": { - "methods": [ - "batch_delete_jobs" - ] - }, - "BatchUpdateJobs": { - "methods": [ - "batch_update_jobs" - ] - }, - "CreateJob": { - "methods": [ - "create_job" - ] - }, - "DeleteJob": { - "methods": [ - "delete_job" - ] - }, - "GetJob": { - "methods": [ - "get_job" - ] - }, - "ListJobs": { - "methods": [ - "list_jobs" - ] - }, - "SearchJobs": { - "methods": [ - "search_jobs" - ] - }, - "SearchJobsForAlert": { - "methods": [ - "search_jobs_for_alert" - ] - }, - "UpdateJob": { - "methods": [ - "update_job" - ] - } - } - }, - "grpc-async": { - "libraryClient": "JobServiceAsyncClient", - "rpcs": { - "BatchCreateJobs": { - "methods": [ - "batch_create_jobs" - ] - }, - "BatchDeleteJobs": { - "methods": [ - "batch_delete_jobs" - ] - }, - "BatchUpdateJobs": { - "methods": [ - "batch_update_jobs" - ] - }, - "CreateJob": { - "methods": [ - "create_job" - ] - }, - "DeleteJob": { - "methods": [ - "delete_job" - ] - }, - "GetJob": { - "methods": [ - "get_job" - ] - }, - "ListJobs": { - "methods": [ - "list_jobs" - ] - }, - "SearchJobs": { - "methods": [ - "search_jobs" - ] - }, - "SearchJobsForAlert": { - "methods": [ - "search_jobs_for_alert" - ] - }, - "UpdateJob": { - "methods": [ - "update_job" - ] - } - } - } - } - }, - "TenantService": { - "clients": { - "grpc": { - "libraryClient": "TenantServiceClient", - "rpcs": { - "CreateTenant": { - "methods": [ - "create_tenant" - ] - }, - "DeleteTenant": { - "methods": [ - "delete_tenant" - ] - }, - "GetTenant": { - "methods": [ - "get_tenant" - ] - }, - "ListTenants": { - "methods": [ - "list_tenants" - ] - }, - "UpdateTenant": { - "methods": [ - "update_tenant" - ] - } - } - }, - "grpc-async": { - "libraryClient": "TenantServiceAsyncClient", - "rpcs": { - "CreateTenant": { - "methods": [ - "create_tenant" - ] - }, - "DeleteTenant": { - "methods": [ - "delete_tenant" - ] - }, - "GetTenant": { - "methods": [ - "get_tenant" - ] - }, - "ListTenants": { - "methods": [ - "list_tenants" - ] - }, - "UpdateTenant": { - "methods": [ - "update_tenant" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/py.typed b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/py.typed deleted file mode 100644 index d9645927..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-talent package uses inline types. diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/__init__.py deleted file mode 100644 index e8e1c384..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/__init__.py +++ /dev/null @@ -1,15 +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. -# diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/__init__.py deleted file mode 100644 index bf2d436c..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_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 .client import CompanyServiceClient -from .async_client import CompanyServiceAsyncClient - -__all__ = ( - 'CompanyServiceClient', - 'CompanyServiceAsyncClient', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/async_client.py deleted file mode 100644 index afd5fdcb..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/async_client.py +++ /dev/null @@ -1,846 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -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 -from google.cloud.talent_v4beta1.types import company as gct_company -from google.cloud.talent_v4beta1.types import company_service -from google.longrunning import operations_pb2 -from .transports.base import CompanyServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport -from .client import CompanyServiceClient - - -class CompanyServiceAsyncClient: - """A service that handles company management, including CRUD and - enumeration. - """ - - _client: CompanyServiceClient - - DEFAULT_ENDPOINT = CompanyServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = CompanyServiceClient.DEFAULT_MTLS_ENDPOINT - - company_path = staticmethod(CompanyServiceClient.company_path) - parse_company_path = staticmethod(CompanyServiceClient.parse_company_path) - common_billing_account_path = staticmethod(CompanyServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(CompanyServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(CompanyServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(CompanyServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(CompanyServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(CompanyServiceClient.parse_common_organization_path) - common_project_path = staticmethod(CompanyServiceClient.common_project_path) - parse_common_project_path = staticmethod(CompanyServiceClient.parse_common_project_path) - common_location_path = staticmethod(CompanyServiceClient.common_location_path) - parse_common_location_path = staticmethod(CompanyServiceClient.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: - CompanyServiceAsyncClient: The constructed client. - """ - return CompanyServiceClient.from_service_account_info.__func__(CompanyServiceAsyncClient, 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: - CompanyServiceAsyncClient: The constructed client. - """ - return CompanyServiceClient.from_service_account_file.__func__(CompanyServiceAsyncClient, 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 CompanyServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> CompanyServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CompanyServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(CompanyServiceClient).get_transport_class, type(CompanyServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, CompanyServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the company 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, ~.CompanyServiceTransport]): 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 = CompanyServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_company(self, - request: Union[company_service.CreateCompanyRequest, dict] = None, - *, - parent: str = None, - company: gct_company.Company = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_company.Company: - r"""Creates a new company entity. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_create_company(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - company = talent_v4beta1.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4beta1.CreateCompanyRequest( - parent="parent_value", - company=company, - ) - - # Make the request - response = await client.create_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateCompanyRequest, dict]): - The request object. The Request of the CreateCompany - method. - parent (:class:`str`): - Required. Resource name of the tenant under which the - company is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created, for example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - company (:class:`google.cloud.talent_v4beta1.types.Company`): - Required. The company to be created. - This corresponds to the ``company`` 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.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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, company]) - 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 = company_service.CreateCompanyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if company is not None: - request.company = company - - # 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_company, - 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_company(self, - request: Union[company_service.GetCompanyRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> company.Company: - r"""Retrieves specified company. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_get_company(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetCompanyRequest( - name="name_value", - ) - - # Make the request - response = await client.get_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetCompanyRequest, dict]): - The request object. Request for getting a company by - name. - name (:class:`str`): - Required. The resource name of the company to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, - "projects/api-test-project/tenants/foo/companies/bar". - - If tenant id is unspecified, the default tenant is used, - for example, "projects/api-test-project/companies/bar". - - 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.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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 = company_service.GetCompanyRequest(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_company, - 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_company(self, - request: Union[company_service.UpdateCompanyRequest, dict] = None, - *, - company: gct_company.Company = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_company.Company: - r"""Updates specified company. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_update_company(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - company = talent_v4beta1.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4beta1.UpdateCompanyRequest( - company=company, - ) - - # Make the request - response = await client.update_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateCompanyRequest, dict]): - The request object. Request for updating a specified - company. - company (:class:`google.cloud.talent_v4beta1.types.Company`): - Required. The company resource to - replace the current resource in the - system. - - This corresponds to the ``company`` 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.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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([company]) - 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 = company_service.UpdateCompanyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if company is not None: - request.company = company - - # 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_company, - 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(( - ("company.name", request.company.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_company(self, - request: Union[company_service.DeleteCompanyRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified company. - Prerequisite: The company has no jobs associated with - it. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_delete_company(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteCompanyRequest( - name="name_value", - ) - - # Make the request - await client.delete_company(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteCompanyRequest, dict]): - The request object. Request to delete a company. - name (:class:`str`): - Required. The resource name of the company to be - deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/baz". - - If tenant id is unspecified, the default tenant is used, - for example, "projects/foo/companies/bar". - - 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 = company_service.DeleteCompanyRequest(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_company, - 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_companies(self, - request: Union[company_service.ListCompaniesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCompaniesAsyncPager: - r"""Lists all companies associated with the project. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_list_companies(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListCompaniesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_companies(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListCompaniesRequest, dict]): - The request object. List companies for which the client - has ACL visibility. - parent (:class:`str`): - Required. Resource name of the tenant under which the - company is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenant/bar". - - If tenant id is unspecified, the default tenant will be - used, for example, "projects/foo". - - 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.company_service.pagers.ListCompaniesAsyncPager: - The List companies 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 = company_service.ListCompaniesRequest(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_companies, - 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.ListCompaniesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # 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 - - 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__ = ( - "CompanyServiceAsyncClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/client.py deleted file mode 100644 index e54ab3bb..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/client.py +++ /dev/null @@ -1,1027 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -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 -from google.cloud.talent_v4beta1.types import company as gct_company -from google.cloud.talent_v4beta1.types import company_service -from google.longrunning import operations_pb2 -from .transports.base import CompanyServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import CompanyServiceGrpcTransport -from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport - - -class CompanyServiceClientMeta(type): - """Metaclass for the CompanyService 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[CompanyServiceTransport]] - _transport_registry["grpc"] = CompanyServiceGrpcTransport - _transport_registry["grpc_asyncio"] = CompanyServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[CompanyServiceTransport]: - """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 CompanyServiceClient(metaclass=CompanyServiceClientMeta): - """A service that handles company 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: - CompanyServiceClient: 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: - CompanyServiceClient: 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) -> CompanyServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CompanyServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @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 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, CompanyServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the company 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, CompanyServiceTransport]): 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, CompanyServiceTransport): - # transport is a CompanyServiceTransport 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, - api_audience=client_options.api_audience, - ) - - def create_company(self, - request: Union[company_service.CreateCompanyRequest, dict] = None, - *, - parent: str = None, - company: gct_company.Company = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_company.Company: - r"""Creates a new company entity. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_create_company(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - company = talent_v4beta1.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4beta1.CreateCompanyRequest( - parent="parent_value", - company=company, - ) - - # Make the request - response = client.create_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateCompanyRequest, dict]): - The request object. The Request of the CreateCompany - method. - parent (str): - Required. Resource name of the tenant under which the - company is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created, for example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - company (google.cloud.talent_v4beta1.types.Company): - Required. The company to be created. - This corresponds to the ``company`` 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.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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, company]) - 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 company_service.CreateCompanyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.CreateCompanyRequest): - request = company_service.CreateCompanyRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if company is not None: - request.company = company - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_company] - - # 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_company(self, - request: Union[company_service.GetCompanyRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> company.Company: - r"""Retrieves specified company. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_get_company(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetCompanyRequest( - name="name_value", - ) - - # Make the request - response = client.get_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetCompanyRequest, dict]): - The request object. Request for getting a company by - name. - name (str): - Required. The resource name of the company to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, - "projects/api-test-project/tenants/foo/companies/bar". - - If tenant id is unspecified, the default tenant is used, - for example, "projects/api-test-project/companies/bar". - - 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.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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 company_service.GetCompanyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.GetCompanyRequest): - request = company_service.GetCompanyRequest(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_company] - - # 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_company(self, - request: Union[company_service.UpdateCompanyRequest, dict] = None, - *, - company: gct_company.Company = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_company.Company: - r"""Updates specified company. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_update_company(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - company = talent_v4beta1.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4beta1.UpdateCompanyRequest( - company=company, - ) - - # Make the request - response = client.update_company(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateCompanyRequest, dict]): - The request object. Request for updating a specified - company. - company (google.cloud.talent_v4beta1.types.Company): - Required. The company resource to - replace the current resource in the - system. - - This corresponds to the ``company`` 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.Company: - A Company resource represents a - company in the service. A company is the - entity that owns job postings, that is, - the hiring entity responsible for - employing applicants for the job - position. - - """ - # 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([company]) - 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 company_service.UpdateCompanyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.UpdateCompanyRequest): - request = company_service.UpdateCompanyRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if company is not None: - request.company = company - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_company] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("company.name", request.company.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_company(self, - request: Union[company_service.DeleteCompanyRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified company. - Prerequisite: The company has no jobs associated with - it. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_delete_company(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteCompanyRequest( - name="name_value", - ) - - # Make the request - client.delete_company(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteCompanyRequest, dict]): - The request object. Request to delete a company. - name (str): - Required. The resource name of the company to be - deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/baz". - - If tenant id is unspecified, the default tenant is used, - for example, "projects/foo/companies/bar". - - 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 company_service.DeleteCompanyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.DeleteCompanyRequest): - request = company_service.DeleteCompanyRequest(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_company] - - # 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_companies(self, - request: Union[company_service.ListCompaniesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCompaniesPager: - r"""Lists all companies associated with the project. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_list_companies(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListCompaniesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_companies(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListCompaniesRequest, dict]): - The request object. List companies for which the client - has ACL visibility. - parent (str): - Required. Resource name of the tenant under which the - company is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenant/bar". - - If tenant id is unspecified, the default tenant will be - used, for example, "projects/foo". - - 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.company_service.pagers.ListCompaniesPager: - The List companies 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 company_service.ListCompaniesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, company_service.ListCompaniesRequest): - request = company_service.ListCompaniesRequest(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_companies] - - # 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.ListCompaniesPager( - 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() - - 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( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "CompanyServiceClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/pagers.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/pagers.py deleted file mode 100644 index c37d1eaf..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/pagers.py +++ /dev/null @@ -1,140 +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, Sequence, Tuple, Optional, Iterator - -from google.cloud.talent_v4beta1.types import company -from google.cloud.talent_v4beta1.types import company_service - - -class ListCompaniesPager: - """A pager for iterating through ``list_companies`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListCompaniesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``companies`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCompanies`` requests and continue to iterate - through the ``companies`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListCompaniesResponse` - 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[..., company_service.ListCompaniesResponse], - request: company_service.ListCompaniesRequest, - response: company_service.ListCompaniesResponse, - *, - 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.ListCompaniesRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListCompaniesResponse): - 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 = company_service.ListCompaniesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[company_service.ListCompaniesResponse]: - 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[company.Company]: - for page in self.pages: - yield from page.companies - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCompaniesAsyncPager: - """A pager for iterating through ``list_companies`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListCompaniesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``companies`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCompanies`` requests and continue to iterate - through the ``companies`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListCompaniesResponse` - 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[company_service.ListCompaniesResponse]], - request: company_service.ListCompaniesRequest, - response: company_service.ListCompaniesResponse, - *, - 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.ListCompaniesRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListCompaniesResponse): - 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 = company_service.ListCompaniesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[company_service.ListCompaniesResponse]: - 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[company.Company]: - async def async_generator(): - async for page in self.pages: - for response in page.companies: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py deleted file mode 100644 index 1b586f42..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py +++ /dev/null @@ -1,33 +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 CompanyServiceTransport -from .grpc import CompanyServiceGrpcTransport -from .grpc_asyncio import CompanyServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[CompanyServiceTransport]] -_transport_registry['grpc'] = CompanyServiceGrpcTransport -_transport_registry['grpc_asyncio'] = CompanyServiceGrpcAsyncIOTransport - -__all__ = ( - 'CompanyServiceTransport', - 'CompanyServiceGrpcTransport', - 'CompanyServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/base.py deleted file mode 100644 index 6308966e..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/base.py +++ /dev/null @@ -1,245 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4beta1.types import company -from google.cloud.talent_v4beta1.types import company as gct_company -from google.cloud.talent_v4beta1.types import company_service -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -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 CompanyServiceTransport(abc.ABC): - """Abstract transport class for CompanyService.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.create_company: gapic_v1.method.wrap_method( - self.create_company, - default_timeout=30.0, - client_info=client_info, - ), - self.get_company: gapic_v1.method.wrap_method( - self.get_company, - 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_company: gapic_v1.method.wrap_method( - self.update_company, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_company: gapic_v1.method.wrap_method( - self.delete_company, - 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_companies: gapic_v1.method.wrap_method( - self.list_companies, - 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_company(self) -> Callable[ - [company_service.CreateCompanyRequest], - Union[ - gct_company.Company, - Awaitable[gct_company.Company] - ]]: - raise NotImplementedError() - - @property - def get_company(self) -> Callable[ - [company_service.GetCompanyRequest], - Union[ - company.Company, - Awaitable[company.Company] - ]]: - raise NotImplementedError() - - @property - def update_company(self) -> Callable[ - [company_service.UpdateCompanyRequest], - Union[ - gct_company.Company, - Awaitable[gct_company.Company] - ]]: - raise NotImplementedError() - - @property - def delete_company(self) -> Callable[ - [company_service.DeleteCompanyRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_companies(self) -> Callable[ - [company_service.ListCompaniesRequest], - Union[ - company_service.ListCompaniesResponse, - Awaitable[company_service.ListCompaniesResponse] - ]]: - 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() - - -__all__ = ( - 'CompanyServiceTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py deleted file mode 100644 index 2e2c4a1e..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py +++ /dev/null @@ -1,393 +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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4beta1.types import company -from google.cloud.talent_v4beta1.types import company as gct_company -from google.cloud.talent_v4beta1.types import company_service -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import CompanyServiceTransport, DEFAULT_CLIENT_INFO - - -class CompanyServiceGrpcTransport(CompanyServiceTransport): - """gRPC backend transport for CompanyService. - - A service that handles company 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_company(self) -> Callable[ - [company_service.CreateCompanyRequest], - gct_company.Company]: - r"""Return a callable for the create company method over gRPC. - - Creates a new company entity. - - Returns: - Callable[[~.CreateCompanyRequest], - ~.Company]: - 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_company' not in self._stubs: - self._stubs['create_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/CreateCompany', - request_serializer=company_service.CreateCompanyRequest.serialize, - response_deserializer=gct_company.Company.deserialize, - ) - return self._stubs['create_company'] - - @property - def get_company(self) -> Callable[ - [company_service.GetCompanyRequest], - company.Company]: - r"""Return a callable for the get company method over gRPC. - - Retrieves specified company. - - Returns: - Callable[[~.GetCompanyRequest], - ~.Company]: - 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_company' not in self._stubs: - self._stubs['get_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/GetCompany', - request_serializer=company_service.GetCompanyRequest.serialize, - response_deserializer=company.Company.deserialize, - ) - return self._stubs['get_company'] - - @property - def update_company(self) -> Callable[ - [company_service.UpdateCompanyRequest], - gct_company.Company]: - r"""Return a callable for the update company method over gRPC. - - Updates specified company. - - Returns: - Callable[[~.UpdateCompanyRequest], - ~.Company]: - 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_company' not in self._stubs: - self._stubs['update_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/UpdateCompany', - request_serializer=company_service.UpdateCompanyRequest.serialize, - response_deserializer=gct_company.Company.deserialize, - ) - return self._stubs['update_company'] - - @property - def delete_company(self) -> Callable[ - [company_service.DeleteCompanyRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete company method over gRPC. - - Deletes specified company. - Prerequisite: The company has no jobs associated with - it. - - Returns: - Callable[[~.DeleteCompanyRequest], - ~.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_company' not in self._stubs: - self._stubs['delete_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/DeleteCompany', - request_serializer=company_service.DeleteCompanyRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_company'] - - @property - def list_companies(self) -> Callable[ - [company_service.ListCompaniesRequest], - company_service.ListCompaniesResponse]: - r"""Return a callable for the list companies method over gRPC. - - Lists all companies associated with the project. - - Returns: - Callable[[~.ListCompaniesRequest], - ~.ListCompaniesResponse]: - 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_companies' not in self._stubs: - self._stubs['list_companies'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/ListCompanies', - request_serializer=company_service.ListCompaniesRequest.serialize, - response_deserializer=company_service.ListCompaniesResponse.deserialize, - ) - return self._stubs['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" - - -__all__ = ( - 'CompanyServiceGrpcTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py deleted file mode 100644 index c2a5af33..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,392 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4beta1.types import company -from google.cloud.talent_v4beta1.types import company as gct_company -from google.cloud.talent_v4beta1.types import company_service -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import CompanyServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import CompanyServiceGrpcTransport - - -class CompanyServiceGrpcAsyncIOTransport(CompanyServiceTransport): - """gRPC AsyncIO backend transport for CompanyService. - - A service that handles company 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_company(self) -> Callable[ - [company_service.CreateCompanyRequest], - Awaitable[gct_company.Company]]: - r"""Return a callable for the create company method over gRPC. - - Creates a new company entity. - - Returns: - Callable[[~.CreateCompanyRequest], - Awaitable[~.Company]]: - 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_company' not in self._stubs: - self._stubs['create_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/CreateCompany', - request_serializer=company_service.CreateCompanyRequest.serialize, - response_deserializer=gct_company.Company.deserialize, - ) - return self._stubs['create_company'] - - @property - def get_company(self) -> Callable[ - [company_service.GetCompanyRequest], - Awaitable[company.Company]]: - r"""Return a callable for the get company method over gRPC. - - Retrieves specified company. - - Returns: - Callable[[~.GetCompanyRequest], - Awaitable[~.Company]]: - 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_company' not in self._stubs: - self._stubs['get_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/GetCompany', - request_serializer=company_service.GetCompanyRequest.serialize, - response_deserializer=company.Company.deserialize, - ) - return self._stubs['get_company'] - - @property - def update_company(self) -> Callable[ - [company_service.UpdateCompanyRequest], - Awaitable[gct_company.Company]]: - r"""Return a callable for the update company method over gRPC. - - Updates specified company. - - Returns: - Callable[[~.UpdateCompanyRequest], - Awaitable[~.Company]]: - 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_company' not in self._stubs: - self._stubs['update_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/UpdateCompany', - request_serializer=company_service.UpdateCompanyRequest.serialize, - response_deserializer=gct_company.Company.deserialize, - ) - return self._stubs['update_company'] - - @property - def delete_company(self) -> Callable[ - [company_service.DeleteCompanyRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete company method over gRPC. - - Deletes specified company. - Prerequisite: The company has no jobs associated with - it. - - Returns: - Callable[[~.DeleteCompanyRequest], - 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_company' not in self._stubs: - self._stubs['delete_company'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/DeleteCompany', - request_serializer=company_service.DeleteCompanyRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_company'] - - @property - def list_companies(self) -> Callable[ - [company_service.ListCompaniesRequest], - Awaitable[company_service.ListCompaniesResponse]]: - r"""Return a callable for the list companies method over gRPC. - - Lists all companies associated with the project. - - Returns: - Callable[[~.ListCompaniesRequest], - Awaitable[~.ListCompaniesResponse]]: - 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_companies' not in self._stubs: - self._stubs['list_companies'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.CompanyService/ListCompanies', - request_serializer=company_service.ListCompaniesRequest.serialize, - response_deserializer=company_service.ListCompaniesResponse.deserialize, - ) - return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/__init__.py deleted file mode 100644 index 28d77594..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/__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 .client import CompletionClient -from .async_client import CompletionAsyncClient - -__all__ = ( - 'CompletionClient', - 'CompletionAsyncClient', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/async_client.py deleted file mode 100644 index 9428436e..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/async_client.py +++ /dev/null @@ -1,345 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import completion_service -from google.longrunning import operations_pb2 -from .transports.base import CompletionTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport -from .client import CompletionClient - - -class CompletionAsyncClient: - """A service handles auto completion.""" - - _client: CompletionClient - - DEFAULT_ENDPOINT = CompletionClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = CompletionClient.DEFAULT_MTLS_ENDPOINT - - company_path = staticmethod(CompletionClient.company_path) - parse_company_path = staticmethod(CompletionClient.parse_company_path) - common_billing_account_path = staticmethod(CompletionClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(CompletionClient.parse_common_billing_account_path) - common_folder_path = staticmethod(CompletionClient.common_folder_path) - parse_common_folder_path = staticmethod(CompletionClient.parse_common_folder_path) - common_organization_path = staticmethod(CompletionClient.common_organization_path) - parse_common_organization_path = staticmethod(CompletionClient.parse_common_organization_path) - common_project_path = staticmethod(CompletionClient.common_project_path) - parse_common_project_path = staticmethod(CompletionClient.parse_common_project_path) - common_location_path = staticmethod(CompletionClient.common_location_path) - parse_common_location_path = staticmethod(CompletionClient.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: - CompletionAsyncClient: The constructed client. - """ - return CompletionClient.from_service_account_info.__func__(CompletionAsyncClient, 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: - CompletionAsyncClient: The constructed client. - """ - return CompletionClient.from_service_account_file.__func__(CompletionAsyncClient, 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 CompletionClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> CompletionTransport: - """Returns the transport used by the client instance. - - Returns: - CompletionTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(CompletionClient).get_transport_class, type(CompletionClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, CompletionTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the completion 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, ~.CompletionTransport]): 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 = CompletionClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def complete_query(self, - request: Union[completion_service.CompleteQueryRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> completion_service.CompleteQueryResponse: - r"""Completes the specified prefix with keyword - suggestions. Intended for use by a job search - auto-complete search box. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_complete_query(): - # Create a client - client = talent_v4beta1.CompletionAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.CompleteQueryRequest( - parent="parent_value", - query="query_value", - page_size=951, - ) - - # Make the request - response = await client.complete_query(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CompleteQueryRequest, dict]): - The request object. Auto-complete parameters. - 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.CompleteQueryResponse: - Response of auto-complete query. - """ - # Create or coerce a protobuf request object. - request = completion_service.CompleteQueryRequest(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.complete_query, - 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, - ) - - # 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 - - 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__ = ( - "CompletionAsyncClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/client.py deleted file mode 100644 index 9166016a..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/client.py +++ /dev/null @@ -1,541 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import completion_service -from google.longrunning import operations_pb2 -from .transports.base import CompletionTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import CompletionGrpcTransport -from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport - - -class CompletionClientMeta(type): - """Metaclass for the Completion 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[CompletionTransport]] - _transport_registry["grpc"] = CompletionGrpcTransport - _transport_registry["grpc_asyncio"] = CompletionGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[CompletionTransport]: - """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 CompletionClient(metaclass=CompletionClientMeta): - """A service handles auto completion.""" - - @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: - CompletionClient: 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: - CompletionClient: 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) -> CompletionTransport: - """Returns the transport used by the client instance. - - Returns: - CompletionTransport: The transport used by the client - instance. - """ - return self._transport - - @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 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, CompletionTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the completion 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, CompletionTransport]): 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, CompletionTransport): - # transport is a CompletionTransport 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, - api_audience=client_options.api_audience, - ) - - def complete_query(self, - request: Union[completion_service.CompleteQueryRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> completion_service.CompleteQueryResponse: - r"""Completes the specified prefix with keyword - suggestions. Intended for use by a job search - auto-complete search box. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_complete_query(): - # Create a client - client = talent_v4beta1.CompletionClient() - - # Initialize request argument(s) - request = talent_v4beta1.CompleteQueryRequest( - parent="parent_value", - query="query_value", - page_size=951, - ) - - # Make the request - response = client.complete_query(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CompleteQueryRequest, dict]): - The request object. Auto-complete parameters. - 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.CompleteQueryResponse: - Response of auto-complete query. - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a completion_service.CompleteQueryRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, completion_service.CompleteQueryRequest): - request = completion_service.CompleteQueryRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.complete_query] - - # 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 __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() - - 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( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "CompletionClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/__init__.py deleted file mode 100644 index 14e86855..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/__init__.py +++ /dev/null @@ -1,33 +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 CompletionTransport -from .grpc import CompletionGrpcTransport -from .grpc_asyncio import CompletionGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[CompletionTransport]] -_transport_registry['grpc'] = CompletionGrpcTransport -_transport_registry['grpc_asyncio'] = CompletionGrpcAsyncIOTransport - -__all__ = ( - 'CompletionTransport', - 'CompletionGrpcTransport', - 'CompletionGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/base.py deleted file mode 100644 index 63ea341e..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/base.py +++ /dev/null @@ -1,172 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4beta1.types import completion_service -from google.longrunning import operations_pb2 - -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 CompletionTransport(abc.ABC): - """Abstract transport class for Completion.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.complete_query: gapic_v1.method.wrap_method( - self.complete_query, - 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 complete_query(self) -> Callable[ - [completion_service.CompleteQueryRequest], - Union[ - completion_service.CompleteQueryResponse, - Awaitable[completion_service.CompleteQueryResponse] - ]]: - 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() - - -__all__ = ( - 'CompletionTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc.py deleted file mode 100644 index 362f4a2b..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc.py +++ /dev/null @@ -1,285 +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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4beta1.types import completion_service -from google.longrunning import operations_pb2 -from .base import CompletionTransport, DEFAULT_CLIENT_INFO - - -class CompletionGrpcTransport(CompletionTransport): - """gRPC backend transport for Completion. - - A service handles auto completion. - - 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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 complete_query(self) -> Callable[ - [completion_service.CompleteQueryRequest], - completion_service.CompleteQueryResponse]: - r"""Return a callable for the complete query method over gRPC. - - Completes the specified prefix with keyword - suggestions. Intended for use by a job search - auto-complete search box. - - Returns: - Callable[[~.CompleteQueryRequest], - ~.CompleteQueryResponse]: - 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 'complete_query' not in self._stubs: - self._stubs['complete_query'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.Completion/CompleteQuery', - request_serializer=completion_service.CompleteQueryRequest.serialize, - response_deserializer=completion_service.CompleteQueryResponse.deserialize, - ) - return self._stubs['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" - - -__all__ = ( - 'CompletionGrpcTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py deleted file mode 100644 index 635ed224..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py +++ /dev/null @@ -1,284 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4beta1.types import completion_service -from google.longrunning import operations_pb2 -from .base import CompletionTransport, DEFAULT_CLIENT_INFO -from .grpc import CompletionGrpcTransport - - -class CompletionGrpcAsyncIOTransport(CompletionTransport): - """gRPC AsyncIO backend transport for Completion. - - A service handles auto completion. - - 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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 complete_query(self) -> Callable[ - [completion_service.CompleteQueryRequest], - Awaitable[completion_service.CompleteQueryResponse]]: - r"""Return a callable for the complete query method over gRPC. - - Completes the specified prefix with keyword - suggestions. Intended for use by a job search - auto-complete search box. - - Returns: - Callable[[~.CompleteQueryRequest], - Awaitable[~.CompleteQueryResponse]]: - 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 'complete_query' not in self._stubs: - self._stubs['complete_query'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.Completion/CompleteQuery', - request_serializer=completion_service.CompleteQueryRequest.serialize, - response_deserializer=completion_service.CompleteQueryResponse.deserialize, - ) - return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/__init__.py deleted file mode 100644 index 194a67c4..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_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 .client import EventServiceClient -from .async_client import EventServiceAsyncClient - -__all__ = ( - 'EventServiceClient', - 'EventServiceAsyncClient', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/async_client.py deleted file mode 100644 index f3d7c3a3..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/async_client.py +++ /dev/null @@ -1,394 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4beta1.types import event -from google.cloud.talent_v4beta1.types import event_service -from google.longrunning import operations_pb2 -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import EventServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport -from .client import EventServiceClient - - -class EventServiceAsyncClient: - """A service handles client event report.""" - - _client: EventServiceClient - - DEFAULT_ENDPOINT = EventServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = EventServiceClient.DEFAULT_MTLS_ENDPOINT - - company_path = staticmethod(EventServiceClient.company_path) - parse_company_path = staticmethod(EventServiceClient.parse_company_path) - common_billing_account_path = staticmethod(EventServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(EventServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(EventServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(EventServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(EventServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(EventServiceClient.parse_common_organization_path) - common_project_path = staticmethod(EventServiceClient.common_project_path) - parse_common_project_path = staticmethod(EventServiceClient.parse_common_project_path) - common_location_path = staticmethod(EventServiceClient.common_location_path) - parse_common_location_path = staticmethod(EventServiceClient.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: - EventServiceAsyncClient: The constructed client. - """ - return EventServiceClient.from_service_account_info.__func__(EventServiceAsyncClient, 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: - EventServiceAsyncClient: The constructed client. - """ - return EventServiceClient.from_service_account_file.__func__(EventServiceAsyncClient, 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 EventServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> EventServiceTransport: - """Returns the transport used by the client instance. - - Returns: - EventServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(EventServiceClient).get_transport_class, type(EventServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, EventServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the event 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, ~.EventServiceTransport]): 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 = EventServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_client_event(self, - request: Union[event_service.CreateClientEventRequest, dict] = None, - *, - parent: str = None, - client_event: event.ClientEvent = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> event.ClientEvent: - r"""Report events issued when end user interacts with customer's - application that uses Cloud Talent Solution. You may inspect the - created events in `self service - tools `__. - `Learn - more `__ - about self service tools. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_create_client_event(): - # Create a client - client = talent_v4beta1.EventServiceAsyncClient() - - # Initialize request argument(s) - client_event = talent_v4beta1.ClientEvent() - client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] - client_event.event_id = "event_id_value" - - request = talent_v4beta1.CreateClientEventRequest( - parent="parent_value", - client_event=client_event, - ) - - # Make the request - response = await client.create_client_event(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateClientEventRequest, dict]): - The request object. The report event request. - parent (:class:`str`): - Required. Resource name of the tenant under which the - event is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created, for example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - client_event (:class:`google.cloud.talent_v4beta1.types.ClientEvent`): - Required. Events issued when end user - interacts with customer's application - that uses Cloud Talent Solution. - - This corresponds to the ``client_event`` 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.ClientEvent: - An event issued when an end user - interacts with the application that - implements Cloud Talent Solution. - Providing this information improves the - quality of results for the API clients, - enabling the service to perform - optimally. The number of events sent - must be consistent with other calls, - such as job searches, issued to the - service by the client. - - """ - # 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, client_event]) - 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 = event_service.CreateClientEventRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if client_event is not None: - request.client_event = client_event - - # 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_client_event, - 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_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 - - 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__ = ( - "EventServiceAsyncClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/client.py deleted file mode 100644 index f2be937f..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/client.py +++ /dev/null @@ -1,596 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.talent_v4beta1.types import event -from google.cloud.talent_v4beta1.types import event_service -from google.longrunning import operations_pb2 -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import EventServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import EventServiceGrpcTransport -from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport - - -class EventServiceClientMeta(type): - """Metaclass for the EventService 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[EventServiceTransport]] - _transport_registry["grpc"] = EventServiceGrpcTransport - _transport_registry["grpc_asyncio"] = EventServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[EventServiceTransport]: - """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 EventServiceClient(metaclass=EventServiceClientMeta): - """A service handles client event report.""" - - @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: - EventServiceClient: 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: - EventServiceClient: 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) -> EventServiceTransport: - """Returns the transport used by the client instance. - - Returns: - EventServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @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 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, EventServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the event 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, EventServiceTransport]): 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, EventServiceTransport): - # transport is a EventServiceTransport 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, - api_audience=client_options.api_audience, - ) - - def create_client_event(self, - request: Union[event_service.CreateClientEventRequest, dict] = None, - *, - parent: str = None, - client_event: event.ClientEvent = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> event.ClientEvent: - r"""Report events issued when end user interacts with customer's - application that uses Cloud Talent Solution. You may inspect the - created events in `self service - tools `__. - `Learn - more `__ - about self service tools. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_create_client_event(): - # Create a client - client = talent_v4beta1.EventServiceClient() - - # Initialize request argument(s) - client_event = talent_v4beta1.ClientEvent() - client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] - client_event.event_id = "event_id_value" - - request = talent_v4beta1.CreateClientEventRequest( - parent="parent_value", - client_event=client_event, - ) - - # Make the request - response = client.create_client_event(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateClientEventRequest, dict]): - The request object. The report event request. - parent (str): - Required. Resource name of the tenant under which the - event is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created, for example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - client_event (google.cloud.talent_v4beta1.types.ClientEvent): - Required. Events issued when end user - interacts with customer's application - that uses Cloud Talent Solution. - - This corresponds to the ``client_event`` 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.ClientEvent: - An event issued when an end user - interacts with the application that - implements Cloud Talent Solution. - Providing this information improves the - quality of results for the API clients, - enabling the service to perform - optimally. The number of events sent - must be consistent with other calls, - such as job searches, issued to the - service by the client. - - """ - # 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, client_event]) - 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 event_service.CreateClientEventRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, event_service.CreateClientEventRequest): - request = event_service.CreateClientEventRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if client_event is not None: - request.client_event = client_event - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_client_event] - - # 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 __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() - - 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( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "EventServiceClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py deleted file mode 100644 index 4647d6a8..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py +++ /dev/null @@ -1,33 +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 EventServiceTransport -from .grpc import EventServiceGrpcTransport -from .grpc_asyncio import EventServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[EventServiceTransport]] -_transport_registry['grpc'] = EventServiceGrpcTransport -_transport_registry['grpc_asyncio'] = EventServiceGrpcAsyncIOTransport - -__all__ = ( - 'EventServiceTransport', - 'EventServiceGrpcTransport', - 'EventServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/base.py deleted file mode 100644 index a73f141c..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/base.py +++ /dev/null @@ -1,166 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4beta1.types import event -from google.cloud.talent_v4beta1.types import event_service -from google.longrunning import operations_pb2 - -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 EventServiceTransport(abc.ABC): - """Abstract transport class for EventService.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.create_client_event: gapic_v1.method.wrap_method( - self.create_client_event, - 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_client_event(self) -> Callable[ - [event_service.CreateClientEventRequest], - Union[ - event.ClientEvent, - Awaitable[event.ClientEvent] - ]]: - 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() - - -__all__ = ( - 'EventServiceTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py deleted file mode 100644 index 5c17699c..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py +++ /dev/null @@ -1,290 +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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4beta1.types import event -from google.cloud.talent_v4beta1.types import event_service -from google.longrunning import operations_pb2 -from .base import EventServiceTransport, DEFAULT_CLIENT_INFO - - -class EventServiceGrpcTransport(EventServiceTransport): - """gRPC backend transport for EventService. - - A service handles client event report. - - 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_client_event(self) -> Callable[ - [event_service.CreateClientEventRequest], - event.ClientEvent]: - r"""Return a callable for the create client event method over gRPC. - - Report events issued when end user interacts with customer's - application that uses Cloud Talent Solution. You may inspect the - created events in `self service - tools `__. - `Learn - more `__ - about self service tools. - - Returns: - Callable[[~.CreateClientEventRequest], - ~.ClientEvent]: - 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_client_event' not in self._stubs: - self._stubs['create_client_event'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.EventService/CreateClientEvent', - request_serializer=event_service.CreateClientEventRequest.serialize, - response_deserializer=event.ClientEvent.deserialize, - ) - return self._stubs['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" - - -__all__ = ( - 'EventServiceGrpcTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py deleted file mode 100644 index 8cc3a7ba..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,289 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4beta1.types import event -from google.cloud.talent_v4beta1.types import event_service -from google.longrunning import operations_pb2 -from .base import EventServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import EventServiceGrpcTransport - - -class EventServiceGrpcAsyncIOTransport(EventServiceTransport): - """gRPC AsyncIO backend transport for EventService. - - A service handles client event report. - - 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_client_event(self) -> Callable[ - [event_service.CreateClientEventRequest], - Awaitable[event.ClientEvent]]: - r"""Return a callable for the create client event method over gRPC. - - Report events issued when end user interacts with customer's - application that uses Cloud Talent Solution. You may inspect the - created events in `self service - tools `__. - `Learn - more `__ - about self service tools. - - Returns: - Callable[[~.CreateClientEventRequest], - Awaitable[~.ClientEvent]]: - 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_client_event' not in self._stubs: - self._stubs['create_client_event'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.EventService/CreateClientEvent', - request_serializer=event_service.CreateClientEventRequest.serialize, - response_deserializer=event.ClientEvent.deserialize, - ) - return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/__init__.py deleted file mode 100644 index 3a5ccd23..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_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 .client import JobServiceClient -from .async_client import JobServiceAsyncClient - -__all__ = ( - 'JobServiceClient', - 'JobServiceAsyncClient', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/async_client.py deleted file mode 100644 index 574fa878..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/async_client.py +++ /dev/null @@ -1,1476 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.talent_v4beta1.services.job_service import pagers -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import job -from google.cloud.talent_v4beta1.types import job as gct_job -from google.cloud.talent_v4beta1.types import job_service -from google.longrunning import operations_pb2 -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport -from .client import JobServiceClient - - -class JobServiceAsyncClient: - """A service handles job management, including job CRUD, - enumeration and search. - """ - - _client: JobServiceClient - - DEFAULT_ENDPOINT = JobServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = JobServiceClient.DEFAULT_MTLS_ENDPOINT - - company_path = staticmethod(JobServiceClient.company_path) - parse_company_path = staticmethod(JobServiceClient.parse_company_path) - job_path = staticmethod(JobServiceClient.job_path) - parse_job_path = staticmethod(JobServiceClient.parse_job_path) - common_billing_account_path = staticmethod(JobServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(JobServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(JobServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(JobServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(JobServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(JobServiceClient.parse_common_organization_path) - common_project_path = staticmethod(JobServiceClient.common_project_path) - parse_common_project_path = staticmethod(JobServiceClient.parse_common_project_path) - common_location_path = staticmethod(JobServiceClient.common_location_path) - parse_common_location_path = staticmethod(JobServiceClient.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: - JobServiceAsyncClient: The constructed client. - """ - return JobServiceClient.from_service_account_info.__func__(JobServiceAsyncClient, 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: - JobServiceAsyncClient: The constructed client. - """ - return JobServiceClient.from_service_account_file.__func__(JobServiceAsyncClient, 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 JobServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> JobServiceTransport: - """Returns the transport used by the client instance. - - Returns: - JobServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(JobServiceClient).get_transport_class, type(JobServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, JobServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the job 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, ~.JobServiceTransport]): 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 = JobServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_job(self, - request: Union[job_service.CreateJobRequest, dict] = None, - *, - parent: str = None, - job: gct_job.Job = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_job.Job: - r"""Creates a new job. - Typically, the job becomes searchable within 10 seconds, - but it may take up to 5 minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_create_job(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - job = talent_v4beta1.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4beta1.CreateJobRequest( - parent="parent_value", - job=job, - ) - - # Make the request - response = await client.create_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateJobRequest, dict]): - The request object. Create job request. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - job (:class:`google.cloud.talent_v4beta1.types.Job`): - Required. The Job to be created. - This corresponds to the ``job`` 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.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4beta1.Company], which - is the hiring entity responsible for the job. - - """ - # 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, job]) - 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 = job_service.CreateJobRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if job is not None: - request.job = job - - # 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_job, - 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 batch_create_jobs(self, - request: Union[job_service.BatchCreateJobsRequest, dict] = None, - *, - parent: str = None, - jobs: Sequence[job.Job] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Begins executing a batch create jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_batch_create_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - jobs = talent_v4beta1.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4beta1.BatchCreateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_create_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.BatchCreateJobsRequest, dict]): - The request object. Request to create a batch of jobs. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - jobs (:class:`Sequence[google.cloud.talent_v4beta1.types.Job]`): - Required. The jobs to be created. - This corresponds to the ``jobs`` 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4beta1.types.JobOperationResult` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] or - [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] - APIs. It's used to replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, jobs]) - 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 = job_service.BatchCreateJobsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if jobs: - request.jobs.extend(jobs) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.batch_create_jobs, - 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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - job_service.JobOperationResult, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - async def get_job(self, - request: Union[job_service.GetJobRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> job.Job: - r"""Retrieves the specified job, whose status is OPEN or - recently EXPIRED within the last 90 days. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_get_job(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetJobRequest( - name="name_value", - ) - - # Make the request - response = await client.get_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetJobRequest, dict]): - The request object. Get job request. - name (:class:`str`): - Required. The resource name of the job to retrieve. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - If tenant id is unspecified, the default tenant is used. - For example, "projects/foo/jobs/bar". - - 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.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4beta1.Company], which - is the hiring entity responsible for the job. - - """ - # 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 = job_service.GetJobRequest(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_job, - 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_job(self, - request: Union[job_service.UpdateJobRequest, dict] = None, - *, - job: gct_job.Job = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_job.Job: - r"""Updates specified job. - Typically, updated contents become visible in search - results within 10 seconds, but it may take up to 5 - minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_update_job(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - job = talent_v4beta1.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4beta1.UpdateJobRequest( - job=job, - ) - - # Make the request - response = await client.update_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateJobRequest, dict]): - The request object. Update job request. - job (:class:`google.cloud.talent_v4beta1.types.Job`): - Required. The Job to be updated. - This corresponds to the ``job`` 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.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4beta1.Company], which - is the hiring entity responsible for the job. - - """ - # 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([job]) - 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 = job_service.UpdateJobRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if job is not None: - request.job = job - - # 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_job, - 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(( - ("job.name", request.job.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def batch_update_jobs(self, - request: Union[job_service.BatchUpdateJobsRequest, dict] = None, - *, - parent: str = None, - jobs: Sequence[job.Job] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Begins executing a batch update jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_batch_update_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - jobs = talent_v4beta1.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4beta1.BatchUpdateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_update_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.BatchUpdateJobsRequest, dict]): - The request object. Request to update a batch of jobs. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - jobs (:class:`Sequence[google.cloud.talent_v4beta1.types.Job]`): - Required. The jobs to be updated. - This corresponds to the ``jobs`` 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4beta1.types.JobOperationResult` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] or - [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] - APIs. It's used to replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, jobs]) - 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 = job_service.BatchUpdateJobsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if jobs: - request.jobs.extend(jobs) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.batch_update_jobs, - 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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - job_service.JobOperationResult, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_job(self, - request: Union[job_service.DeleteJobRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes the specified job. - Typically, the job becomes unsearchable within 10 - seconds, but it may take up to 5 minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_delete_job(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteJobRequest( - name="name_value", - ) - - # Make the request - await client.delete_job(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteJobRequest, dict]): - The request object. Delete job request. - name (:class:`str`): - Required. The resource name of the job to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - If tenant id is unspecified, the default tenant is used. - For example, "projects/foo/jobs/bar". - - 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 = job_service.DeleteJobRequest(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_job, - 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 batch_delete_jobs(self, - request: Union[job_service.BatchDeleteJobsRequest, dict] = None, - *, - parent: str = None, - filter: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by - filter. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_batch_delete_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.BatchDeleteJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - await client.batch_delete_jobs(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.BatchDeleteJobsRequest, dict]): - The request object. Batch delete jobs request. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - filter (:class:`str`): - Required. The filter string specifies the jobs to be - deleted. - - Supported operator: =, AND - - The fields eligible for filtering are: - - - ``companyName`` (Required) - - ``requisitionId`` (Required) - - Sample Query: companyName = "projects/foo/companies/bar" - AND requisitionId = "req-1" - - This corresponds to the ``filter`` 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([parent, filter]) - 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 = job_service.BatchDeleteJobsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if filter is not None: - request.filter = filter - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.batch_delete_jobs, - 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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def list_jobs(self, - request: Union[job_service.ListJobsRequest, dict] = None, - *, - parent: str = None, - filter: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListJobsAsyncPager: - r"""Lists jobs by filter. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_list_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - page_result = client.list_jobs(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListJobsRequest, dict]): - The request object. List jobs request. - parent (:class:`str`): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - filter (:class:`str`): - Required. The filter string specifies the jobs to be - enumerated. - - Supported operator: =, AND - - The fields eligible for filtering are: - - - ``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" - - requisitionId = "req-1" - - requisitionId = "req-1" AND status = "EXPIRED" - - This corresponds to the ``filter`` 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.job_service.pagers.ListJobsAsyncPager: - List jobs response. - 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, filter]) - 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 = job_service.ListJobsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if filter is not None: - request.filter = filter - - # 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_jobs, - 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.ListJobsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def search_jobs(self, - request: Union[job_service.SearchJobsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.SearchJobsAsyncPager: - r"""Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - - This call constrains the - [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs - present in the database, and only returns jobs that the caller - has permission to search against. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_search_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_jobs(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.SearchJobsRequest, dict]): - The request object. The Request body of the `SearchJobs` - 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.job_service.pagers.SearchJobsAsyncPager: - Response for SearchJob method. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = job_service.SearchJobsRequest(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_jobs, - 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.SearchJobsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def search_jobs_for_alert(self, - request: Union[job_service.SearchJobsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.SearchJobsForAlertAsyncPager: - r"""Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - - This API call is intended for the use case of targeting passive - job seekers (for example, job seekers who have signed up to - receive email alerts about potential job opportunities), and has - different algorithmic adjustments that are targeted to passive - job seekers. - - This call constrains the - [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs - present in the database, and only returns jobs the caller has - permission to search against. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_search_jobs_for_alert(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_jobs_for_alert(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.SearchJobsRequest, dict]): - The request object. The Request body of the `SearchJobs` - 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.job_service.pagers.SearchJobsForAlertAsyncPager: - Response for SearchJob method. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = job_service.SearchJobsRequest(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_jobs_for_alert, - 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.SearchJobsForAlertAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # 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 - - 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__ = ( - "JobServiceAsyncClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/client.py deleted file mode 100644 index c4105c09..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/client.py +++ /dev/null @@ -1,1668 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.talent_v4beta1.services.job_service import pagers -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import job -from google.cloud.talent_v4beta1.types import job as gct_job -from google.cloud.talent_v4beta1.types import job_service -from google.longrunning import operations_pb2 -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import JobServiceGrpcTransport -from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport - - -class JobServiceClientMeta(type): - """Metaclass for the JobService 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[JobServiceTransport]] - _transport_registry["grpc"] = JobServiceGrpcTransport - _transport_registry["grpc_asyncio"] = JobServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[JobServiceTransport]: - """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 JobServiceClient(metaclass=JobServiceClientMeta): - """A service handles job management, including job 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: - JobServiceClient: 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: - JobServiceClient: 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) -> JobServiceTransport: - """Returns the transport used by the client instance. - - Returns: - JobServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @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 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, JobServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the job 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, JobServiceTransport]): 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, JobServiceTransport): - # transport is a JobServiceTransport 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, - api_audience=client_options.api_audience, - ) - - def create_job(self, - request: Union[job_service.CreateJobRequest, dict] = None, - *, - parent: str = None, - job: gct_job.Job = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_job.Job: - r"""Creates a new job. - Typically, the job becomes searchable within 10 seconds, - but it may take up to 5 minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_create_job(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - job = talent_v4beta1.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4beta1.CreateJobRequest( - parent="parent_value", - job=job, - ) - - # Make the request - response = client.create_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateJobRequest, dict]): - The request object. Create job request. - parent (str): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - job (google.cloud.talent_v4beta1.types.Job): - Required. The Job to be created. - This corresponds to the ``job`` 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.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4beta1.Company], which - is the hiring entity responsible for the job. - - """ - # 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, job]) - 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 job_service.CreateJobRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.CreateJobRequest): - request = job_service.CreateJobRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if job is not None: - request.job = job - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_job] - - # 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 batch_create_jobs(self, - request: Union[job_service.BatchCreateJobsRequest, dict] = None, - *, - parent: str = None, - jobs: Sequence[job.Job] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Begins executing a batch create jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_batch_create_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - jobs = talent_v4beta1.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4beta1.BatchCreateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_create_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.BatchCreateJobsRequest, dict]): - The request object. Request to create a batch of jobs. - parent (str): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): - Required. The jobs to be created. - This corresponds to the ``jobs`` 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4beta1.types.JobOperationResult` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] or - [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] - APIs. It's used to replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, jobs]) - 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 job_service.BatchCreateJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.BatchCreateJobsRequest): - request = job_service.BatchCreateJobsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if jobs is not None: - request.jobs = jobs - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_create_jobs] - - # 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, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - job_service.JobOperationResult, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - def get_job(self, - request: Union[job_service.GetJobRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> job.Job: - r"""Retrieves the specified job, whose status is OPEN or - recently EXPIRED within the last 90 days. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_get_job(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetJobRequest( - name="name_value", - ) - - # Make the request - response = client.get_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetJobRequest, dict]): - The request object. Get job request. - name (str): - Required. The resource name of the job to retrieve. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - If tenant id is unspecified, the default tenant is used. - For example, "projects/foo/jobs/bar". - - 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.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4beta1.Company], which - is the hiring entity responsible for the job. - - """ - # 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 job_service.GetJobRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.GetJobRequest): - request = job_service.GetJobRequest(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_job] - - # 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_job(self, - request: Union[job_service.UpdateJobRequest, dict] = None, - *, - job: gct_job.Job = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_job.Job: - r"""Updates specified job. - Typically, updated contents become visible in search - results within 10 seconds, but it may take up to 5 - minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_update_job(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - job = talent_v4beta1.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4beta1.UpdateJobRequest( - job=job, - ) - - # Make the request - response = client.update_job(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateJobRequest, dict]): - The request object. Update job request. - job (google.cloud.talent_v4beta1.types.Job): - Required. The Job to be updated. - This corresponds to the ``job`` 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.Job: - A Job resource represents a job posting (also referred to as a "job listing" - or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4beta1.Company], which - is the hiring entity responsible for the job. - - """ - # 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([job]) - 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 job_service.UpdateJobRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.UpdateJobRequest): - request = job_service.UpdateJobRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if job is not None: - request.job = job - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_job] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("job.name", request.job.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def batch_update_jobs(self, - request: Union[job_service.BatchUpdateJobsRequest, dict] = None, - *, - parent: str = None, - jobs: Sequence[job.Job] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Begins executing a batch update jobs operation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_batch_update_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - jobs = talent_v4beta1.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4beta1.BatchUpdateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_update_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.BatchUpdateJobsRequest, dict]): - The request object. Request to update a batch of jobs. - parent (str): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): - Required. The jobs to be updated. - This corresponds to the ``jobs`` 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.talent_v4beta1.types.JobOperationResult` The result of [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] or - [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] - APIs. It's used to replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - """ - # 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, jobs]) - 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 job_service.BatchUpdateJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.BatchUpdateJobsRequest): - request = job_service.BatchUpdateJobsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if jobs is not None: - request.jobs = jobs - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_update_jobs] - - # 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, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - job_service.JobOperationResult, - metadata_type=common.BatchOperationMetadata, - ) - - # Done; return the response. - return response - - def delete_job(self, - request: Union[job_service.DeleteJobRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes the specified job. - Typically, the job becomes unsearchable within 10 - seconds, but it may take up to 5 minutes. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_delete_job(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteJobRequest( - name="name_value", - ) - - # Make the request - client.delete_job(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteJobRequest, dict]): - The request object. Delete job request. - name (str): - Required. The resource name of the job to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - If tenant id is unspecified, the default tenant is used. - For example, "projects/foo/jobs/bar". - - 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 job_service.DeleteJobRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.DeleteJobRequest): - request = job_service.DeleteJobRequest(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_job] - - # 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 batch_delete_jobs(self, - request: Union[job_service.BatchDeleteJobsRequest, dict] = None, - *, - parent: str = None, - filter: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by - filter. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_batch_delete_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.BatchDeleteJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - client.batch_delete_jobs(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.BatchDeleteJobsRequest, dict]): - The request object. Batch delete jobs request. - parent (str): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - filter (str): - Required. The filter string specifies the jobs to be - deleted. - - Supported operator: =, AND - - The fields eligible for filtering are: - - - ``companyName`` (Required) - - ``requisitionId`` (Required) - - Sample Query: companyName = "projects/foo/companies/bar" - AND requisitionId = "req-1" - - This corresponds to the ``filter`` 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([parent, filter]) - 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 job_service.BatchDeleteJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.BatchDeleteJobsRequest): - request = job_service.BatchDeleteJobsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if filter is not None: - request.filter = filter - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_delete_jobs] - - # 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. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def list_jobs(self, - request: Union[job_service.ListJobsRequest, dict] = None, - *, - parent: str = None, - filter: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListJobsPager: - r"""Lists jobs by filter. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_list_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - page_result = client.list_jobs(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListJobsRequest, dict]): - The request object. List jobs request. - parent (str): - Required. The resource name of the tenant under which - the job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}". For - example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - filter (str): - Required. The filter string specifies the jobs to be - enumerated. - - Supported operator: =, AND - - The fields eligible for filtering are: - - - ``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" - - requisitionId = "req-1" - - requisitionId = "req-1" AND status = "EXPIRED" - - This corresponds to the ``filter`` 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.job_service.pagers.ListJobsPager: - List jobs response. - 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, filter]) - 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 job_service.ListJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.ListJobsRequest): - request = job_service.ListJobsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if filter is not None: - request.filter = filter - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_jobs] - - # 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.ListJobsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def search_jobs(self, - request: Union[job_service.SearchJobsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.SearchJobsPager: - r"""Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - - This call constrains the - [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs - present in the database, and only returns jobs that the caller - has permission to search against. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_search_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_jobs(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.SearchJobsRequest, dict]): - The request object. The Request body of the `SearchJobs` - 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.job_service.pagers.SearchJobsPager: - Response for SearchJob 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 job_service.SearchJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.SearchJobsRequest): - request = job_service.SearchJobsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.search_jobs] - - # 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.SearchJobsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def search_jobs_for_alert(self, - request: Union[job_service.SearchJobsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.SearchJobsForAlertPager: - r"""Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - - This API call is intended for the use case of targeting passive - job seekers (for example, job seekers who have signed up to - receive email alerts about potential job opportunities), and has - different algorithmic adjustments that are targeted to passive - job seekers. - - This call constrains the - [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs - present in the database, and only returns jobs the caller has - permission to search against. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_search_jobs_for_alert(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_jobs_for_alert(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.SearchJobsRequest, dict]): - The request object. The Request body of the `SearchJobs` - 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.job_service.pagers.SearchJobsForAlertPager: - Response for SearchJob 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 job_service.SearchJobsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, job_service.SearchJobsRequest): - request = job_service.SearchJobsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.search_jobs_for_alert] - - # 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.SearchJobsForAlertPager( - 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() - - 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( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "JobServiceClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/pagers.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/pagers.py deleted file mode 100644 index ae70ac5b..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/pagers.py +++ /dev/null @@ -1,382 +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, Sequence, Tuple, Optional, Iterator - -from google.cloud.talent_v4beta1.types import job -from google.cloud.talent_v4beta1.types import job_service - - -class ListJobsPager: - """A pager for iterating through ``list_jobs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListJobsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``jobs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListJobs`` requests and continue to iterate - through the ``jobs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListJobsResponse` - 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[..., job_service.ListJobsResponse], - request: job_service.ListJobsRequest, - response: job_service.ListJobsResponse, - *, - 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.ListJobsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListJobsResponse): - 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 = job_service.ListJobsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[job_service.ListJobsResponse]: - 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[job.Job]: - for page in self.pages: - yield from page.jobs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListJobsAsyncPager: - """A pager for iterating through ``list_jobs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListJobsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``jobs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListJobs`` requests and continue to iterate - through the ``jobs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListJobsResponse` - 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[job_service.ListJobsResponse]], - request: job_service.ListJobsRequest, - response: job_service.ListJobsResponse, - *, - 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.ListJobsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListJobsResponse): - 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 = job_service.ListJobsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[job_service.ListJobsResponse]: - 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[job.Job]: - async def async_generator(): - async for page in self.pages: - for response in page.jobs: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class SearchJobsPager: - """A pager for iterating through ``search_jobs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``matching_jobs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``SearchJobs`` requests and continue to iterate - through the ``matching_jobs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` - 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[..., job_service.SearchJobsResponse], - request: job_service.SearchJobsRequest, - response: job_service.SearchJobsResponse, - *, - 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.SearchJobsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.SearchJobsResponse): - 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 = job_service.SearchJobsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[job_service.SearchJobsResponse]: - 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[job_service.SearchJobsResponse.MatchingJob]: - for page in self.pages: - yield from page.matching_jobs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class SearchJobsAsyncPager: - """A pager for iterating through ``search_jobs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``matching_jobs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``SearchJobs`` requests and continue to iterate - through the ``matching_jobs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` - 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[job_service.SearchJobsResponse]], - request: job_service.SearchJobsRequest, - response: job_service.SearchJobsResponse, - *, - 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.SearchJobsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.SearchJobsResponse): - 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 = job_service.SearchJobsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[job_service.SearchJobsResponse]: - 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[job_service.SearchJobsResponse.MatchingJob]: - async def async_generator(): - async for page in self.pages: - for response in page.matching_jobs: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class SearchJobsForAlertPager: - """A pager for iterating through ``search_jobs_for_alert`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``matching_jobs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``SearchJobsForAlert`` requests and continue to iterate - through the ``matching_jobs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` - 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[..., job_service.SearchJobsResponse], - request: job_service.SearchJobsRequest, - response: job_service.SearchJobsResponse, - *, - 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.SearchJobsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.SearchJobsResponse): - 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 = job_service.SearchJobsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[job_service.SearchJobsResponse]: - 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[job_service.SearchJobsResponse.MatchingJob]: - for page in self.pages: - yield from page.matching_jobs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class SearchJobsForAlertAsyncPager: - """A pager for iterating through ``search_jobs_for_alert`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``matching_jobs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``SearchJobsForAlert`` requests and continue to iterate - through the ``matching_jobs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.SearchJobsResponse` - 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[job_service.SearchJobsResponse]], - request: job_service.SearchJobsRequest, - response: job_service.SearchJobsResponse, - *, - 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.SearchJobsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.SearchJobsResponse): - 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 = job_service.SearchJobsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[job_service.SearchJobsResponse]: - 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[job_service.SearchJobsResponse.MatchingJob]: - async def async_generator(): - async for page in self.pages: - for response in page.matching_jobs: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py deleted file mode 100644 index 05345304..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py +++ /dev/null @@ -1,33 +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 JobServiceTransport -from .grpc import JobServiceGrpcTransport -from .grpc_asyncio import JobServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[JobServiceTransport]] -_transport_registry['grpc'] = JobServiceGrpcTransport -_transport_registry['grpc_asyncio'] = JobServiceGrpcAsyncIOTransport - -__all__ = ( - 'JobServiceTransport', - 'JobServiceGrpcTransport', - 'JobServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/base.py deleted file mode 100644 index 383fda71..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/base.py +++ /dev/null @@ -1,322 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4beta1.types import job -from google.cloud.talent_v4beta1.types import job as gct_job -from google.cloud.talent_v4beta1.types import job_service -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -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 JobServiceTransport(abc.ABC): - """Abstract transport class for JobService.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.create_job: gapic_v1.method.wrap_method( - self.create_job, - default_timeout=30.0, - client_info=client_info, - ), - self.batch_create_jobs: gapic_v1.method.wrap_method( - self.batch_create_jobs, - default_timeout=30.0, - client_info=client_info, - ), - self.get_job: gapic_v1.method.wrap_method( - self.get_job, - 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_job: gapic_v1.method.wrap_method( - self.update_job, - default_timeout=30.0, - client_info=client_info, - ), - self.batch_update_jobs: gapic_v1.method.wrap_method( - self.batch_update_jobs, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_job: gapic_v1.method.wrap_method( - self.delete_job, - 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.batch_delete_jobs: gapic_v1.method.wrap_method( - self.batch_delete_jobs, - default_timeout=30.0, - client_info=client_info, - ), - self.list_jobs: gapic_v1.method.wrap_method( - self.list_jobs, - 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_jobs: gapic_v1.method.wrap_method( - self.search_jobs, - default_timeout=30.0, - client_info=client_info, - ), - self.search_jobs_for_alert: gapic_v1.method.wrap_method( - self.search_jobs_for_alert, - 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 operations_client(self): - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def create_job(self) -> Callable[ - [job_service.CreateJobRequest], - Union[ - gct_job.Job, - Awaitable[gct_job.Job] - ]]: - raise NotImplementedError() - - @property - def batch_create_jobs(self) -> Callable[ - [job_service.BatchCreateJobsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_job(self) -> Callable[ - [job_service.GetJobRequest], - Union[ - job.Job, - Awaitable[job.Job] - ]]: - raise NotImplementedError() - - @property - def update_job(self) -> Callable[ - [job_service.UpdateJobRequest], - Union[ - gct_job.Job, - Awaitable[gct_job.Job] - ]]: - raise NotImplementedError() - - @property - def batch_update_jobs(self) -> Callable[ - [job_service.BatchUpdateJobsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_job(self) -> Callable[ - [job_service.DeleteJobRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def batch_delete_jobs(self) -> Callable[ - [job_service.BatchDeleteJobsRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_jobs(self) -> Callable[ - [job_service.ListJobsRequest], - Union[ - job_service.ListJobsResponse, - Awaitable[job_service.ListJobsResponse] - ]]: - raise NotImplementedError() - - @property - def search_jobs(self) -> Callable[ - [job_service.SearchJobsRequest], - Union[ - job_service.SearchJobsResponse, - Awaitable[job_service.SearchJobsResponse] - ]]: - raise NotImplementedError() - - @property - def search_jobs_for_alert(self) -> Callable[ - [job_service.SearchJobsRequest], - Union[ - job_service.SearchJobsResponse, - Awaitable[job_service.SearchJobsResponse] - ]]: - 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() - - -__all__ = ( - 'JobServiceTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py deleted file mode 100644 index e377d5ff..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py +++ /dev/null @@ -1,567 +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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4beta1.types import job -from google.cloud.talent_v4beta1.types import job as gct_job -from google.cloud.talent_v4beta1.types import job_service -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import JobServiceTransport, DEFAULT_CLIENT_INFO - - -class JobServiceGrpcTransport(JobServiceTransport): - """gRPC backend transport for JobService. - - A service handles job management, including job 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, - api_audience: Optional[str] = None, - ) -> 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] = {} - self._operations_client: Optional[operations_v1.OperationsClient] = None - - 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, - api_audience=api_audience, - ) - - 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 operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_job(self) -> Callable[ - [job_service.CreateJobRequest], - gct_job.Job]: - r"""Return a callable for the create job method over gRPC. - - Creates a new job. - Typically, the job becomes searchable within 10 seconds, - but it may take up to 5 minutes. - - Returns: - Callable[[~.CreateJobRequest], - ~.Job]: - 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_job' not in self._stubs: - self._stubs['create_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/CreateJob', - request_serializer=job_service.CreateJobRequest.serialize, - response_deserializer=gct_job.Job.deserialize, - ) - return self._stubs['create_job'] - - @property - def batch_create_jobs(self) -> Callable[ - [job_service.BatchCreateJobsRequest], - operations_pb2.Operation]: - r"""Return a callable for the batch create jobs method over gRPC. - - Begins executing a batch create jobs operation. - - Returns: - Callable[[~.BatchCreateJobsRequest], - ~.Operation]: - 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 'batch_create_jobs' not in self._stubs: - self._stubs['batch_create_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/BatchCreateJobs', - request_serializer=job_service.BatchCreateJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_create_jobs'] - - @property - def get_job(self) -> Callable[ - [job_service.GetJobRequest], - job.Job]: - r"""Return a callable for the get job method over gRPC. - - Retrieves the specified job, whose status is OPEN or - recently EXPIRED within the last 90 days. - - Returns: - Callable[[~.GetJobRequest], - ~.Job]: - 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_job' not in self._stubs: - self._stubs['get_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/GetJob', - request_serializer=job_service.GetJobRequest.serialize, - response_deserializer=job.Job.deserialize, - ) - return self._stubs['get_job'] - - @property - def update_job(self) -> Callable[ - [job_service.UpdateJobRequest], - gct_job.Job]: - r"""Return a callable for the update job method over gRPC. - - Updates specified job. - Typically, updated contents become visible in search - results within 10 seconds, but it may take up to 5 - minutes. - - Returns: - Callable[[~.UpdateJobRequest], - ~.Job]: - 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_job' not in self._stubs: - self._stubs['update_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/UpdateJob', - request_serializer=job_service.UpdateJobRequest.serialize, - response_deserializer=gct_job.Job.deserialize, - ) - return self._stubs['update_job'] - - @property - def batch_update_jobs(self) -> Callable[ - [job_service.BatchUpdateJobsRequest], - operations_pb2.Operation]: - r"""Return a callable for the batch update jobs method over gRPC. - - Begins executing a batch update jobs operation. - - Returns: - Callable[[~.BatchUpdateJobsRequest], - ~.Operation]: - 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 'batch_update_jobs' not in self._stubs: - self._stubs['batch_update_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/BatchUpdateJobs', - request_serializer=job_service.BatchUpdateJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_update_jobs'] - - @property - def delete_job(self) -> Callable[ - [job_service.DeleteJobRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete job method over gRPC. - - Deletes the specified job. - Typically, the job becomes unsearchable within 10 - seconds, but it may take up to 5 minutes. - - Returns: - Callable[[~.DeleteJobRequest], - ~.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_job' not in self._stubs: - self._stubs['delete_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/DeleteJob', - request_serializer=job_service.DeleteJobRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_job'] - - @property - def batch_delete_jobs(self) -> Callable[ - [job_service.BatchDeleteJobsRequest], - empty_pb2.Empty]: - r"""Return a callable for the batch delete jobs method over gRPC. - - Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by - filter. - - Returns: - Callable[[~.BatchDeleteJobsRequest], - ~.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 'batch_delete_jobs' not in self._stubs: - self._stubs['batch_delete_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/BatchDeleteJobs', - request_serializer=job_service.BatchDeleteJobsRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['batch_delete_jobs'] - - @property - def list_jobs(self) -> Callable[ - [job_service.ListJobsRequest], - job_service.ListJobsResponse]: - r"""Return a callable for the list jobs method over gRPC. - - Lists jobs by filter. - - Returns: - Callable[[~.ListJobsRequest], - ~.ListJobsResponse]: - 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_jobs' not in self._stubs: - self._stubs['list_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/ListJobs', - request_serializer=job_service.ListJobsRequest.serialize, - response_deserializer=job_service.ListJobsResponse.deserialize, - ) - return self._stubs['list_jobs'] - - @property - def search_jobs(self) -> Callable[ - [job_service.SearchJobsRequest], - job_service.SearchJobsResponse]: - r"""Return a callable for the search jobs method over gRPC. - - Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - - This call constrains the - [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs - present in the database, and only returns jobs that the caller - has permission to search against. - - Returns: - Callable[[~.SearchJobsRequest], - ~.SearchJobsResponse]: - 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_jobs' not in self._stubs: - self._stubs['search_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/SearchJobs', - request_serializer=job_service.SearchJobsRequest.serialize, - response_deserializer=job_service.SearchJobsResponse.deserialize, - ) - return self._stubs['search_jobs'] - - @property - def search_jobs_for_alert(self) -> Callable[ - [job_service.SearchJobsRequest], - job_service.SearchJobsResponse]: - r"""Return a callable for the search jobs for alert method over gRPC. - - Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - - This API call is intended for the use case of targeting passive - job seekers (for example, job seekers who have signed up to - receive email alerts about potential job opportunities), and has - different algorithmic adjustments that are targeted to passive - job seekers. - - This call constrains the - [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs - present in the database, and only returns jobs the caller has - permission to search against. - - Returns: - Callable[[~.SearchJobsRequest], - ~.SearchJobsResponse]: - 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_jobs_for_alert' not in self._stubs: - self._stubs['search_jobs_for_alert'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/SearchJobsForAlert', - request_serializer=job_service.SearchJobsRequest.serialize, - response_deserializer=job_service.SearchJobsResponse.deserialize, - ) - return self._stubs['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" - - -__all__ = ( - 'JobServiceGrpcTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py deleted file mode 100644 index fd10406e..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,566 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4beta1.types import job -from google.cloud.talent_v4beta1.types import job as gct_job -from google.cloud.talent_v4beta1.types import job_service -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import JobServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import JobServiceGrpcTransport - - -class JobServiceGrpcAsyncIOTransport(JobServiceTransport): - """gRPC AsyncIO backend transport for JobService. - - A service handles job management, including job 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, - api_audience: Optional[str] = None, - ) -> 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] = {} - self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None - - 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, - api_audience=api_audience, - ) - - 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 operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_job(self) -> Callable[ - [job_service.CreateJobRequest], - Awaitable[gct_job.Job]]: - r"""Return a callable for the create job method over gRPC. - - Creates a new job. - Typically, the job becomes searchable within 10 seconds, - but it may take up to 5 minutes. - - Returns: - Callable[[~.CreateJobRequest], - Awaitable[~.Job]]: - 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_job' not in self._stubs: - self._stubs['create_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/CreateJob', - request_serializer=job_service.CreateJobRequest.serialize, - response_deserializer=gct_job.Job.deserialize, - ) - return self._stubs['create_job'] - - @property - def batch_create_jobs(self) -> Callable[ - [job_service.BatchCreateJobsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the batch create jobs method over gRPC. - - Begins executing a batch create jobs operation. - - Returns: - Callable[[~.BatchCreateJobsRequest], - Awaitable[~.Operation]]: - 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 'batch_create_jobs' not in self._stubs: - self._stubs['batch_create_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/BatchCreateJobs', - request_serializer=job_service.BatchCreateJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_create_jobs'] - - @property - def get_job(self) -> Callable[ - [job_service.GetJobRequest], - Awaitable[job.Job]]: - r"""Return a callable for the get job method over gRPC. - - Retrieves the specified job, whose status is OPEN or - recently EXPIRED within the last 90 days. - - Returns: - Callable[[~.GetJobRequest], - Awaitable[~.Job]]: - 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_job' not in self._stubs: - self._stubs['get_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/GetJob', - request_serializer=job_service.GetJobRequest.serialize, - response_deserializer=job.Job.deserialize, - ) - return self._stubs['get_job'] - - @property - def update_job(self) -> Callable[ - [job_service.UpdateJobRequest], - Awaitable[gct_job.Job]]: - r"""Return a callable for the update job method over gRPC. - - Updates specified job. - Typically, updated contents become visible in search - results within 10 seconds, but it may take up to 5 - minutes. - - Returns: - Callable[[~.UpdateJobRequest], - Awaitable[~.Job]]: - 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_job' not in self._stubs: - self._stubs['update_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/UpdateJob', - request_serializer=job_service.UpdateJobRequest.serialize, - response_deserializer=gct_job.Job.deserialize, - ) - return self._stubs['update_job'] - - @property - def batch_update_jobs(self) -> Callable[ - [job_service.BatchUpdateJobsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the batch update jobs method over gRPC. - - Begins executing a batch update jobs operation. - - Returns: - Callable[[~.BatchUpdateJobsRequest], - Awaitable[~.Operation]]: - 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 'batch_update_jobs' not in self._stubs: - self._stubs['batch_update_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/BatchUpdateJobs', - request_serializer=job_service.BatchUpdateJobsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_update_jobs'] - - @property - def delete_job(self) -> Callable[ - [job_service.DeleteJobRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete job method over gRPC. - - Deletes the specified job. - Typically, the job becomes unsearchable within 10 - seconds, but it may take up to 5 minutes. - - Returns: - Callable[[~.DeleteJobRequest], - 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_job' not in self._stubs: - self._stubs['delete_job'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/DeleteJob', - request_serializer=job_service.DeleteJobRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_job'] - - @property - def batch_delete_jobs(self) -> Callable[ - [job_service.BatchDeleteJobsRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the batch delete jobs method over gRPC. - - Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by - filter. - - Returns: - Callable[[~.BatchDeleteJobsRequest], - 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 'batch_delete_jobs' not in self._stubs: - self._stubs['batch_delete_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/BatchDeleteJobs', - request_serializer=job_service.BatchDeleteJobsRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['batch_delete_jobs'] - - @property - def list_jobs(self) -> Callable[ - [job_service.ListJobsRequest], - Awaitable[job_service.ListJobsResponse]]: - r"""Return a callable for the list jobs method over gRPC. - - Lists jobs by filter. - - Returns: - Callable[[~.ListJobsRequest], - Awaitable[~.ListJobsResponse]]: - 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_jobs' not in self._stubs: - self._stubs['list_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/ListJobs', - request_serializer=job_service.ListJobsRequest.serialize, - response_deserializer=job_service.ListJobsResponse.deserialize, - ) - return self._stubs['list_jobs'] - - @property - def search_jobs(self) -> Callable[ - [job_service.SearchJobsRequest], - Awaitable[job_service.SearchJobsResponse]]: - r"""Return a callable for the search jobs method over gRPC. - - Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - - This call constrains the - [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs - present in the database, and only returns jobs that the caller - has permission to search against. - - Returns: - Callable[[~.SearchJobsRequest], - Awaitable[~.SearchJobsResponse]]: - 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_jobs' not in self._stubs: - self._stubs['search_jobs'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/SearchJobs', - request_serializer=job_service.SearchJobsRequest.serialize, - response_deserializer=job_service.SearchJobsResponse.deserialize, - ) - return self._stubs['search_jobs'] - - @property - def search_jobs_for_alert(self) -> Callable[ - [job_service.SearchJobsRequest], - Awaitable[job_service.SearchJobsResponse]]: - r"""Return a callable for the search jobs for alert method over gRPC. - - Searches for jobs using the provided - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - - This API call is intended for the use case of targeting passive - job seekers (for example, job seekers who have signed up to - receive email alerts about potential job opportunities), and has - different algorithmic adjustments that are targeted to passive - job seekers. - - This call constrains the - [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs - present in the database, and only returns jobs the caller has - permission to search against. - - Returns: - Callable[[~.SearchJobsRequest], - Awaitable[~.SearchJobsResponse]]: - 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_jobs_for_alert' not in self._stubs: - self._stubs['search_jobs_for_alert'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.JobService/SearchJobsForAlert', - request_serializer=job_service.SearchJobsRequest.serialize, - response_deserializer=job_service.SearchJobsResponse.deserialize, - ) - return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/__init__.py deleted file mode 100644 index 03b84ddf..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_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 .client import TenantServiceClient -from .async_client import TenantServiceAsyncClient - -__all__ = ( - 'TenantServiceClient', - 'TenantServiceAsyncClient', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/async_client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/async_client.py deleted file mode 100644 index 07a22384..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/async_client.py +++ /dev/null @@ -1,829 +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 -import pkg_resources - -from google.api_core.client_options import ClientOptions -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.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -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 -from google.cloud.talent_v4beta1.types import tenant_service -from google.longrunning import operations_pb2 -from .transports.base import TenantServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport -from .client import TenantServiceClient - - -class TenantServiceAsyncClient: - """A service that handles tenant management, including CRUD and - enumeration. - """ - - _client: TenantServiceClient - - DEFAULT_ENDPOINT = TenantServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = TenantServiceClient.DEFAULT_MTLS_ENDPOINT - - tenant_path = staticmethod(TenantServiceClient.tenant_path) - parse_tenant_path = staticmethod(TenantServiceClient.parse_tenant_path) - common_billing_account_path = staticmethod(TenantServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(TenantServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(TenantServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(TenantServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(TenantServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(TenantServiceClient.parse_common_organization_path) - common_project_path = staticmethod(TenantServiceClient.common_project_path) - parse_common_project_path = staticmethod(TenantServiceClient.parse_common_project_path) - common_location_path = staticmethod(TenantServiceClient.common_location_path) - parse_common_location_path = staticmethod(TenantServiceClient.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: - TenantServiceAsyncClient: The constructed client. - """ - return TenantServiceClient.from_service_account_info.__func__(TenantServiceAsyncClient, 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: - TenantServiceAsyncClient: The constructed client. - """ - return TenantServiceClient.from_service_account_file.__func__(TenantServiceAsyncClient, 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 TenantServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> TenantServiceTransport: - """Returns the transport used by the client instance. - - Returns: - TenantServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(TenantServiceClient).get_transport_class, type(TenantServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, TenantServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the tenant 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, ~.TenantServiceTransport]): 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 = TenantServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_tenant(self, - request: Union[tenant_service.CreateTenantRequest, dict] = None, - *, - parent: str = None, - tenant: gct_tenant.Tenant = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_tenant.Tenant: - r"""Creates a new tenant entity. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_create_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - tenant = talent_v4beta1.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4beta1.CreateTenantRequest( - parent="parent_value", - tenant=tenant, - ) - - # Make the request - response = await client.create_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateTenantRequest, dict]): - The request object. The Request of the CreateTenant - method. - parent (:class:`str`): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tenant (:class:`google.cloud.talent_v4beta1.types.Tenant`): - Required. The tenant to be created. - This corresponds to the ``tenant`` 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.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - profiles. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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, tenant]) - 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 = tenant_service.CreateTenantRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if tenant is not None: - request.tenant = tenant - - # 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_tenant, - 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_tenant(self, - request: Union[tenant_service.GetTenantRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> tenant.Tenant: - r"""Retrieves specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_get_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetTenantRequest( - name="name_value", - ) - - # Make the request - response = await client.get_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetTenantRequest, dict]): - The request object. Request for getting a tenant by - name. - name (:class:`str`): - Required. The resource name of the tenant to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenants/bar". - - 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.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - profiles. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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 = tenant_service.GetTenantRequest(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_tenant, - 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_tenant(self, - request: Union[tenant_service.UpdateTenantRequest, dict] = None, - *, - tenant: gct_tenant.Tenant = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_tenant.Tenant: - r"""Updates specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_update_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - tenant = talent_v4beta1.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4beta1.UpdateTenantRequest( - tenant=tenant, - ) - - # Make the request - response = await client.update_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateTenantRequest, dict]): - The request object. Request for updating a specified - tenant. - tenant (:class:`google.cloud.talent_v4beta1.types.Tenant`): - Required. The tenant resource to - replace the current resource in the - system. - - This corresponds to the ``tenant`` 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.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - profiles. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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([tenant]) - 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 = tenant_service.UpdateTenantRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if tenant is not None: - request.tenant = tenant - - # 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_tenant, - 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(( - ("tenant.name", request.tenant.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_tenant(self, - request: Union[tenant_service.DeleteTenantRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_delete_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteTenantRequest( - name="name_value", - ) - - # Make the request - await client.delete_tenant(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteTenantRequest, dict]): - The request object. Request to delete a tenant. - name (:class:`str`): - Required. The resource name of the tenant to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenants/bar". - - 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 = tenant_service.DeleteTenantRequest(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_tenant, - 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_tenants(self, - request: Union[tenant_service.ListTenantsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTenantsAsyncPager: - r"""Lists all tenants associated with the project. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - async def sample_list_tenants(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListTenantsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_tenants(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListTenantsRequest, dict]): - The request object. List tenants for which the client - has ACL visibility. - parent (:class:`str`): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - - 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.tenant_service.pagers.ListTenantsAsyncPager: - The List tenants 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 = tenant_service.ListTenantsRequest(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_tenants, - 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.ListTenantsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # 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 - - 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__ = ( - "TenantServiceAsyncClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/client.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/client.py deleted file mode 100644 index 0e971a2e..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/client.py +++ /dev/null @@ -1,1010 +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 -import pkg_resources - -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.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -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 -from google.cloud.talent_v4beta1.types import tenant_service -from google.longrunning import operations_pb2 -from .transports.base import TenantServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import TenantServiceGrpcTransport -from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport - - -class TenantServiceClientMeta(type): - """Metaclass for the TenantService 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[TenantServiceTransport]] - _transport_registry["grpc"] = TenantServiceGrpcTransport - _transport_registry["grpc_asyncio"] = TenantServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[TenantServiceTransport]: - """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 TenantServiceClient(metaclass=TenantServiceClientMeta): - """A service that handles tenant 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: - TenantServiceClient: 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: - TenantServiceClient: 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) -> TenantServiceTransport: - """Returns the transport used by the client instance. - - Returns: - TenantServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @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, TenantServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the tenant 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, TenantServiceTransport]): 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, TenantServiceTransport): - # transport is a TenantServiceTransport 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, - api_audience=client_options.api_audience, - ) - - def create_tenant(self, - request: Union[tenant_service.CreateTenantRequest, dict] = None, - *, - parent: str = None, - tenant: gct_tenant.Tenant = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_tenant.Tenant: - r"""Creates a new tenant entity. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_create_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - tenant = talent_v4beta1.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4beta1.CreateTenantRequest( - parent="parent_value", - tenant=tenant, - ) - - # Make the request - response = client.create_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.CreateTenantRequest, dict]): - The request object. The Request of the CreateTenant - method. - parent (str): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tenant (google.cloud.talent_v4beta1.types.Tenant): - Required. The tenant to be created. - This corresponds to the ``tenant`` 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.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - profiles. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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, tenant]) - 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 tenant_service.CreateTenantRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.CreateTenantRequest): - request = tenant_service.CreateTenantRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if tenant is not None: - request.tenant = tenant - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_tenant] - - # 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_tenant(self, - request: Union[tenant_service.GetTenantRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> tenant.Tenant: - r"""Retrieves specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_get_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetTenantRequest( - name="name_value", - ) - - # Make the request - response = client.get_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.GetTenantRequest, dict]): - The request object. Request for getting a tenant by - name. - name (str): - Required. The resource name of the tenant to be - retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenants/bar". - - 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.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - profiles. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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 tenant_service.GetTenantRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.GetTenantRequest): - request = tenant_service.GetTenantRequest(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_tenant] - - # 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_tenant(self, - request: Union[tenant_service.UpdateTenantRequest, dict] = None, - *, - tenant: gct_tenant.Tenant = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gct_tenant.Tenant: - r"""Updates specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_update_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - tenant = talent_v4beta1.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4beta1.UpdateTenantRequest( - tenant=tenant, - ) - - # Make the request - response = client.update_tenant(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.UpdateTenantRequest, dict]): - The request object. Request for updating a specified - tenant. - tenant (google.cloud.talent_v4beta1.types.Tenant): - Required. The tenant resource to - replace the current resource in the - system. - - This corresponds to the ``tenant`` 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.Tenant: - A Tenant resource represents a tenant - in the service. A tenant is a group or - entity that shares common access with - specific privileges for resources like - profiles. Customer may create multiple - tenants to provide data isolation for - different groups. - - """ - # 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([tenant]) - 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 tenant_service.UpdateTenantRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.UpdateTenantRequest): - request = tenant_service.UpdateTenantRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if tenant is not None: - request.tenant = tenant - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_tenant] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("tenant.name", request.tenant.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_tenant(self, - request: Union[tenant_service.DeleteTenantRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes specified tenant. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_delete_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteTenantRequest( - name="name_value", - ) - - # Make the request - client.delete_tenant(request=request) - - Args: - request (Union[google.cloud.talent_v4beta1.types.DeleteTenantRequest, dict]): - The request object. Request to delete a tenant. - name (str): - Required. The resource name of the tenant to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}", for - example, "projects/foo/tenants/bar". - - 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 tenant_service.DeleteTenantRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.DeleteTenantRequest): - request = tenant_service.DeleteTenantRequest(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_tenant] - - # 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_tenants(self, - request: Union[tenant_service.ListTenantsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTenantsPager: - r"""Lists all tenants associated with the project. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import talent_v4beta1 - - def sample_list_tenants(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListTenantsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_tenants(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.talent_v4beta1.types.ListTenantsRequest, dict]): - The request object. List tenants for which the client - has ACL visibility. - parent (str): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - - 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.tenant_service.pagers.ListTenantsPager: - The List tenants 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 tenant_service.ListTenantsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, tenant_service.ListTenantsRequest): - request = tenant_service.ListTenantsRequest(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_tenants] - - # 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.ListTenantsPager( - 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() - - 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( - gapic_version=pkg_resources.get_distribution( - "google-cloud-talent", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "TenantServiceClient", -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/pagers.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/pagers.py deleted file mode 100644 index a130d1f4..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/pagers.py +++ /dev/null @@ -1,140 +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, Sequence, Tuple, Optional, Iterator - -from google.cloud.talent_v4beta1.types import tenant -from google.cloud.talent_v4beta1.types import tenant_service - - -class ListTenantsPager: - """A pager for iterating through ``list_tenants`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListTenantsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``tenants`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListTenants`` requests and continue to iterate - through the ``tenants`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListTenantsResponse` - 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[..., tenant_service.ListTenantsResponse], - request: tenant_service.ListTenantsRequest, - response: tenant_service.ListTenantsResponse, - *, - 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.ListTenantsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListTenantsResponse): - 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 = tenant_service.ListTenantsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[tenant_service.ListTenantsResponse]: - 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[tenant.Tenant]: - for page in self.pages: - yield from page.tenants - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTenantsAsyncPager: - """A pager for iterating through ``list_tenants`` requests. - - This class thinly wraps an initial - :class:`google.cloud.talent_v4beta1.types.ListTenantsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``tenants`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListTenants`` requests and continue to iterate - through the ``tenants`` field on the - corresponding responses. - - All the usual :class:`google.cloud.talent_v4beta1.types.ListTenantsResponse` - 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[tenant_service.ListTenantsResponse]], - request: tenant_service.ListTenantsRequest, - response: tenant_service.ListTenantsResponse, - *, - 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.ListTenantsRequest): - The initial request object. - response (google.cloud.talent_v4beta1.types.ListTenantsResponse): - 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 = tenant_service.ListTenantsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[tenant_service.ListTenantsResponse]: - 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[tenant.Tenant]: - async def async_generator(): - async for page in self.pages: - for response in page.tenants: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py deleted file mode 100644 index 59edc02c..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py +++ /dev/null @@ -1,33 +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 TenantServiceTransport -from .grpc import TenantServiceGrpcTransport -from .grpc_asyncio import TenantServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[TenantServiceTransport]] -_transport_registry['grpc'] = TenantServiceGrpcTransport -_transport_registry['grpc_asyncio'] = TenantServiceGrpcAsyncIOTransport - -__all__ = ( - 'TenantServiceTransport', - 'TenantServiceGrpcTransport', - 'TenantServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py deleted file mode 100644 index 2c972f1e..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py +++ /dev/null @@ -1,245 +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 pkg_resources - -import google.auth # type: ignore -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 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.talent_v4beta1.types import tenant -from google.cloud.talent_v4beta1.types import tenant as gct_tenant -from google.cloud.talent_v4beta1.types import tenant_service -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -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 TenantServiceTransport(abc.ABC): - """Abstract transport class for TenantService.""" - - 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, - api_audience: Optional[str] = None, - **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. - """ - - 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) - # 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 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 - - # 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 = { - self.create_tenant: gapic_v1.method.wrap_method( - self.create_tenant, - default_timeout=30.0, - client_info=client_info, - ), - self.get_tenant: gapic_v1.method.wrap_method( - self.get_tenant, - 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_tenant: gapic_v1.method.wrap_method( - self.update_tenant, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_tenant: gapic_v1.method.wrap_method( - self.delete_tenant, - 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_tenants: gapic_v1.method.wrap_method( - self.list_tenants, - 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_tenant(self) -> Callable[ - [tenant_service.CreateTenantRequest], - Union[ - gct_tenant.Tenant, - Awaitable[gct_tenant.Tenant] - ]]: - raise NotImplementedError() - - @property - def get_tenant(self) -> Callable[ - [tenant_service.GetTenantRequest], - Union[ - tenant.Tenant, - Awaitable[tenant.Tenant] - ]]: - raise NotImplementedError() - - @property - def update_tenant(self) -> Callable[ - [tenant_service.UpdateTenantRequest], - Union[ - gct_tenant.Tenant, - Awaitable[gct_tenant.Tenant] - ]]: - raise NotImplementedError() - - @property - def delete_tenant(self) -> Callable[ - [tenant_service.DeleteTenantRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_tenants(self) -> Callable[ - [tenant_service.ListTenantsRequest], - Union[ - tenant_service.ListTenantsResponse, - Awaitable[tenant_service.ListTenantsResponse] - ]]: - 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() - - -__all__ = ( - 'TenantServiceTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py deleted file mode 100644 index 89f69c3a..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py +++ /dev/null @@ -1,391 +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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.talent_v4beta1.types import tenant -from google.cloud.talent_v4beta1.types import tenant as gct_tenant -from google.cloud.talent_v4beta1.types import tenant_service -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import TenantServiceTransport, DEFAULT_CLIENT_INFO - - -class TenantServiceGrpcTransport(TenantServiceTransport): - """gRPC backend transport for TenantService. - - A service that handles tenant 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_tenant(self) -> Callable[ - [tenant_service.CreateTenantRequest], - gct_tenant.Tenant]: - r"""Return a callable for the create tenant method over gRPC. - - Creates a new tenant entity. - - Returns: - Callable[[~.CreateTenantRequest], - ~.Tenant]: - 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_tenant' not in self._stubs: - self._stubs['create_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/CreateTenant', - request_serializer=tenant_service.CreateTenantRequest.serialize, - response_deserializer=gct_tenant.Tenant.deserialize, - ) - return self._stubs['create_tenant'] - - @property - def get_tenant(self) -> Callable[ - [tenant_service.GetTenantRequest], - tenant.Tenant]: - r"""Return a callable for the get tenant method over gRPC. - - Retrieves specified tenant. - - Returns: - Callable[[~.GetTenantRequest], - ~.Tenant]: - 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_tenant' not in self._stubs: - self._stubs['get_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/GetTenant', - request_serializer=tenant_service.GetTenantRequest.serialize, - response_deserializer=tenant.Tenant.deserialize, - ) - return self._stubs['get_tenant'] - - @property - def update_tenant(self) -> Callable[ - [tenant_service.UpdateTenantRequest], - gct_tenant.Tenant]: - r"""Return a callable for the update tenant method over gRPC. - - Updates specified tenant. - - Returns: - Callable[[~.UpdateTenantRequest], - ~.Tenant]: - 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_tenant' not in self._stubs: - self._stubs['update_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/UpdateTenant', - request_serializer=tenant_service.UpdateTenantRequest.serialize, - response_deserializer=gct_tenant.Tenant.deserialize, - ) - return self._stubs['update_tenant'] - - @property - def delete_tenant(self) -> Callable[ - [tenant_service.DeleteTenantRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete tenant method over gRPC. - - Deletes specified tenant. - - Returns: - Callable[[~.DeleteTenantRequest], - ~.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_tenant' not in self._stubs: - self._stubs['delete_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/DeleteTenant', - request_serializer=tenant_service.DeleteTenantRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_tenant'] - - @property - def list_tenants(self) -> Callable[ - [tenant_service.ListTenantsRequest], - tenant_service.ListTenantsResponse]: - r"""Return a callable for the list tenants method over gRPC. - - Lists all tenants associated with the project. - - Returns: - Callable[[~.ListTenantsRequest], - ~.ListTenantsResponse]: - 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_tenants' not in self._stubs: - self._stubs['list_tenants'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/ListTenants', - request_serializer=tenant_service.ListTenantsRequest.serialize, - response_deserializer=tenant_service.ListTenantsResponse.deserialize, - ) - return self._stubs['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" - - -__all__ = ( - 'TenantServiceGrpcTransport', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py deleted file mode 100644 index 826d2a17..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,390 +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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.talent_v4beta1.types import tenant -from google.cloud.talent_v4beta1.types import tenant as gct_tenant -from google.cloud.talent_v4beta1.types import tenant_service -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import TenantServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import TenantServiceGrpcTransport - - -class TenantServiceGrpcAsyncIOTransport(TenantServiceTransport): - """gRPC AsyncIO backend transport for TenantService. - - A service that handles tenant 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, - api_audience: Optional[str] = None, - ) -> 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, - api_audience=api_audience, - ) - - 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_tenant(self) -> Callable[ - [tenant_service.CreateTenantRequest], - Awaitable[gct_tenant.Tenant]]: - r"""Return a callable for the create tenant method over gRPC. - - Creates a new tenant entity. - - Returns: - Callable[[~.CreateTenantRequest], - Awaitable[~.Tenant]]: - 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_tenant' not in self._stubs: - self._stubs['create_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/CreateTenant', - request_serializer=tenant_service.CreateTenantRequest.serialize, - response_deserializer=gct_tenant.Tenant.deserialize, - ) - return self._stubs['create_tenant'] - - @property - def get_tenant(self) -> Callable[ - [tenant_service.GetTenantRequest], - Awaitable[tenant.Tenant]]: - r"""Return a callable for the get tenant method over gRPC. - - Retrieves specified tenant. - - Returns: - Callable[[~.GetTenantRequest], - Awaitable[~.Tenant]]: - 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_tenant' not in self._stubs: - self._stubs['get_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/GetTenant', - request_serializer=tenant_service.GetTenantRequest.serialize, - response_deserializer=tenant.Tenant.deserialize, - ) - return self._stubs['get_tenant'] - - @property - def update_tenant(self) -> Callable[ - [tenant_service.UpdateTenantRequest], - Awaitable[gct_tenant.Tenant]]: - r"""Return a callable for the update tenant method over gRPC. - - Updates specified tenant. - - Returns: - Callable[[~.UpdateTenantRequest], - Awaitable[~.Tenant]]: - 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_tenant' not in self._stubs: - self._stubs['update_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/UpdateTenant', - request_serializer=tenant_service.UpdateTenantRequest.serialize, - response_deserializer=gct_tenant.Tenant.deserialize, - ) - return self._stubs['update_tenant'] - - @property - def delete_tenant(self) -> Callable[ - [tenant_service.DeleteTenantRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete tenant method over gRPC. - - Deletes specified tenant. - - Returns: - Callable[[~.DeleteTenantRequest], - 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_tenant' not in self._stubs: - self._stubs['delete_tenant'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/DeleteTenant', - request_serializer=tenant_service.DeleteTenantRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_tenant'] - - @property - def list_tenants(self) -> Callable[ - [tenant_service.ListTenantsRequest], - Awaitable[tenant_service.ListTenantsResponse]]: - r"""Return a callable for the list tenants method over gRPC. - - Lists all tenants associated with the project. - - Returns: - Callable[[~.ListTenantsRequest], - Awaitable[~.ListTenantsResponse]]: - 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_tenants' not in self._stubs: - self._stubs['list_tenants'] = self.grpc_channel.unary_unary( - '/google.cloud.talent.v4beta1.TenantService/ListTenants', - request_serializer=tenant_service.ListTenantsRequest.serialize, - response_deserializer=tenant_service.ListTenantsResponse.deserialize, - ) - return self._stubs['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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/__init__.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/__init__.py deleted file mode 100644 index bf3c4eac..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/__init__.py +++ /dev/null @@ -1,158 +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 .common import ( - BatchOperationMetadata, - CompensationInfo, - CustomAttribute, - DeviceInfo, - Location, - RequestMetadata, - ResponseMetadata, - SpellingCorrection, - TimestampRange, - CommuteMethod, - CompanySize, - DegreeType, - EmploymentType, - HtmlSanitization, - JobBenefit, - JobCategory, - JobLevel, - PostingRegion, - Visibility, -) -from .company import ( - Company, -) -from .company_service import ( - CreateCompanyRequest, - DeleteCompanyRequest, - GetCompanyRequest, - ListCompaniesRequest, - ListCompaniesResponse, - UpdateCompanyRequest, -) -from .completion_service import ( - CompleteQueryRequest, - CompleteQueryResponse, -) -from .event import ( - ClientEvent, - JobEvent, -) -from .event_service import ( - CreateClientEventRequest, -) -from .filters import ( - CommuteFilter, - CompensationFilter, - JobQuery, - LocationFilter, -) -from .histogram import ( - HistogramQuery, - HistogramQueryResult, -) -from .job import ( - Job, -) -from .job_service import ( - BatchCreateJobsRequest, - BatchDeleteJobsRequest, - BatchUpdateJobsRequest, - CreateJobRequest, - DeleteJobRequest, - GetJobRequest, - JobOperationResult, - ListJobsRequest, - ListJobsResponse, - SearchJobsRequest, - SearchJobsResponse, - UpdateJobRequest, - JobView, -) -from .tenant import ( - Tenant, -) -from .tenant_service import ( - CreateTenantRequest, - DeleteTenantRequest, - GetTenantRequest, - ListTenantsRequest, - ListTenantsResponse, - UpdateTenantRequest, -) - -__all__ = ( - 'BatchOperationMetadata', - 'CompensationInfo', - 'CustomAttribute', - 'DeviceInfo', - 'Location', - 'RequestMetadata', - 'ResponseMetadata', - 'SpellingCorrection', - 'TimestampRange', - 'CommuteMethod', - 'CompanySize', - 'DegreeType', - 'EmploymentType', - 'HtmlSanitization', - 'JobBenefit', - 'JobCategory', - 'JobLevel', - 'PostingRegion', - 'Visibility', - 'Company', - 'CreateCompanyRequest', - 'DeleteCompanyRequest', - 'GetCompanyRequest', - 'ListCompaniesRequest', - 'ListCompaniesResponse', - 'UpdateCompanyRequest', - 'CompleteQueryRequest', - 'CompleteQueryResponse', - 'ClientEvent', - 'JobEvent', - 'CreateClientEventRequest', - 'CommuteFilter', - 'CompensationFilter', - 'JobQuery', - 'LocationFilter', - 'HistogramQuery', - 'HistogramQueryResult', - 'Job', - 'BatchCreateJobsRequest', - 'BatchDeleteJobsRequest', - 'BatchUpdateJobsRequest', - 'CreateJobRequest', - 'DeleteJobRequest', - 'GetJobRequest', - 'JobOperationResult', - 'ListJobsRequest', - 'ListJobsResponse', - 'SearchJobsRequest', - 'SearchJobsResponse', - 'UpdateJobRequest', - 'JobView', - 'Tenant', - 'CreateTenantRequest', - 'DeleteTenantRequest', - 'GetTenantRequest', - 'ListTenantsRequest', - 'ListTenantsResponse', - 'UpdateTenantRequest', -) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/batch.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/batch.py deleted file mode 100644 index 160692d0..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/batch.py +++ /dev/null @@ -1,25 +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. -# - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - }, -) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/common.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/common.py deleted file mode 100644 index 247003ff..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/common.py +++ /dev/null @@ -1,846 +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 proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_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 - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'CompanySize', - 'JobBenefit', - 'DegreeType', - 'EmploymentType', - 'JobLevel', - 'JobCategory', - 'PostingRegion', - 'Visibility', - 'HtmlSanitization', - 'CommuteMethod', - 'TimestampRange', - 'Location', - 'RequestMetadata', - 'ResponseMetadata', - 'DeviceInfo', - 'CustomAttribute', - 'SpellingCorrection', - 'CompensationInfo', - 'BatchOperationMetadata', - }, -) - - -class CompanySize(proto.Enum): - r"""An enum that represents the size of the company.""" - COMPANY_SIZE_UNSPECIFIED = 0 - MINI = 1 - SMALL = 2 - SMEDIUM = 3 - MEDIUM = 4 - BIG = 5 - BIGGER = 6 - GIANT = 7 - - -class JobBenefit(proto.Enum): - r"""An enum that represents employee benefits included with the - job. - """ - JOB_BENEFIT_UNSPECIFIED = 0 - CHILD_CARE = 1 - DENTAL = 2 - DOMESTIC_PARTNER = 3 - FLEXIBLE_HOURS = 4 - MEDICAL = 5 - LIFE_INSURANCE = 6 - PARENTAL_LEAVE = 7 - RETIREMENT_PLAN = 8 - SICK_DAYS = 9 - VACATION = 10 - VISION = 11 - - -class DegreeType(proto.Enum): - r"""Educational degree level defined in International Standard - Classification of Education (ISCED). - """ - DEGREE_TYPE_UNSPECIFIED = 0 - PRIMARY_EDUCATION = 1 - LOWER_SECONDARY_EDUCATION = 2 - UPPER_SECONDARY_EDUCATION = 3 - ADULT_REMEDIAL_EDUCATION = 4 - ASSOCIATES_OR_EQUIVALENT = 5 - BACHELORS_OR_EQUIVALENT = 6 - MASTERS_OR_EQUIVALENT = 7 - DOCTORAL_OR_EQUIVALENT = 8 - - -class EmploymentType(proto.Enum): - r"""An enum that represents the employment type of a job.""" - EMPLOYMENT_TYPE_UNSPECIFIED = 0 - FULL_TIME = 1 - PART_TIME = 2 - CONTRACTOR = 3 - CONTRACT_TO_HIRE = 4 - TEMPORARY = 5 - INTERN = 6 - VOLUNTEER = 7 - PER_DIEM = 8 - FLY_IN_FLY_OUT = 9 - OTHER_EMPLOYMENT_TYPE = 10 - - -class JobLevel(proto.Enum): - r"""An enum that represents the required experience level - required for the job. - """ - JOB_LEVEL_UNSPECIFIED = 0 - ENTRY_LEVEL = 1 - EXPERIENCED = 2 - MANAGER = 3 - DIRECTOR = 4 - EXECUTIVE = 5 - - -class JobCategory(proto.Enum): - r"""An enum that represents the categorization or primary focus - of specific role. This value is different than the "industry" - associated with a role, which is related to the categorization - of the company listing the job. - """ - JOB_CATEGORY_UNSPECIFIED = 0 - ACCOUNTING_AND_FINANCE = 1 - ADMINISTRATIVE_AND_OFFICE = 2 - ADVERTISING_AND_MARKETING = 3 - ANIMAL_CARE = 4 - ART_FASHION_AND_DESIGN = 5 - BUSINESS_OPERATIONS = 6 - CLEANING_AND_FACILITIES = 7 - COMPUTER_AND_IT = 8 - CONSTRUCTION = 9 - CUSTOMER_SERVICE = 10 - EDUCATION = 11 - ENTERTAINMENT_AND_TRAVEL = 12 - FARMING_AND_OUTDOORS = 13 - HEALTHCARE = 14 - HUMAN_RESOURCES = 15 - INSTALLATION_MAINTENANCE_AND_REPAIR = 16 - LEGAL = 17 - MANAGEMENT = 18 - MANUFACTURING_AND_WAREHOUSE = 19 - MEDIA_COMMUNICATIONS_AND_WRITING = 20 - OIL_GAS_AND_MINING = 21 - PERSONAL_CARE_AND_SERVICES = 22 - PROTECTIVE_SERVICES = 23 - REAL_ESTATE = 24 - RESTAURANT_AND_HOSPITALITY = 25 - SALES_AND_RETAIL = 26 - SCIENCE_AND_ENGINEERING = 27 - SOCIAL_SERVICES_AND_NON_PROFIT = 28 - SPORTS_FITNESS_AND_RECREATION = 29 - TRANSPORTATION_AND_LOGISTICS = 30 - - -class PostingRegion(proto.Enum): - r"""An enum that represents the job posting region. In most - cases, job postings don't need to specify a region. If a region - is given, jobs are eligible for searches in the specified - region. - """ - POSTING_REGION_UNSPECIFIED = 0 - ADMINISTRATIVE_AREA = 1 - NATION = 2 - TELECOMMUTE = 3 - - -class Visibility(proto.Enum): - r"""Deprecated. All resources are only visible to the owner. - An enum that represents who has view access to the resource. - """ - _pb_options = {'deprecated': True} - VISIBILITY_UNSPECIFIED = 0 - ACCOUNT_ONLY = 1 - SHARED_WITH_GOOGLE = 2 - SHARED_WITH_PUBLIC = 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 - determine whether and how sanitization is performed on these - fields. - """ - HTML_SANITIZATION_UNSPECIFIED = 0 - HTML_SANITIZATION_DISABLED = 1 - SIMPLE_FORMATTING_ONLY = 2 - - -class CommuteMethod(proto.Enum): - r"""Method for commute.""" - COMMUTE_METHOD_UNSPECIFIED = 0 - DRIVING = 1 - TRANSIT = 2 - WALKING = 3 - CYCLING = 4 - - -class TimestampRange(proto.Message): - r"""Message representing a period of time between two timestamps. - - Attributes: - start_time (google.protobuf.timestamp_pb2.Timestamp): - Begin of the period (inclusive). - end_time (google.protobuf.timestamp_pb2.Timestamp): - End of the period (exclusive). - """ - - start_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - - -class Location(proto.Message): - r"""A resource that represents a location with full geographic - information. - - Attributes: - location_type (google.cloud.talent_v4beta1.types.Location.LocationType): - The type of a location, which corresponds to the address - lines field of - [google.type.PostalAddress][google.type.PostalAddress]. For - example, "Downtown, Atlanta, GA, USA" has a type of - [LocationType.NEIGHBORHOOD][google.cloud.talent.v4beta1.Location.LocationType.NEIGHBORHOOD], - and "Kansas City, KS, USA" has a type of - [LocationType.LOCALITY][google.cloud.talent.v4beta1.Location.LocationType.LOCALITY]. - postal_address (google.type.postal_address_pb2.PostalAddress): - Postal address of the location that includes - human readable information, such as postal - delivery and payments addresses. Given a postal - address, a postal service can deliver items to a - premises, P.O. Box, or other delivery location. - lat_lng (google.type.latlng_pb2.LatLng): - An object representing a latitude/longitude - pair. - radius_miles (float): - Radius in miles of the job location. This value is derived - from the location bounding box in which a circle with the - specified radius centered from - [google.type.LatLng][google.type.LatLng] covers the area - associated with the job location. For example, currently, - "Mountain View, CA, USA" has a radius of 6.17 miles. - """ - class LocationType(proto.Enum): - r"""An enum which represents the type of a location.""" - LOCATION_TYPE_UNSPECIFIED = 0 - COUNTRY = 1 - ADMINISTRATIVE_AREA = 2 - SUB_ADMINISTRATIVE_AREA = 3 - LOCALITY = 4 - POSTAL_CODE = 5 - SUB_LOCALITY = 6 - SUB_LOCALITY_1 = 7 - SUB_LOCALITY_2 = 8 - NEIGHBORHOOD = 9 - STREET_ADDRESS = 10 - - location_type = proto.Field( - proto.ENUM, - number=1, - enum=LocationType, - ) - postal_address = proto.Field( - proto.MESSAGE, - number=2, - message=postal_address_pb2.PostalAddress, - ) - lat_lng = proto.Field( - proto.MESSAGE, - number=3, - message=latlng_pb2.LatLng, - ) - radius_miles = proto.Field( - proto.DOUBLE, - number=4, - ) - - -class RequestMetadata(proto.Message): - r"""Meta information related to the job searcher or entity - conducting the job search. This information is used to improve - the performance of the service. - - Attributes: - domain (str): - Required if - [allow_missing_ids][google.cloud.talent.v4beta1.RequestMetadata.allow_missing_ids] - is unset or ``false``. - - The client-defined scope or source of the service call, - which typically is the domain on which the service has been - implemented and is currently being run. - - For example, if the service is being run by client Foo, - Inc., on job board www.foo.com and career site www.bar.com, - then this field is set to "foo.com" for use on the job - board, and "bar.com" for use on the career site. - - Note that any improvements to the model for a particular - tenant site rely on this field being set correctly to a - unique domain. - - The maximum number of allowed characters is 255. - session_id (str): - Required if - [allow_missing_ids][google.cloud.talent.v4beta1.RequestMetadata.allow_missing_ids] - is unset or ``false``. - - A unique session identification string. A session is defined - as the duration of an end user's interaction with the - service over a certain period. Obfuscate this field for - privacy concerns before providing it to the service. - - Note that any improvements to the model for a particular - tenant site rely on this field being set correctly to a - unique session ID. - - The maximum number of allowed characters is 255. - user_id (str): - Required if - [allow_missing_ids][google.cloud.talent.v4beta1.RequestMetadata.allow_missing_ids] - is unset or ``false``. - - A unique user identification string, as determined by the - client. To have the strongest positive impact on search - quality make sure the client-level is unique. Obfuscate this - field for privacy concerns before providing it to the - service. - - Note that any improvements to the model for a particular - tenant site rely on this field being set correctly to a - unique user ID. - - The maximum number of allowed characters is 255. - allow_missing_ids (bool): - Only set when any of - [domain][google.cloud.talent.v4beta1.RequestMetadata.domain], - [session_id][google.cloud.talent.v4beta1.RequestMetadata.session_id] - and - [user_id][google.cloud.talent.v4beta1.RequestMetadata.user_id] - isn't available for some reason. It is highly recommended - not to set this field and provide accurate - [domain][google.cloud.talent.v4beta1.RequestMetadata.domain], - [session_id][google.cloud.talent.v4beta1.RequestMetadata.session_id] - and - [user_id][google.cloud.talent.v4beta1.RequestMetadata.user_id] - for the best service experience. - device_info (google.cloud.talent_v4beta1.types.DeviceInfo): - The type of device used by the job seeker at - the time of the call to the service. - """ - - domain = proto.Field( - proto.STRING, - number=1, - ) - session_id = proto.Field( - proto.STRING, - number=2, - ) - user_id = proto.Field( - proto.STRING, - number=3, - ) - allow_missing_ids = proto.Field( - proto.BOOL, - number=4, - ) - device_info = proto.Field( - proto.MESSAGE, - number=5, - message='DeviceInfo', - ) - - -class ResponseMetadata(proto.Message): - r"""Additional information returned to client, such as debugging - information. - - Attributes: - request_id (str): - A unique id associated with this call. - This id is logged for tracking purposes. - """ - - request_id = proto.Field( - proto.STRING, - number=1, - ) - - -class DeviceInfo(proto.Message): - r"""Device information collected from the job seeker, candidate, - or other entity conducting the job search. Providing this - information improves the quality of the search results across - devices. - - Attributes: - device_type (google.cloud.talent_v4beta1.types.DeviceInfo.DeviceType): - Type of the device. - id (str): - A device-specific ID. The ID must be a unique - identifier that distinguishes the device from - other devices. - """ - class DeviceType(proto.Enum): - r"""An enumeration describing an API access portal and exposure - mechanism. - """ - DEVICE_TYPE_UNSPECIFIED = 0 - WEB = 1 - MOBILE_WEB = 2 - ANDROID = 3 - IOS = 4 - BOT = 5 - OTHER = 6 - - device_type = proto.Field( - proto.ENUM, - number=1, - enum=DeviceType, - ) - id = proto.Field( - proto.STRING, - number=2, - ) - - -class CustomAttribute(proto.Message): - r"""Custom attribute values that are either filterable or - non-filterable. - - Attributes: - string_values (Sequence[str]): - Exactly one of - [string_values][google.cloud.talent.v4beta1.CustomAttribute.string_values] - or - [long_values][google.cloud.talent.v4beta1.CustomAttribute.long_values] - must be specified. - - This field is used to perform a string match - (``CASE_SENSITIVE_MATCH`` or ``CASE_INSENSITIVE_MATCH``) - search. For filterable ``string_value``\ s, a maximum total - number of 200 values is allowed, with each ``string_value`` - has a byte size of no more than 500B. For unfilterable - ``string_values``, the maximum total byte size of - unfilterable ``string_values`` is 50KB. - - Empty string isn't allowed. - long_values (Sequence[int]): - Exactly one of - [string_values][google.cloud.talent.v4beta1.CustomAttribute.string_values] - or - [long_values][google.cloud.talent.v4beta1.CustomAttribute.long_values] - must be specified. - - This field is used to perform number range search. (``EQ``, - ``GT``, ``GE``, ``LE``, ``LT``) over filterable - ``long_value``. - - Currently at most 1 - [long_values][google.cloud.talent.v4beta1.CustomAttribute.long_values] - is supported. - filterable (bool): - 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. - """ - - string_values = proto.RepeatedField( - proto.STRING, - number=1, - ) - long_values = proto.RepeatedField( - proto.INT64, - number=2, - ) - filterable = proto.Field( - proto.BOOL, - number=3, - ) - keyword_searchable = proto.Field( - proto.BOOL, - number=4, - ) - - -class SpellingCorrection(proto.Message): - r"""Spell check result. - - Attributes: - corrected (bool): - Indicates if the query was corrected by the - spell checker. - corrected_text (str): - Correction output consisting of the corrected - keyword string. - corrected_html (str): - Corrected output with html tags to highlight - the corrected words. Corrected words are called - out with the "..." html tags. - For example, the user input query is "software - enginear", where the second word, "enginear," is - incorrect. It should be "engineer". When - spelling correction is enabled, this value is - "software engineer". - """ - - corrected = proto.Field( - proto.BOOL, - number=1, - ) - corrected_text = proto.Field( - proto.STRING, - number=2, - ) - corrected_html = proto.Field( - proto.STRING, - number=3, - ) - - -class CompensationInfo(proto.Message): - r"""Job compensation details. - - Attributes: - entries (Sequence[google.cloud.talent_v4beta1.types.CompensationInfo.CompensationEntry]): - Job compensation information. - - At most one entry can be of type - [CompensationInfo.CompensationType.BASE][google.cloud.talent.v4beta1.CompensationInfo.CompensationType.BASE], - which is referred as **base compensation entry** for the - job. - annualized_base_compensation_range (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationRange): - Output only. Annualized base compensation range. Computed as - base compensation entry's - [CompensationEntry.amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] - times - [CompensationEntry.expected_units_per_year][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.expected_units_per_year]. - - See - [CompensationEntry][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry] - for explanation on compensation annualization. - annualized_total_compensation_range (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationRange): - Output only. Annualized total compensation range. Computed - as all compensation entries' - [CompensationEntry.amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] - times - [CompensationEntry.expected_units_per_year][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.expected_units_per_year]. - - See - [CompensationEntry][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry] - for explanation on compensation annualization. - """ - class CompensationType(proto.Enum): - r"""The type of compensation. - - For compensation amounts specified in non-monetary amounts, describe - the compensation scheme in the - [CompensationEntry.description][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.description]. - - For example, tipping format is described in - [CompensationEntry.description][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.description] - (for example, "expect 15-20% tips based on customer bill.") and an - estimate of the tips provided in - [CompensationEntry.amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] - or - [CompensationEntry.range][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.range] - ($10 per hour). - - For example, equity is described in - [CompensationEntry.description][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.description] - (for example, "1% - 2% equity vesting over 4 years, 1 year cliff") - and value estimated in - [CompensationEntry.amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] - or - [CompensationEntry.range][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.range]. - If no value estimate is possible, units are - [CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED] - and then further clarified in - [CompensationEntry.description][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.description] - field. - """ - COMPENSATION_TYPE_UNSPECIFIED = 0 - BASE = 1 - BONUS = 2 - SIGNING_BONUS = 3 - EQUITY = 4 - PROFIT_SHARING = 5 - COMMISSIONS = 6 - TIPS = 7 - OTHER_COMPENSATION_TYPE = 8 - - class CompensationUnit(proto.Enum): - r"""Pay frequency.""" - COMPENSATION_UNIT_UNSPECIFIED = 0 - HOURLY = 1 - DAILY = 2 - WEEKLY = 3 - MONTHLY = 4 - YEARLY = 5 - ONE_TIME = 6 - OTHER_COMPENSATION_UNIT = 7 - - class CompensationEntry(proto.Message): - r"""A compensation entry that represents one component of compensation, - such as base pay, bonus, or other compensation type. - - Annualization: One compensation entry can be annualized if - - - it contains valid - [amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] - or - [range][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.range]. - - and its - [expected_units_per_year][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.expected_units_per_year] - is set or can be derived. Its annualized range is determined as - ([amount][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.amount] - or - [range][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.range]) - times - [expected_units_per_year][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.expected_units_per_year]. - - 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: - type_ (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationType): - Compensation type. - - Default is - [CompensationType.COMPENSATION_TYPE_UNSPECIFIED][google.cloud.talent.v4beta1.CompensationInfo.CompensationType.COMPENSATION_TYPE_UNSPECIFIED]. - unit (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationUnit): - Frequency of the specified amount. - - Default is - [CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit.COMPENSATION_UNIT_UNSPECIFIED]. - amount (google.type.money_pb2.Money): - Compensation amount. - - This field is a member of `oneof`_ ``compensation_amount``. - range_ (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationRange): - Compensation range. - - This field is a member of `oneof`_ ``compensation_amount``. - description (str): - Compensation description. For example, could - indicate equity terms or provide additional - context to an estimated bonus. - expected_units_per_year (google.protobuf.wrappers_pb2.DoubleValue): - Expected number of units paid each year. If not specified, - when - [Job.employment_types][google.cloud.talent.v4beta1.Job.employment_types] - is FULLTIME, a default value is inferred based on - [unit][google.cloud.talent.v4beta1.CompensationInfo.CompensationEntry.unit]. - Default values: - - - HOURLY: 2080 - - DAILY: 260 - - WEEKLY: 52 - - MONTHLY: 12 - - ANNUAL: 1 - """ - - type_ = proto.Field( - proto.ENUM, - number=1, - enum='CompensationInfo.CompensationType', - ) - unit = proto.Field( - proto.ENUM, - number=2, - enum='CompensationInfo.CompensationUnit', - ) - amount = proto.Field( - proto.MESSAGE, - number=3, - oneof='compensation_amount', - message=money_pb2.Money, - ) - range_ = proto.Field( - proto.MESSAGE, - number=4, - oneof='compensation_amount', - message='CompensationInfo.CompensationRange', - ) - description = proto.Field( - proto.STRING, - number=5, - ) - expected_units_per_year = proto.Field( - proto.MESSAGE, - number=6, - message=wrappers_pb2.DoubleValue, - ) - - class CompensationRange(proto.Message): - r"""Compensation range. - - Attributes: - max_compensation (google.type.money_pb2.Money): - The maximum amount of compensation. If left empty, the value - is set to a maximal compensation value and the currency code - is set to match the [currency - code][google.type.Money.currency_code] of min_compensation. - min_compensation (google.type.money_pb2.Money): - The minimum amount of compensation. If left empty, the value - is set to zero and the currency code is set to match the - [currency code][google.type.Money.currency_code] of - max_compensation. - """ - - max_compensation = proto.Field( - proto.MESSAGE, - number=2, - message=money_pb2.Money, - ) - min_compensation = proto.Field( - proto.MESSAGE, - number=1, - message=money_pb2.Money, - ) - - entries = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=CompensationEntry, - ) - annualized_base_compensation_range = proto.Field( - proto.MESSAGE, - number=2, - message=CompensationRange, - ) - annualized_total_compensation_range = proto.Field( - proto.MESSAGE, - number=3, - message=CompensationRange, - ) - - -class BatchOperationMetadata(proto.Message): - r"""Metadata used for long running operations returned by CTS batch - APIs. It's used to replace - [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata]. - - Attributes: - state (google.cloud.talent_v4beta1.types.BatchOperationMetadata.State): - The state of a long running operation. - state_description (str): - More detailed information about operation - state. - success_count (int): - Count of successful item(s) inside an - operation. - failure_count (int): - Count of failed item(s) inside an operation. - total_count (int): - Count of total item(s) inside an operation. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the batch operation is created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the batch operation status is updated. The - metadata and the - [update_time][google.cloud.talent.v4beta1.BatchOperationMetadata.update_time] - is refreshed every minute otherwise cached data is returned. - end_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the batch operation is finished and - [google.longrunning.Operation.done][google.longrunning.Operation.done] - is set to ``true``. - """ - class State(proto.Enum): - r"""""" - STATE_UNSPECIFIED = 0 - INITIALIZING = 1 - PROCESSING = 2 - SUCCEEDED = 3 - FAILED = 4 - CANCELLING = 5 - CANCELLED = 6 - - state = proto.Field( - proto.ENUM, - number=1, - enum=State, - ) - state_description = proto.Field( - proto.STRING, - number=2, - ) - success_count = proto.Field( - proto.INT32, - number=3, - ) - failure_count = proto.Field( - proto.INT32, - number=4, - ) - total_count = proto.Field( - proto.INT32, - number=5, - ) - create_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company.py deleted file mode 100644 index 26f057fe..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company.py +++ /dev/null @@ -1,178 +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 proto # type: ignore - -from google.cloud.talent_v4beta1.types import common - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'Company', - }, -) - - -class Company(proto.Message): - r"""A Company resource represents a company in the service. A - company is the entity that owns job postings, that is, the - hiring entity responsible for employing applicants for the job - position. - - Attributes: - name (str): - Required during company update. - - The resource name for a company. This is generated by the - service when a company is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/baz". - - If tenant id is unspecified, the default tenant is used. For - example, "projects/foo/companies/bar". - display_name (str): - Required. The display name of the company, - for example, "Google LLC". - external_id (str): - Required. Client side company identifier, - used to uniquely identify the company. - - The maximum number of allowed characters is 255. - size (google.cloud.talent_v4beta1.types.CompanySize): - The employer's company size. - headquarters_address (str): - The street address of the company's main headquarters, which - may be different from the job location. The service attempts - to geolocate the provided address, and populates a more - specific location wherever possible in - [DerivedInfo.headquarters_location][google.cloud.talent.v4beta1.Company.DerivedInfo.headquarters_location]. - hiring_agency (bool): - Set to true if it is the hiring agency that - post jobs for other employers. - - Defaults to false if not provided. - eeo_text (str): - Equal Employment Opportunity legal disclaimer - text to be associated with all jobs, and - typically to be displayed in all roles. - - The maximum number of allowed characters is 500. - website_uri (str): - The URI representing the company's primary - web site or home page, for example, - "https://www.google.com". - The maximum number of allowed characters is 255. - career_site_uri (str): - The URI to employer's career site or careers - page on the employer's web site, for example, - "https://careers.google.com". - image_uri (str): - A URI that hosts the employer's company logo. - keyword_searchable_job_custom_attributes (Sequence[str]): - A list of keys of filterable - [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes], - whose corresponding ``string_values`` are used in keyword - searches. Jobs with ``string_values`` under these specified - field keys are returned if any of the values match the - search keyword. Custom field values with parenthesis, - brackets and special symbols are not searchable as-is, and - those keyword queries must be surrounded by quotes. - derived_info (google.cloud.talent_v4beta1.types.Company.DerivedInfo): - Output only. Derived details about the - company. - suspended (bool): - Output only. Indicates whether a company is - flagged to be suspended from public availability - by the service when job content appears - suspicious, abusive, or spammy. - """ - - class DerivedInfo(proto.Message): - r"""Derived details about the company. - - Attributes: - headquarters_location (google.cloud.talent_v4beta1.types.Location): - A structured headquarters location of the company, resolved - from - [Company.headquarters_address][google.cloud.talent.v4beta1.Company.headquarters_address] - if provided. - """ - - headquarters_location = proto.Field( - proto.MESSAGE, - number=1, - message=common.Location, - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - display_name = proto.Field( - proto.STRING, - number=2, - ) - external_id = proto.Field( - proto.STRING, - number=3, - ) - size = proto.Field( - proto.ENUM, - number=4, - enum=common.CompanySize, - ) - headquarters_address = proto.Field( - proto.STRING, - number=5, - ) - hiring_agency = proto.Field( - proto.BOOL, - number=6, - ) - eeo_text = proto.Field( - proto.STRING, - number=7, - ) - website_uri = proto.Field( - proto.STRING, - number=8, - ) - career_site_uri = proto.Field( - proto.STRING, - number=9, - ) - image_uri = proto.Field( - proto.STRING, - number=10, - ) - keyword_searchable_job_custom_attributes = proto.RepeatedField( - proto.STRING, - number=11, - ) - derived_info = proto.Field( - proto.MESSAGE, - number=12, - message=DerivedInfo, - ) - suspended = proto.Field( - proto.BOOL, - number=13, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company_service.py deleted file mode 100644 index fc9527a3..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/company_service.py +++ /dev/null @@ -1,222 +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 proto # type: ignore - -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import company as gct_company -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'CreateCompanyRequest', - 'GetCompanyRequest', - 'UpdateCompanyRequest', - 'DeleteCompanyRequest', - 'ListCompaniesRequest', - 'ListCompaniesResponse', - }, -) - - -class CreateCompanyRequest(proto.Message): - r"""The Request of the CreateCompany method. - - Attributes: - parent (str): - Required. Resource name of the tenant under which the - company is created. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created, for example, - "projects/foo". - company (google.cloud.talent_v4beta1.types.Company): - Required. The company to be created. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - company = proto.Field( - proto.MESSAGE, - number=2, - message=gct_company.Company, - ) - - -class GetCompanyRequest(proto.Message): - r"""Request for getting a company by name. - - Attributes: - name (str): - Required. The resource name of the company to be retrieved. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, - "projects/api-test-project/tenants/foo/companies/bar". - - If tenant id is unspecified, the default tenant is used, for - example, "projects/api-test-project/companies/bar". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateCompanyRequest(proto.Message): - r"""Request for updating a specified company. - - Attributes: - company (google.cloud.talent_v4beta1.types.Company): - Required. The company 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.UpdateCompanyRequest.update_mask] - is provided, only the specified fields in - [company][google.cloud.talent.v4beta1.UpdateCompanyRequest.company] - are updated. Otherwise all the fields are updated. - - A field mask to specify the company fields to be updated. - Only top level fields of - [Company][google.cloud.talent.v4beta1.Company] are - supported. - """ - - company = proto.Field( - proto.MESSAGE, - number=1, - message=gct_company.Company, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteCompanyRequest(proto.Message): - r"""Request to delete a company. - - Attributes: - name (str): - Required. The resource name of the company to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/baz". - - If tenant id is unspecified, the default tenant is used, for - example, "projects/foo/companies/bar". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCompaniesRequest(proto.Message): - r"""List companies for which the client has ACL visibility. - - Attributes: - parent (str): - Required. Resource name of the tenant under which the - company is created. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenant/bar". - - If tenant id is unspecified, the default tenant will be - used, for example, "projects/foo". - page_token (str): - The starting indicator from which to return - results. - page_size (int): - The maximum number of companies to be - returned, at most 100. Default is 100 if a - non-positive number is provided. - require_open_jobs (bool): - Set to true if the companies requested must have open jobs. - - Defaults to false. - - If true, at most - [page_size][google.cloud.talent.v4beta1.ListCompaniesRequest.page_size] - of companies are fetched, among which only those with open - jobs are returned. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_token = proto.Field( - proto.STRING, - number=2, - ) - page_size = proto.Field( - proto.INT32, - number=3, - ) - require_open_jobs = proto.Field( - proto.BOOL, - number=4, - ) - - -class ListCompaniesResponse(proto.Message): - r"""The List companies response object. - - Attributes: - companies (Sequence[google.cloud.talent_v4beta1.types.Company]): - Companies 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 - - companies = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gct_company.Company, - ) - 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/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/completion_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/completion_service.py deleted file mode 100644 index d42e0b4e..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/completion_service.py +++ /dev/null @@ -1,169 +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 proto # type: ignore - -from google.cloud.talent_v4beta1.types import common - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'CompleteQueryRequest', - 'CompleteQueryResponse', - }, -) - - -class CompleteQueryRequest(proto.Message): - r"""Auto-complete parameters. - - Attributes: - parent (str): - Required. Resource name of tenant the completion is - performed within. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenant/bar". - - If tenant id is unspecified, the default tenant is used, for - example, "projects/foo". - query (str): - Required. The query used to generate - suggestions. - The maximum number of allowed characters is 255. - language_codes (Sequence[str]): - The list of languages of the query. This is the BCP-47 - language code, such as "en-US" or "sr-Latn". For more - information, see `Tags for Identifying - Languages `__. - - The maximum number of allowed characters is 255. - page_size (int): - Required. Completion result count. - The maximum allowed page size is 10. - company (str): - If provided, restricts completion to specified company. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", - for example, "projects/foo/tenants/bar/companies/baz". - - If tenant id is unspecified, the default tenant is used, for - example, "projects/foo". - scope (google.cloud.talent_v4beta1.types.CompleteQueryRequest.CompletionScope): - The scope of the completion. The defaults is - [CompletionScope.PUBLIC][google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionScope.PUBLIC]. - type_ (google.cloud.talent_v4beta1.types.CompleteQueryRequest.CompletionType): - The completion topic. The default is - [CompletionType.COMBINED][google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType.COMBINED]. - """ - class CompletionScope(proto.Enum): - r"""Enum to specify the scope of completion.""" - COMPLETION_SCOPE_UNSPECIFIED = 0 - TENANT = 1 - PUBLIC = 2 - - class CompletionType(proto.Enum): - r"""Enum to specify auto-completion topics.""" - COMPLETION_TYPE_UNSPECIFIED = 0 - JOB_TITLE = 1 - COMPANY_NAME = 2 - COMBINED = 3 - - parent = proto.Field( - proto.STRING, - number=1, - ) - query = proto.Field( - proto.STRING, - number=2, - ) - language_codes = proto.RepeatedField( - proto.STRING, - number=3, - ) - page_size = proto.Field( - proto.INT32, - number=4, - ) - company = proto.Field( - proto.STRING, - number=5, - ) - scope = proto.Field( - proto.ENUM, - number=6, - enum=CompletionScope, - ) - type_ = proto.Field( - proto.ENUM, - number=7, - enum=CompletionType, - ) - - -class CompleteQueryResponse(proto.Message): - r"""Response of auto-complete query. - - Attributes: - completion_results (Sequence[google.cloud.talent_v4beta1.types.CompleteQueryResponse.CompletionResult]): - Results of the matching job/company - candidates. - metadata (google.cloud.talent_v4beta1.types.ResponseMetadata): - Additional information for the API - invocation, such as the request tracking id. - """ - - class CompletionResult(proto.Message): - r"""Resource that represents completion results. - - Attributes: - suggestion (str): - The suggestion for the query. - type_ (google.cloud.talent_v4beta1.types.CompleteQueryRequest.CompletionType): - The completion topic. - image_uri (str): - The URI of the company image for - [COMPANY_NAME][google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType.COMPANY_NAME]. - """ - - suggestion = proto.Field( - proto.STRING, - number=1, - ) - type_ = proto.Field( - proto.ENUM, - number=2, - enum='CompleteQueryRequest.CompletionType', - ) - image_uri = proto.Field( - proto.STRING, - number=3, - ) - - completion_results = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=CompletionResult, - ) - metadata = proto.Field( - proto.MESSAGE, - number=2, - message=common.ResponseMetadata, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event.py deleted file mode 100644 index f9e5faf8..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event.py +++ /dev/null @@ -1,155 +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 proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'ClientEvent', - 'JobEvent', - }, -) - - -class ClientEvent(proto.Message): - r"""An event issued when an end user interacts with the - application that implements Cloud Talent Solution. Providing - this information improves the quality of results for the API - clients, enabling the service to perform optimally. The number - of events sent must be consistent with other calls, such as job - searches, issued to the service by the client. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - request_id (str): - Strongly recommended for the best service experience. - - A unique ID generated in the API responses. It can be found - in - [ResponseMetadata.request_id][google.cloud.talent.v4beta1.ResponseMetadata.request_id]. - event_id (str): - Required. A unique identifier, generated by - the client application. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Required. The timestamp of the event. - job_event (google.cloud.talent_v4beta1.types.JobEvent): - An event issued when a job seeker 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 - or other users, for example, feedback on why a - profile was bookmarked. - """ - - request_id = proto.Field( - proto.STRING, - number=1, - ) - event_id = proto.Field( - proto.STRING, - number=2, - ) - create_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - job_event = proto.Field( - proto.MESSAGE, - number=5, - oneof='event', - message='JobEvent', - ) - event_notes = proto.Field( - proto.STRING, - number=9, - ) - - -class JobEvent(proto.Message): - r"""An event issued when a job seeker interacts with the - application that implements Cloud Talent Solution. - - Attributes: - type_ (google.cloud.talent_v4beta1.types.JobEvent.JobEventType): - Required. The type of the event (see - [JobEventType][google.cloud.talent.v4beta1.JobEvent.JobEventType]). - jobs (Sequence[str]): - Required. The [job - name(s)][google.cloud.talent.v4beta1.Job.name] associated - with this event. For example, if this is an - [impression][google.cloud.talent.v4beta1.JobEvent.JobEventType.IMPRESSION] - event, this field contains the identifiers of all jobs shown - to the job seeker. If this was a - [view][google.cloud.talent.v4beta1.JobEvent.JobEventType.VIEW] - event, this field contains the identifier of the viewed job. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}", - for example, "projects/foo/tenants/bar/jobs/baz". - profile (str): - The [profile name][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". - """ - class JobEventType(proto.Enum): - r"""An enumeration of an event attributed to the behavior of the - end user, such as a job seeker. - """ - JOB_EVENT_TYPE_UNSPECIFIED = 0 - IMPRESSION = 1 - VIEW = 2 - VIEW_REDIRECT = 3 - APPLICATION_START = 4 - APPLICATION_FINISH = 5 - APPLICATION_QUICK_SUBMISSION = 6 - APPLICATION_REDIRECT = 7 - APPLICATION_START_FROM_SEARCH = 8 - APPLICATION_REDIRECT_FROM_SEARCH = 9 - APPLICATION_COMPANY_SUBMIT = 10 - BOOKMARK = 11 - NOTIFICATION = 12 - HIRED = 13 - SENT_CV = 14 - INTERVIEW_GRANTED = 15 - - type_ = proto.Field( - proto.ENUM, - number=1, - enum=JobEventType, - ) - jobs = proto.RepeatedField( - proto.STRING, - number=2, - ) - profile = proto.Field( - proto.STRING, - number=3, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event_service.py deleted file mode 100644 index 3d029ae4..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/event_service.py +++ /dev/null @@ -1,58 +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 proto # type: ignore - -from google.cloud.talent_v4beta1.types import event - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'CreateClientEventRequest', - }, -) - - -class CreateClientEventRequest(proto.Message): - r"""The report event request. - - Attributes: - parent (str): - Required. Resource name of the tenant under which the event - is created. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created, for example, - "projects/foo". - client_event (google.cloud.talent_v4beta1.types.ClientEvent): - Required. Events issued when end user - interacts with customer's application that uses - Cloud Talent Solution. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - client_event = proto.Field( - proto.MESSAGE, - number=2, - message=event.ClientEvent, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/filters.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/filters.py deleted file mode 100644 index 72e5205e..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/filters.py +++ /dev/null @@ -1,511 +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 proto # type: ignore - -from google.cloud.talent_v4beta1.types import common -from google.protobuf import duration_pb2 # type: ignore -from google.type import latlng_pb2 # type: ignore -from google.type import timeofday_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'JobQuery', - 'LocationFilter', - 'CompensationFilter', - 'CommuteFilter', - }, -) - - -class JobQuery(proto.Message): - r"""The query required to perform a search query. - - Attributes: - query (str): - The query string that matches against the job - title, description, and location fields. - - The maximum number of allowed characters is 255. - query_language_code (str): - The language code of - [query][google.cloud.talent.v4beta1.JobQuery.query]. For - example, "en-US". This field helps to better interpret the - query. - - If a value isn't specified, the query language code is - automatically detected, which may not be accurate. - - Language code should be in BCP-47 format, such as "en-US" or - "sr-Latn". For more information, see `Tags for Identifying - Languages `__. - companies (Sequence[str]): - This filter specifies the company entities to search - against. - - If a value isn't specified, jobs are searched for against - all companies. - - If multiple values are specified, jobs are searched against - the companies specified. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". - For example, "projects/foo/tenants/bar/companies/baz". - - If tenant id is unspecified, the default tenant is used. For - example, "projects/foo/companies/bar". - - At most 20 company filters are allowed. - location_filters (Sequence[google.cloud.talent_v4beta1.types.LocationFilter]): - The location filter specifies geo-regions containing the - jobs to search against. See - [LocationFilter][google.cloud.talent.v4beta1.LocationFilter] - for more information. - - If a location value isn't specified, jobs fitting the other - search criteria are retrieved regardless of where they're - located. - - If multiple values are specified, jobs are retrieved from - any of the specified locations. If different values are - specified for the - [LocationFilter.distance_in_miles][google.cloud.talent.v4beta1.LocationFilter.distance_in_miles] - parameter, the maximum provided distance is used for all - locations. - - At most 5 location filters are allowed. - job_categories (Sequence[google.cloud.talent_v4beta1.types.JobCategory]): - The category filter specifies the categories of jobs to - search against. See - [JobCategory][google.cloud.talent.v4beta1.JobCategory] for - more information. - - If a value isn't specified, jobs from any category are - searched against. - - If multiple values are specified, jobs from any of the - specified categories are searched against. - commute_filter (google.cloud.talent_v4beta1.types.CommuteFilter): - Allows filtering jobs by commute time with different travel - methods (for example, driving or public transit). - - Note: This only works when you specify a - [CommuteMethod][google.cloud.talent.v4beta1.CommuteMethod]. - In this case, - [location_filters][google.cloud.talent.v4beta1.JobQuery.location_filters] - is ignored. - - Currently we don't support sorting by commute time. - company_display_names (Sequence[str]): - This filter specifies the company - [Company.display_name][google.cloud.talent.v4beta1.Company.display_name] - 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. - - If multiple values are specified, jobs within the search - results may be associated with any of the specified - companies. - - At most 20 company display name filters are allowed. - compensation_filter (google.cloud.talent_v4beta1.types.CompensationFilter): - This search filter is applied only to - [Job.compensation_info][google.cloud.talent.v4beta1.Job.compensation_info]. - For example, if the filter is specified as "Hourly job with - per-hour compensation > $15", only jobs meeting these - criteria are searched. If a filter isn't defined, all open - jobs are searched. - custom_attribute_filter (str): - This filter specifies a structured syntax to match against - the - [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes] - marked as ``filterable``. - - The syntax for this expression is a subset of SQL syntax. - - Supported operators are: ``=``, ``!=``, ``<``, ``<=``, - ``>``, and ``>=`` where the left of the operator is a custom - field key and the right of the operator is a number or a - quoted string. You must escape backslash (\) and quote (") - characters. - - Supported functions are ``LOWER([field_name])`` to perform a - case insensitive match and ``EMPTY([field_name])`` 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"), a maximum of 100 comparisons or functions are - allowed in the expression. The expression must be < 10000 - bytes in length. - - Sample Query: - ``(LOWER(driving_license)="class \"a\"" OR EMPTY(driving_license)) AND driving_years > 10`` - 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". - Defaults to false: a spell check is performed. - employment_types (Sequence[google.cloud.talent_v4beta1.types.EmploymentType]): - The employment type filter specifies the employment type of - jobs to search against, such as - [EmploymentType.FULL_TIME][google.cloud.talent.v4beta1.EmploymentType.FULL_TIME]. - - If a value isn't specified, jobs in the search results - includes any employment type. - - If multiple values are specified, jobs in the search results - include any of the specified employment types. - language_codes (Sequence[str]): - This filter specifies the locale of jobs to search against, - for example, "en-US". - - If a value isn't specified, the search results can contain - jobs in any locale. - - Language codes should be in BCP-47 format, such as "en-US" - or "sr-Latn". For more information, see `Tags for - Identifying - Languages `__. - - At most 10 language code filters are allowed. - publish_time_range (google.cloud.talent_v4beta1.types.TimestampRange): - Jobs published within a range specified by - this filter are searched against. - excluded_jobs (Sequence[str]): - This filter specifies a list of job names to - be excluded during search. - At most 400 excluded job names are allowed. - """ - - query = proto.Field( - proto.STRING, - number=1, - ) - query_language_code = proto.Field( - proto.STRING, - number=14, - ) - companies = proto.RepeatedField( - proto.STRING, - number=2, - ) - location_filters = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='LocationFilter', - ) - job_categories = proto.RepeatedField( - proto.ENUM, - number=4, - enum=common.JobCategory, - ) - commute_filter = proto.Field( - proto.MESSAGE, - number=5, - message='CommuteFilter', - ) - company_display_names = proto.RepeatedField( - proto.STRING, - number=6, - ) - compensation_filter = proto.Field( - proto.MESSAGE, - number=7, - message='CompensationFilter', - ) - custom_attribute_filter = proto.Field( - proto.STRING, - number=8, - ) - disable_spell_check = proto.Field( - proto.BOOL, - number=9, - ) - employment_types = proto.RepeatedField( - proto.ENUM, - number=10, - enum=common.EmploymentType, - ) - language_codes = proto.RepeatedField( - proto.STRING, - number=11, - ) - publish_time_range = proto.Field( - proto.MESSAGE, - number=12, - message=common.TimestampRange, - ) - excluded_jobs = proto.RepeatedField( - proto.STRING, - number=13, - ) - - -class LocationFilter(proto.Message): - r"""Geographic region of the search. - - Attributes: - address (str): - The address name, such as "Mountain View" or - "Bay Area". - region_code (str): - 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://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 - provided. - distance_in_miles (float): - The distance_in_miles is applied when the location being - searched for is identified as a city or smaller. This field - is ignored if the location being searched for is a state or - larger. - 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). - [Job.posting_region][google.cloud.talent.v4beta1.Job.posting_region] - indicates if a job permits telecommuting. If this field is - set to - [TelecommutePreference.TELECOMMUTE_ALLOWED][google.cloud.talent.v4beta1.LocationFilter.TelecommutePreference.TELECOMMUTE_ALLOWED], - telecommuting jobs are searched, and - [address][google.cloud.talent.v4beta1.LocationFilter.address] - and - [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], - 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 - location filter to search for a combination of job - locations, such as "Mountain View" or "telecommuting" jobs. - However, when used in combination with other location - filters, telecommuting jobs can be treated as less relevant - than other jobs in the search response. - - This field is only used for job search requests. - negated (bool): - Whether to apply negation to the filter so - profiles matching the filter are excluded. - """ - class TelecommutePreference(proto.Enum): - r"""Specify whether to include telecommute jobs.""" - TELECOMMUTE_PREFERENCE_UNSPECIFIED = 0 - TELECOMMUTE_EXCLUDED = 1 - TELECOMMUTE_ALLOWED = 2 - TELECOMMUTE_JOBS_EXCLUDED = 3 - - address = proto.Field( - proto.STRING, - number=1, - ) - region_code = proto.Field( - proto.STRING, - number=2, - ) - lat_lng = proto.Field( - proto.MESSAGE, - number=3, - message=latlng_pb2.LatLng, - ) - distance_in_miles = proto.Field( - proto.DOUBLE, - number=4, - ) - telecommute_preference = proto.Field( - proto.ENUM, - number=5, - enum=TelecommutePreference, - ) - negated = proto.Field( - proto.BOOL, - number=6, - ) - - -class CompensationFilter(proto.Message): - r"""Filter on job compensation type and amount. - - Attributes: - type_ (google.cloud.talent_v4beta1.types.CompensationFilter.FilterType): - Required. Type of filter. - units (Sequence[google.cloud.talent_v4beta1.types.CompensationInfo.CompensationUnit]): - Required. Specify desired ``base compensation entry's`` - [CompensationInfo.CompensationUnit][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit]. - range_ (google.cloud.talent_v4beta1.types.CompensationInfo.CompensationRange): - Compensation range. - include_jobs_with_unspecified_compensation_range (bool): - If set to true, jobs with unspecified - compensation range fields are included. - """ - class FilterType(proto.Enum): - r"""Specify the type of filtering.""" - FILTER_TYPE_UNSPECIFIED = 0 - UNIT_ONLY = 1 - UNIT_AND_AMOUNT = 2 - ANNUALIZED_BASE_AMOUNT = 3 - ANNUALIZED_TOTAL_AMOUNT = 4 - - type_ = proto.Field( - proto.ENUM, - number=1, - enum=FilterType, - ) - units = proto.RepeatedField( - proto.ENUM, - number=2, - enum=common.CompensationInfo.CompensationUnit, - ) - range_ = proto.Field( - proto.MESSAGE, - number=3, - message=common.CompensationInfo.CompensationRange, - ) - include_jobs_with_unspecified_compensation_range = proto.Field( - proto.BOOL, - number=4, - ) - - -class CommuteFilter(proto.Message): - r"""Parameters needed for commute search. - - 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: - commute_method (google.cloud.talent_v4beta1.types.CommuteMethod): - Required. The method of transportation to - calculate the commute time for. - start_coordinates (google.type.latlng_pb2.LatLng): - Required. The latitude and longitude of the - location to calculate the commute time from. - travel_duration (google.protobuf.duration_pb2.Duration): - Required. The maximum travel time in seconds. The maximum - allowed value is ``3600s`` (one hour). Format is ``123s``. - allow_imprecise_addresses (bool): - If ``true``, jobs without street level addresses may also be - returned. For city level addresses, the city center is used. - For state and coarser level addresses, text matching is - used. If this field is set to ``false`` or isn't specified, - only jobs that include street level addresses will be - returned by commute search. - road_traffic (google.cloud.talent_v4beta1.types.CommuteFilter.RoadTraffic): - Specifies the traffic density to use when - calculating commute time. - - This field is a member of `oneof`_ ``traffic_option``. - departure_time (google.type.timeofday_pb2.TimeOfDay): - The departure time used to calculate traffic impact, - represented as - [google.type.TimeOfDay][google.type.TimeOfDay] in local time - zone. - - Currently traffic model is restricted to hour level - resolution. - - This field is a member of `oneof`_ ``traffic_option``. - """ - class RoadTraffic(proto.Enum): - r"""The traffic density to use when calculating commute time.""" - ROAD_TRAFFIC_UNSPECIFIED = 0 - TRAFFIC_FREE = 1 - BUSY_HOUR = 2 - - commute_method = proto.Field( - proto.ENUM, - number=1, - enum=common.CommuteMethod, - ) - start_coordinates = proto.Field( - proto.MESSAGE, - number=2, - message=latlng_pb2.LatLng, - ) - travel_duration = proto.Field( - proto.MESSAGE, - number=3, - message=duration_pb2.Duration, - ) - allow_imprecise_addresses = proto.Field( - proto.BOOL, - number=4, - ) - road_traffic = proto.Field( - proto.ENUM, - number=5, - oneof='traffic_option', - enum=RoadTraffic, - ) - departure_time = proto.Field( - proto.MESSAGE, - number=6, - oneof='traffic_option', - message=timeofday_pb2.TimeOfDay, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/histogram.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/histogram.py deleted file mode 100644 index a94682fe..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/histogram.py +++ /dev/null @@ -1,84 +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 proto # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'HistogramQuery', - 'HistogramQueryResult', - }, -) - - -class HistogramQuery(proto.Message): - r"""The histogram request. - - Attributes: - histogram_query (str): - An expression specifies a histogram request against matching - resources (for example, jobs, profiles) for searches. - - See - [SearchJobsRequest.histogram_queries][google.cloud.talent.v4beta1.SearchJobsRequest.histogram_queries] - and - [SearchProfilesRequest.histogram_queries][google.cloud.talent.v4beta1.SearchProfilesRequest.histogram_queries] - for details about syntax. - """ - - histogram_query = proto.Field( - proto.STRING, - number=1, - ) - - -class HistogramQueryResult(proto.Message): - r"""Histogram result that matches - [HistogramQuery][google.cloud.talent.v4beta1.HistogramQuery] - specified in searches. - - Attributes: - histogram_query (str): - Requested histogram expression. - histogram (Mapping[str, int]): - A map from the values of the facet associated with distinct - values to the number of matching entries with corresponding - value. - - The key format is: - - - (for string histogram) string values stored in the field. - - (for named numeric bucket) name specified in ``bucket()`` - function, like for ``bucket(0, MAX, "non-negative")``, - the key will be ``non-negative``. - - (for anonymous numeric bucket) range formatted as - ``-``, for example, ``0-1000``, ``MIN-0``, and - ``0-MAX``. - """ - - histogram_query = proto.Field( - proto.STRING, - number=1, - ) - histogram = proto.MapField( - proto.STRING, - proto.INT64, - number=2, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job.py deleted file mode 100644 index e6af27bb..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job.py +++ /dev/null @@ -1,567 +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 proto # type: ignore - -from google.cloud.talent_v4beta1.types import common -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'Job', - }, -) - - -class Job(proto.Message): - r"""A Job resource represents a job posting (also referred to as a "job - listing" or "job requisition"). A job belongs to a - [Company][google.cloud.talent.v4beta1.Company], which is the hiring - entity responsible for the job. - - Attributes: - name (str): - Required during job update. - - The resource name for the job. This is generated by the - service when a job is created. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - If tenant id is unspecified, the default tenant is used. For - example, "projects/foo/jobs/bar". - - Use of this field in job queries and API calls is preferred - over the use of - [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id] - since this value is unique. - company (str): - Required. The resource name of the company listing the job. - - The format is - "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". - For example, "projects/foo/tenants/bar/companies/baz". - - If tenant id is unspecified, the default tenant is used. For - example, "projects/foo/companies/bar". - requisition_id (str): - Required. The requisition ID, also referred to as the - posting ID, is assigned by the client to identify a job. - This field is intended to be used by clients for client - identification and tracking of postings. A job isn't allowed - to be created if there is another job with the same - [company][google.cloud.talent.v4beta1.Job.name], - [language_code][google.cloud.talent.v4beta1.Job.language_code] - and - [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id]. - - The maximum number of allowed characters is 255. - title (str): - Required. The title of the job, such as - "Software Engineer" - The maximum number of allowed characters is 500. - description (str): - Required. The description of the job, which typically - includes a multi-paragraph description of the company and - related information. Separate fields are provided on the job - object for - [responsibilities][google.cloud.talent.v4beta1.Job.responsibilities], - [qualifications][google.cloud.talent.v4beta1.Job.qualifications], - and other job characteristics. Use of these separate job - fields is recommended. - - This field accepts and sanitizes HTML input, and also - accepts bold, italic, ordered list, and unordered list - markup tags. - - The maximum number of allowed characters is 100,000. - addresses (Sequence[str]): - Strongly recommended for the best service experience. - - Location(s) where the employer is looking to hire for this - job posting. - - Specifying the full street address(es) of the hiring - location enables better API results, especially job searches - by commute time. - - At most 50 locations are allowed for best search - performance. If a job has more locations, it is suggested to - split it into multiple jobs with unique - [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id]s - (e.g. 'ReqA' becomes 'ReqA-1', 'ReqA-2', and so on.) as - multiple jobs with the same - [company][google.cloud.talent.v4beta1.Job.company], - [language_code][google.cloud.talent.v4beta1.Job.language_code] - and - [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id] - are not allowed. If the original - [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id] - must be preserved, a custom field should be used for - storage. It is also suggested to group the locations that - close to each other in the same job for better search - experience. - - The maximum number of allowed characters is 500. - application_info (google.cloud.talent_v4beta1.types.Job.ApplicationInfo): - Job application information. - job_benefits (Sequence[google.cloud.talent_v4beta1.types.JobBenefit]): - The benefits included with the job. - compensation_info (google.cloud.talent_v4beta1.types.CompensationInfo): - Job compensation information (a.k.a. "pay - rate") i.e., the compensation that will paid to - the employee. - custom_attributes (Mapping[str, google.cloud.talent_v4beta1.types.CustomAttribute]): - A map of fields to hold both filterable and non-filterable - custom job attributes that are not covered by the provided - structured fields. - - The keys of the map are strings up to 64 bytes and must - match the pattern: ``[a-zA-Z][a-zA-Z0-9_]*``. For example, - key0LikeThis or KEY_1_LIKE_THIS. - - At most 100 filterable and at most 100 unfilterable keys are - supported. For filterable ``string_values``, across all keys - at most 200 values are allowed, with each string no more - than 255 characters. For unfilterable ``string_values``, the - maximum total size of ``string_values`` across all keys is - 50KB. - degree_types (Sequence[google.cloud.talent_v4beta1.types.DegreeType]): - The desired education degrees for the job, - such as Bachelors, Masters. - department (str): - The department or functional area within the - company with the open position. - - The maximum number of allowed characters is 255. - employment_types (Sequence[google.cloud.talent_v4beta1.types.EmploymentType]): - The employment type(s) of a job, for example, [full - time][google.cloud.talent.v4beta1.EmploymentType.FULL_TIME] - or [part - time][google.cloud.talent.v4beta1.EmploymentType.PART_TIME]. - incentives (str): - A description of bonus, commission, and other - compensation incentives associated with the job - not including salary or pay. - The maximum number of allowed characters is - 10,000. - language_code (str): - The language of the posting. This field is distinct from any - requirements for fluency that are associated with the job. - - Language codes must be in BCP-47 format, such as "en-US" or - "sr-Latn". For more information, see `Tags for Identifying - Languages `__\ {: - class="external" target="_blank" }. - - If this field is unspecified and - [Job.description][google.cloud.talent.v4beta1.Job.description] - is present, detected language code based on - [Job.description][google.cloud.talent.v4beta1.Job.description] - is assigned, otherwise defaults to 'en_US'. - job_level (google.cloud.talent_v4beta1.types.JobLevel): - The experience level associated with the job, - such as "Entry Level". - promotion_value (int): - A promotion value of the job, as determined by the client. - The value determines the sort order of the jobs returned - when searching for jobs using the featured jobs search call, - with higher promotional values being returned first and ties - being resolved by relevance sort. Only the jobs with a - promotionValue >0 are returned in a FEATURED_JOB_SEARCH. - - Default value is 0, and negative values are treated as 0. - qualifications (str): - A description of the qualifications required to perform the - job. The use of this field is recommended as an alternative - to using the more general - [description][google.cloud.talent.v4beta1.Job.description] - field. - - This field accepts and sanitizes HTML input, and also - accepts bold, italic, ordered list, and unordered list - markup tags. - - The maximum number of allowed characters is 10,000. - responsibilities (str): - A description of job responsibilities. The use of this field - is recommended as an alternative to using the more general - [description][google.cloud.talent.v4beta1.Job.description] - field. - - This field accepts and sanitizes HTML input, and also - accepts bold, italic, ordered list, and unordered list - markup tags. - - The maximum number of allowed characters is 10,000. - posting_region (google.cloud.talent_v4beta1.types.PostingRegion): - The job - [PostingRegion][google.cloud.talent.v4beta1.PostingRegion] - (for example, state, country) throughout which the job is - available. If this field is set, a - [LocationFilter][google.cloud.talent.v4beta1.LocationFilter] - in a search query within the job region finds this job - posting if an exact location match isn't specified. If this - field is set to - [PostingRegion.NATION][google.cloud.talent.v4beta1.PostingRegion.NATION] - or - [PostingRegion.ADMINISTRATIVE_AREA][google.cloud.talent.v4beta1.PostingRegion.ADMINISTRATIVE_AREA], - setting job - [Job.addresses][google.cloud.talent.v4beta1.Job.addresses] - to the same location level as this field is strongly - recommended. - visibility (google.cloud.talent_v4beta1.types.Visibility): - Deprecated. The job is only visible to the owner. - - The visibility of the job. - - Defaults to - [Visibility.ACCOUNT_ONLY][google.cloud.talent.v4beta1.Visibility.ACCOUNT_ONLY] - if not specified. - job_start_time (google.protobuf.timestamp_pb2.Timestamp): - The start timestamp of the job in UTC time - zone. Typically this field is used for - contracting engagements. Invalid timestamps are - ignored. - job_end_time (google.protobuf.timestamp_pb2.Timestamp): - The end timestamp of the job. Typically this - field is used for contracting engagements. - Invalid timestamps are ignored. - posting_publish_time (google.protobuf.timestamp_pb2.Timestamp): - The timestamp this job posting was most - recently published. The default value is the - time the request arrives at the server. Invalid - timestamps are ignored. - posting_expire_time (google.protobuf.timestamp_pb2.Timestamp): - Strongly recommended for the best service experience. - - The expiration timestamp of the job. After this timestamp, - the job is marked as expired, and it no longer appears in - search results. The expired job can't be listed by the - [ListJobs][google.cloud.talent.v4beta1.JobService.ListJobs] - API, but it can be retrieved with the - [GetJob][google.cloud.talent.v4beta1.JobService.GetJob] API - or updated with the - [UpdateJob][google.cloud.talent.v4beta1.JobService.UpdateJob] - API or deleted with the - [DeleteJob][google.cloud.talent.v4beta1.JobService.DeleteJob] - API. An expired job can be updated and opened again by using - a future expiration timestamp. Updating an expired job fails - if there is another existing open job with same - [company][google.cloud.talent.v4beta1.Job.company], - [language_code][google.cloud.talent.v4beta1.Job.language_code] - and - [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id]. - - The expired jobs are retained in our system for 90 days. - However, the overall expired job count cannot exceed 3 times - the maximum number of open jobs over previous 7 days. If - this threshold is exceeded, expired jobs are cleaned out in - order of earliest expire time. Expired jobs are no longer - accessible after they are cleaned out. - - Invalid timestamps are ignored, and treated as expire time - not provided. - - If the timestamp is before the instant request is made, the - job is treated as expired immediately on creation. This kind - of job can not be updated. And when creating a job with past - timestamp, the - [posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] - must be set before - [posting_expire_time][google.cloud.talent.v4beta1.Job.posting_expire_time]. - The purpose of this feature is to allow other objects, such - as [Application][google.cloud.talent.v4beta1.Application], - to refer a job that didn't exist in the system prior to - becoming expired. If you want to modify a job that was - expired on creation, delete it and create a new one. - - If this value isn't provided at the time of job creation or - is invalid, the job posting expires after 30 days from the - job's creation time. For example, if the job was created on - 2017/01/01 13:00AM UTC with an unspecified expiration date, - the job expires after 2017/01/31 13:00AM UTC. - - If this value isn't provided on job update, it depends on - the field masks set by - [UpdateJobRequest.update_mask][google.cloud.talent.v4beta1.UpdateJobRequest.update_mask]. - If the field masks include - [job_end_time][google.cloud.talent.v4beta1.Job.job_end_time], - or the masks are empty meaning that every field is updated, - the job posting expires after 30 days from the job's last - update time. Otherwise the expiration date isn't updated. - posting_create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The timestamp when this job - posting was created. - posting_update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The timestamp when this job - posting was last updated. - company_display_name (str): - Output only. Display name of the company - listing the job. - derived_info (google.cloud.talent_v4beta1.types.Job.DerivedInfo): - Output only. Derived details about the job - posting. - processing_options (google.cloud.talent_v4beta1.types.Job.ProcessingOptions): - Options for job processing. - """ - - class ApplicationInfo(proto.Message): - r"""Application related details of a job posting. - - Attributes: - emails (Sequence[str]): - Use this field to specify email address(es) - to which resumes or applications can be sent. - The maximum number of allowed characters for - each entry is 255. - instruction (str): - Use this field to provide instructions, such - as "Mail your application to ...", that a - candidate can follow to apply for the job. - This field accepts and sanitizes HTML input, and - also accepts bold, italic, ordered list, and - unordered list markup tags. - The maximum number of allowed characters is - 3,000. - uris (Sequence[str]): - Use this URI field to direct an applicant to - a website, for example to link to an online - application form. - The maximum number of allowed characters for - each entry is 2,000. - """ - - emails = proto.RepeatedField( - proto.STRING, - number=1, - ) - instruction = proto.Field( - proto.STRING, - number=2, - ) - uris = proto.RepeatedField( - proto.STRING, - number=3, - ) - - class DerivedInfo(proto.Message): - r"""Derived details about the job posting. - - Attributes: - locations (Sequence[google.cloud.talent_v4beta1.types.Location]): - Structured locations of the job, resolved from - [Job.addresses][google.cloud.talent.v4beta1.Job.addresses]. - - [locations][google.cloud.talent.v4beta1.Job.DerivedInfo.locations] - are exactly matched to - [Job.addresses][google.cloud.talent.v4beta1.Job.addresses] - in the same order. - job_categories (Sequence[google.cloud.talent_v4beta1.types.JobCategory]): - Job categories derived from - [Job.title][google.cloud.talent.v4beta1.Job.title] and - [Job.description][google.cloud.talent.v4beta1.Job.description]. - """ - - locations = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=common.Location, - ) - job_categories = proto.RepeatedField( - proto.ENUM, - number=3, - enum=common.JobCategory, - ) - - class ProcessingOptions(proto.Message): - r"""Options for job processing. - - Attributes: - disable_street_address_resolution (bool): - If set to ``true``, the service does not attempt to resolve - a more precise address for the job. - html_sanitization (google.cloud.talent_v4beta1.types.HtmlSanitization): - Option for job HTML content sanitization. Applied fields - are: - - - description - - applicationInfo.instruction - - incentives - - qualifications - - responsibilities - - HTML tags in these fields may be stripped if sanitiazation - isn't disabled. - - Defaults to - [HtmlSanitization.SIMPLE_FORMATTING_ONLY][google.cloud.talent.v4beta1.HtmlSanitization.SIMPLE_FORMATTING_ONLY]. - """ - - disable_street_address_resolution = proto.Field( - proto.BOOL, - number=1, - ) - html_sanitization = proto.Field( - proto.ENUM, - number=2, - enum=common.HtmlSanitization, - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - company = proto.Field( - proto.STRING, - number=2, - ) - requisition_id = proto.Field( - proto.STRING, - number=3, - ) - title = proto.Field( - proto.STRING, - number=4, - ) - description = proto.Field( - proto.STRING, - number=5, - ) - addresses = proto.RepeatedField( - proto.STRING, - number=6, - ) - application_info = proto.Field( - proto.MESSAGE, - number=7, - message=ApplicationInfo, - ) - job_benefits = proto.RepeatedField( - proto.ENUM, - number=8, - enum=common.JobBenefit, - ) - compensation_info = proto.Field( - proto.MESSAGE, - number=9, - message=common.CompensationInfo, - ) - custom_attributes = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=10, - message=common.CustomAttribute, - ) - degree_types = proto.RepeatedField( - proto.ENUM, - number=11, - enum=common.DegreeType, - ) - department = proto.Field( - proto.STRING, - number=12, - ) - employment_types = proto.RepeatedField( - proto.ENUM, - number=13, - enum=common.EmploymentType, - ) - incentives = proto.Field( - proto.STRING, - number=14, - ) - language_code = proto.Field( - proto.STRING, - number=15, - ) - job_level = proto.Field( - proto.ENUM, - number=16, - enum=common.JobLevel, - ) - promotion_value = proto.Field( - proto.INT32, - number=17, - ) - qualifications = proto.Field( - proto.STRING, - number=18, - ) - responsibilities = proto.Field( - proto.STRING, - number=19, - ) - posting_region = proto.Field( - proto.ENUM, - number=20, - enum=common.PostingRegion, - ) - visibility = proto.Field( - proto.ENUM, - number=21, - enum=common.Visibility, - ) - job_start_time = proto.Field( - proto.MESSAGE, - number=22, - message=timestamp_pb2.Timestamp, - ) - job_end_time = proto.Field( - proto.MESSAGE, - number=23, - message=timestamp_pb2.Timestamp, - ) - posting_publish_time = proto.Field( - proto.MESSAGE, - number=24, - message=timestamp_pb2.Timestamp, - ) - posting_expire_time = proto.Field( - proto.MESSAGE, - number=25, - message=timestamp_pb2.Timestamp, - ) - posting_create_time = proto.Field( - proto.MESSAGE, - number=26, - message=timestamp_pb2.Timestamp, - ) - posting_update_time = proto.Field( - proto.MESSAGE, - number=27, - message=timestamp_pb2.Timestamp, - ) - company_display_name = proto.Field( - proto.STRING, - number=28, - ) - derived_info = proto.Field( - proto.MESSAGE, - number=29, - message=DerivedInfo, - ) - processing_options = proto.Field( - proto.MESSAGE, - number=30, - message=ProcessingOptions, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job_service.py deleted file mode 100644 index bb7ffc7a..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/job_service.py +++ /dev/null @@ -1,1110 +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 proto # type: ignore - -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import filters -from google.cloud.talent_v4beta1.types import histogram -from google.cloud.talent_v4beta1.types import job as gct_job -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.rpc import status_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'JobView', - 'CreateJobRequest', - 'GetJobRequest', - 'UpdateJobRequest', - 'DeleteJobRequest', - 'BatchDeleteJobsRequest', - 'ListJobsRequest', - 'ListJobsResponse', - 'SearchJobsRequest', - 'SearchJobsResponse', - 'BatchCreateJobsRequest', - 'BatchUpdateJobsRequest', - 'JobOperationResult', - }, -) - - -class JobView(proto.Enum): - r"""An enum that specifies the job attributes that are returned in the - [MatchingJob.job][google.cloud.talent.v4beta1.SearchJobsResponse.MatchingJob.job] - or - [ListJobsResponse.jobs][google.cloud.talent.v4beta1.ListJobsResponse.jobs] - fields. - """ - JOB_VIEW_UNSPECIFIED = 0 - JOB_VIEW_ID_ONLY = 1 - JOB_VIEW_MINIMAL = 2 - JOB_VIEW_SMALL = 3 - JOB_VIEW_FULL = 4 - - -class CreateJobRequest(proto.Message): - r"""Create job request. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenant/bar". If tenant id is - unspecified a default tenant is created. For example, - "projects/foo". - job (google.cloud.talent_v4beta1.types.Job): - Required. The Job to be created. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - job = proto.Field( - proto.MESSAGE, - number=2, - message=gct_job.Job, - ) - - -class GetJobRequest(proto.Message): - r"""Get job request. - - Attributes: - name (str): - Required. The resource name of the job to retrieve. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - If tenant id is unspecified, the default tenant is used. For - example, "projects/foo/jobs/bar". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateJobRequest(proto.Message): - r"""Update job request. - - Attributes: - job (google.cloud.talent_v4beta1.types.Job): - Required. The Job to be updated. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Strongly recommended for the best service experience. - - If - [update_mask][google.cloud.talent.v4beta1.UpdateJobRequest.update_mask] - is provided, only the specified fields in - [job][google.cloud.talent.v4beta1.UpdateJobRequest.job] are - updated. Otherwise all the fields are updated. - - A field mask to restrict the fields that are updated. Only - top level fields of [Job][google.cloud.talent.v4beta1.Job] - are supported. - """ - - job = proto.Field( - proto.MESSAGE, - number=1, - message=gct_job.Job, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteJobRequest(proto.Message): - r"""Delete job request. - - Attributes: - name (str): - Required. The resource name of the job to be deleted. - - The format is - "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - For example, "projects/foo/tenants/bar/jobs/baz". - - If tenant id is unspecified, the default tenant is used. For - example, "projects/foo/jobs/bar". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class BatchDeleteJobsRequest(proto.Message): - r"""Batch delete jobs request. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - filter (str): - Required. The filter string specifies the jobs to be - deleted. - - Supported operator: =, AND - - The fields eligible for filtering are: - - - ``companyName`` (Required) - - ``requisitionId`` (Required) - - Sample Query: companyName = "projects/foo/companies/bar" AND - requisitionId = "req-1". - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - filter = proto.Field( - proto.STRING, - number=2, - ) - - -class ListJobsRequest(proto.Message): - r"""List jobs request. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - filter (str): - Required. The filter string specifies the jobs to be - enumerated. - - Supported operator: =, AND - - The fields eligible for filtering are: - - - ``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" - - requisitionId = "req-1" - - requisitionId = "req-1" AND status = "EXPIRED". - page_token (str): - The starting point of a query result. - page_size (int): - The maximum number of jobs to be returned per page of - results. - - If - [job_view][google.cloud.talent.v4beta1.ListJobsRequest.job_view] - is set to - [JobView.JOB_VIEW_ID_ONLY][google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY], - the maximum allowed page size is 1000. Otherwise, the - maximum allowed page size is 100. - - Default is 100 if empty or a number < 1 is specified. - job_view (google.cloud.talent_v4beta1.types.JobView): - The desired job attributes returned for jobs in the search - response. Defaults to - [JobView.JOB_VIEW_FULL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL] - if no value is specified. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - filter = proto.Field( - proto.STRING, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - page_size = proto.Field( - proto.INT32, - number=4, - ) - job_view = proto.Field( - proto.ENUM, - number=5, - enum='JobView', - ) - - -class ListJobsResponse(proto.Message): - r"""List jobs response. - - Attributes: - jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): - The Jobs for a given company. - The maximum number of items returned is based on - the limit field provided in the request. - 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 - - jobs = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gct_job.Job, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - metadata = proto.Field( - proto.MESSAGE, - number=3, - message=common.ResponseMetadata, - ) - - -class SearchJobsRequest(proto.Message): - r"""The Request body of the ``SearchJobs`` 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/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - search_mode (google.cloud.talent_v4beta1.types.SearchJobsRequest.SearchMode): - Mode of a search. - - Defaults to - [SearchMode.JOB_SEARCH][google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH]. - request_metadata (google.cloud.talent_v4beta1.types.RequestMetadata): - Required. The meta information collected about the job - searcher, used to improve the search quality of the service. - The identifiers (such as ``user_id``) are provided by users, - and must be unique and consistent. - job_query (google.cloud.talent_v4beta1.types.JobQuery): - Query used to search against jobs, such as - keyword, location filters, etc. - enable_broadening (bool): - Controls whether to broaden the search when - it produces sparse results. Broadened queries - append results to the end of the matching - results list. - - Defaults to false. - require_precise_result_size (bool): - This field is deprecated. - histogram_queries (Sequence[google.cloud.talent_v4beta1.types.HistogramQuery]): - An expression specifies a histogram request against matching - jobs. - - Expression syntax is an aggregation function call with - histogram facets and other options. - - Available aggregation function calls are: - - - ``count(string_histogram_facet)``: Count the number of - matching entities, for each distinct attribute value. - - ``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 - ``[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 built-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). - - Job histogram facets: - - - company_display_name: histogram by - [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name]. - - employment_type: histogram by - [Job.employment_types][google.cloud.talent.v4beta1.Job.employment_types], - for example, "FULL_TIME", "PART_TIME". - - 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. - - publish_time_in_year: histogram by the - [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] - in years. Must specify list of numeric buckets in spec. - - degree_types: histogram by the - [Job.degree_types][google.cloud.talent.v4beta1.Job.degree_types], - for example, "Bachelors", "Masters". - - job_level: histogram by the - [Job.job_level][google.cloud.talent.v4beta1.Job.job_level], - for example, "Entry Level". - - country: histogram by the country code of jobs, for - example, "US", "FR". - - admin1: histogram by the admin1 code of jobs, which is a - global placeholder referring to the state, province, or - the particular term a country uses to define the - geographic structure below the country level, for - example, "CA", "IL". - - city: histogram by a combination of the "city name, - admin1 code". For example, "Mountain View, CA", "New - York, NY". - - admin1_country: histogram by a combination of the "admin1 - code, country", for example, "CA, US", "IL, US". - - city_coordinate: histogram by the city center's GPS - coordinates (latitude and longitude), for example, - 37.4038522,-122.0987765. Since the coordinates of a city - center can change, customers may need to refresh them - periodically. - - locale: histogram by the - [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], - for example, "en-US", "fr-FR". - - language: histogram by the language subtag of the - [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], - for example, "en", "fr". - - category: histogram by the - [JobCategory][google.cloud.talent.v4beta1.JobCategory], - for example, "COMPUTER_AND_IT", "HEALTHCARE". - - base_compensation_unit: histogram by the - [CompensationInfo.CompensationUnit][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit] - of base salary, for example, "WEEKLY", "MONTHLY". - - base_compensation: histogram by the base salary. Must - specify list of numeric buckets to group results by. - - annualized_base_compensation: histogram by the base - annualized salary. Must specify list of numeric buckets - to group results by. - - annualized_total_compensation: histogram by the total - annualized salary. Must specify list of numeric buckets - to group results by. - - string_custom_attribute: histogram by string - [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. - Values can be accessed via square bracket notations like - string_custom_attribute["key1"]. - - numeric_custom_attribute: histogram by numeric - [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. - Values can be accessed via square bracket notations like - numeric_custom_attribute["key1"]. Must specify list of - numeric buckets to group results by. - - Example expressions: - - - ``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")])`` - job_view (google.cloud.talent_v4beta1.types.JobView): - The desired job attributes returned for jobs in the search - response. Defaults to - [JobView.JOB_VIEW_SMALL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL] - if no value is specified. - offset (int): - An integer that specifies the current offset (that is, - starting result location, amongst the jobs deemed by the API - as relevant) in search results. This field is only - considered if - [page_token][google.cloud.talent.v4beta1.SearchJobsRequest.page_token] - is unset. - - The maximum allowed value is 5000. Otherwise an error is - thrown. - - For example, 0 means to return results starting from the - first matching job, and 10 means to return from the 11th - job. This can be used for pagination, (for example, pageSize - = 10 and offset = 10 means to return from the second page). - page_size (int): - A limit on the number of jobs returned in the - search results. Increasing this value above the - default value of 10 can increase search response - time. The value can be between 1 and 100. - page_token (str): - The token specifying the current offset within search - results. See - [SearchJobsResponse.next_page_token][google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token] - for an explanation of how to obtain the next set of query - results. - order_by (str): - The criteria determining how search results are sorted. - Default is ``"relevance desc"``. - - Supported options are: - - - ``"relevance desc"``: By relevance descending, as - determined by the API algorithms. Relevance thresholding - of query results is only available with this ordering. - - ``"posting_publish_time desc"``: By - [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] - descending. - - ``"posting_update_time desc"``: By - [Job.posting_update_time][google.cloud.talent.v4beta1.Job.posting_update_time] - descending. - - ``"title"``: By - [Job.title][google.cloud.talent.v4beta1.Job.title] - ascending. - - ``"title desc"``: By - [Job.title][google.cloud.talent.v4beta1.Job.title] - descending. - - ``"annualized_base_compensation"``: By job's - [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] - ascending. Jobs whose annualized base compensation is - unspecified are put at the end of search results. - - ``"annualized_base_compensation desc"``: By job's - [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] - descending. Jobs whose annualized base compensation is - unspecified are put at the end of search results. - - ``"annualized_total_compensation"``: By job's - [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] - ascending. Jobs whose annualized base compensation is - unspecified are put at the end of search results. - - ``"annualized_total_compensation desc"``: By job's - [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] - descending. Jobs whose annualized base compensation is - unspecified are put at the end of search results. - - ``"custom_ranking desc"``: By the relevance score - adjusted to the - [SearchJobsRequest.CustomRankingInfo.ranking_expression][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression] - with weight factor assigned by - [SearchJobsRequest.CustomRankingInfo.importance_level][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level] - in descending order. - - Location sorting: Use the special syntax to order jobs by - distance: ``"distance_from('Hawaii')"``: Order by - distance from Hawaii. ``"distance_from(19.89, 155.5)"``: - Order by distance from a coordinate. - ``"distance_from('Hawaii'), distance_from('Puerto Rico')"``: - Order by multiple locations. See details below. - ``"distance_from('Hawaii'), distance_from(19.89, 155.5)"``: - Order by multiple locations. See details below. The - string can have a maximum of 256 characters. When - multiple distance centers are provided, a job that is - close to any of the distance centers would have a high - rank. When a job has multiple locations, the job location - closest to one of the distance centers will be used. Jobs - that don't have locations will be ranked at the bottom. - Distance is calculated with a precision of 11.3 meters - (37.4 feet). Diversification strategy is still applied - unless explicitly disabled in - [diversification_level][google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level]. - diversification_level (google.cloud.talent_v4beta1.types.SearchJobsRequest.DiversificationLevel): - Controls whether highly similar jobs are returned next to - each other in the search results. Jobs are identified as - highly similar based on their titles, job categories, and - locations. Highly similar results are clustered so that only - one representative job of the cluster is displayed to the - job seeker higher up in the results, with the other jobs - being displayed lower down in the results. - - Defaults to - [DiversificationLevel.SIMPLE][google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE] - if no value is specified. - custom_ranking_info (google.cloud.talent_v4beta1.types.SearchJobsRequest.CustomRankingInfo): - Controls over how job documents get ranked on - 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], - [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name], - [Job.addresses][google.cloud.talent.v4beta1.Job.addresses], - [Job.qualifications][google.cloud.talent.v4beta1.Job.qualifications]. - When disable keyword match is turned off, a keyword match - returns jobs that do not match given category filters when - there are matching keywords. For example, for the query - "program manager," a result is returned even if the job - posting has the title "software developer," which doesn't - fall into "program manager" ontology, but does have "program - manager" appearing in its description. - - For queries like "cloud" that don't contain title or - location specific ontology, jobs with "cloud" keyword - matches are returned regardless of this flag'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. - - 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): - r"""A string-represented enumeration of the job search mode. The - service operate differently for different modes of service. - """ - SEARCH_MODE_UNSPECIFIED = 0 - JOB_SEARCH = 1 - FEATURED_JOB_SEARCH = 2 - - class DiversificationLevel(proto.Enum): - r"""Controls whether highly similar jobs are returned next to - each other in the search results. Jobs are identified as highly - similar based on their titles, job categories, and locations. - Highly similar results are clustered so that only one - representative job of the cluster is displayed to the job seeker - higher up in the results, with the other jobs being displayed - lower down in the results. - """ - DIVERSIFICATION_LEVEL_UNSPECIFIED = 0 - 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]. - - Attributes: - importance_level (google.cloud.talent_v4beta1.types.SearchJobsRequest.CustomRankingInfo.ImportanceLevel): - Required. Controls over how important the score of - [CustomRankingInfo.ranking_expression][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression] - gets applied to job's final ranking position. - - An error is thrown if not specified. - ranking_expression (str): - Required. Controls over how job documents get ranked on top - of existing relevance score (determined by API algorithm). A - combination of the ranking expression and relevance score is - used to determine job's final ranking position. - - The syntax for this expression is a subset of Google SQL - syntax. - - Supported operators are: +, -, \*, /, where the left and - right side of the operator is either a numeric - [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes] - key, integer/double value or an expression that can be - evaluated to a number. - - Parenthesis are supported to adjust calculation precedence. - 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 - populated on the job or if the expression results in a - divide by zero. If an expression is invalid for a job, that - job is demoted to the end of the results. - - Sample ranking expression (year + 25) \* 0.25 - (freshness / - 0.5) - """ - class ImportanceLevel(proto.Enum): - r"""The importance level for - [CustomRankingInfo.ranking_expression][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression]. - """ - IMPORTANCE_LEVEL_UNSPECIFIED = 0 - NONE = 1 - LOW = 2 - MILD = 3 - MEDIUM = 4 - HIGH = 5 - EXTREME = 6 - - importance_level = proto.Field( - proto.ENUM, - number=1, - enum='SearchJobsRequest.CustomRankingInfo.ImportanceLevel', - ) - ranking_expression = proto.Field( - proto.STRING, - number=2, - ) - - parent = proto.Field( - proto.STRING, - number=1, - ) - search_mode = proto.Field( - proto.ENUM, - number=2, - enum=SearchMode, - ) - request_metadata = proto.Field( - proto.MESSAGE, - number=3, - message=common.RequestMetadata, - ) - job_query = proto.Field( - proto.MESSAGE, - number=4, - message=filters.JobQuery, - ) - enable_broadening = proto.Field( - proto.BOOL, - number=5, - ) - require_precise_result_size = proto.Field( - proto.BOOL, - number=6, - ) - histogram_queries = proto.RepeatedField( - proto.MESSAGE, - number=7, - message=histogram.HistogramQuery, - ) - job_view = proto.Field( - proto.ENUM, - number=8, - enum='JobView', - ) - offset = proto.Field( - proto.INT32, - number=9, - ) - page_size = proto.Field( - proto.INT32, - number=10, - ) - page_token = proto.Field( - proto.STRING, - number=11, - ) - order_by = proto.Field( - proto.STRING, - number=12, - ) - diversification_level = proto.Field( - proto.ENUM, - number=13, - enum=DiversificationLevel, - ) - custom_ranking_info = proto.Field( - proto.MESSAGE, - number=14, - message=CustomRankingInfo, - ) - disable_keyword_match = proto.Field( - proto.BOOL, - number=16, - ) - keyword_match_mode = proto.Field( - proto.ENUM, - number=18, - enum=KeywordMatchMode, - ) - - -class SearchJobsResponse(proto.Message): - r"""Response for SearchJob method. - - Attributes: - matching_jobs (Sequence[google.cloud.talent_v4beta1.types.SearchJobsResponse.MatchingJob]): - The Job entities that match the specified - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - histogram_query_results (Sequence[google.cloud.talent_v4beta1.types.HistogramQueryResult]): - The histogram results that match with specified - [SearchJobsRequest.histogram_queries][google.cloud.talent.v4beta1.SearchJobsRequest.histogram_queries]. - next_page_token (str): - The token that specifies the starting - position of the next page of results. This field - is empty if there are no more results. - location_filters (Sequence[google.cloud.talent_v4beta1.types.Location]): - The location filters that the service applied to the - specified query. If any filters are lat-lng based, the - [Location.location_type][google.cloud.talent.v4beta1.Location.location_type] - is - [Location.LocationType.LOCATION_TYPE_UNSPECIFIED][google.cloud.talent.v4beta1.Location.LocationType.LOCATION_TYPE_UNSPECIFIED]. - estimated_total_size (int): - An estimation of the number of jobs that match the specified - query. - - This number isn't guaranteed to be accurate. For accurate - results, see - [SearchJobsResponse.total_size][google.cloud.talent.v4beta1.SearchJobsResponse.total_size]. - total_size (int): - 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. - broadened_query_jobs_count (int): - If query broadening is enabled, we may append - additional results from the broadened query. - This number indicates how many of the jobs - returned in the jobs field are from the - broadened query. These results are always at the - end of the jobs list. In particular, a value of - 0, or if the field isn't set, all the jobs in - the jobs list are from the original (without - broadening) query. If this field is non-zero, - subsequent requests with offset after this - result set should contain all broadened results. - spell_correction (google.cloud.talent_v4beta1.types.SpellingCorrection): - The spell checking result, and correction. - """ - - class MatchingJob(proto.Message): - r"""Job entry with metadata inside - [SearchJobsResponse][google.cloud.talent.v4beta1.SearchJobsResponse]. - - Attributes: - job (google.cloud.talent_v4beta1.types.Job): - Job resource that matches the specified - [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. - job_summary (str): - A summary of the job with core information - that's displayed on the search results listing - page. - job_title_snippet (str): - Contains snippets of text from the - [Job.title][google.cloud.talent.v4beta1.Job.title] field - most closely matching a search query's keywords, if - available. The matching query keywords are enclosed in HTML - bold tags. - search_text_snippet (str): - Contains snippets of text from the - [Job.description][google.cloud.talent.v4beta1.Job.description] - and similar fields that most closely match a search query's - keywords, if available. All HTML tags in the original fields - are stripped when returned in this field, and matching query - keywords are enclosed in HTML bold tags. - commute_info (google.cloud.talent_v4beta1.types.SearchJobsResponse.CommuteInfo): - Commute information which is generated based on specified - [CommuteFilter][google.cloud.talent.v4beta1.CommuteFilter]. - """ - - job = proto.Field( - proto.MESSAGE, - number=1, - message=gct_job.Job, - ) - job_summary = proto.Field( - proto.STRING, - number=2, - ) - job_title_snippet = proto.Field( - proto.STRING, - number=3, - ) - search_text_snippet = proto.Field( - proto.STRING, - number=4, - ) - commute_info = proto.Field( - proto.MESSAGE, - number=5, - message='SearchJobsResponse.CommuteInfo', - ) - - class CommuteInfo(proto.Message): - r"""Commute details related to this job. - - Attributes: - job_location (google.cloud.talent_v4beta1.types.Location): - Location used as the destination in the - commute calculation. - travel_duration (google.protobuf.duration_pb2.Duration): - The number of seconds required to travel to - the job location from the query location. A - duration of 0 seconds indicates that the job - isn't reachable within the requested duration, - but was returned as part of an expanded query. - """ - - job_location = proto.Field( - proto.MESSAGE, - number=1, - message=common.Location, - ) - travel_duration = proto.Field( - proto.MESSAGE, - number=2, - message=duration_pb2.Duration, - ) - - @property - def raw_page(self): - return self - - matching_jobs = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=MatchingJob, - ) - histogram_query_results = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=histogram.HistogramQueryResult, - ) - next_page_token = proto.Field( - proto.STRING, - number=3, - ) - location_filters = proto.RepeatedField( - proto.MESSAGE, - number=4, - message=common.Location, - ) - estimated_total_size = proto.Field( - proto.INT32, - number=5, - ) - total_size = proto.Field( - proto.INT32, - number=6, - ) - metadata = proto.Field( - proto.MESSAGE, - number=7, - message=common.ResponseMetadata, - ) - broadened_query_jobs_count = proto.Field( - proto.INT32, - number=8, - ) - spell_correction = proto.Field( - proto.MESSAGE, - number=9, - message=common.SpellingCorrection, - ) - - -class BatchCreateJobsRequest(proto.Message): - r"""Request to create a batch of jobs. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): - Required. The jobs to be created. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - jobs = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=gct_job.Job, - ) - - -class BatchUpdateJobsRequest(proto.Message): - r"""Request to update a batch of jobs. - - Attributes: - parent (str): - Required. The resource name of the tenant under which the - job is created. - - The format is "projects/{project_id}/tenants/{tenant_id}". - For example, "projects/foo/tenant/bar". If tenant id is - unspecified, a default tenant is created. For example, - "projects/foo". - jobs (Sequence[google.cloud.talent_v4beta1.types.Job]): - Required. The jobs to be updated. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Strongly recommended for the best service experience. Be - aware that it will also increase latency when checking the - status of a batch operation. - - If - [update_mask][google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask] - is provided, only the specified fields in - [Job][google.cloud.talent.v4beta1.Job] are updated. - Otherwise all the fields are updated. - - A field mask to restrict the fields that are updated. Only - top level fields of [Job][google.cloud.talent.v4beta1.Job] - are supported. - - If - [update_mask][google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask] - is provided, The [Job][google.cloud.talent.v4beta1.Job] - inside - [JobResult][google.cloud.talent.v4beta1.JobOperationResult.JobResult] - will only contains fields that is updated, plus the Id of - the Job. Otherwise, [Job][google.cloud.talent.v4beta1.Job] - will include all fields, which can yield a very large - response. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - jobs = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=gct_job.Job, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) - - -class JobOperationResult(proto.Message): - r"""The result of - [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs] - or - [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs] - APIs. It's used to replace - [google.longrunning.Operation.response][google.longrunning.Operation.response] - in case of success. - - Attributes: - job_results (Sequence[google.cloud.talent_v4beta1.types.JobOperationResult.JobResult]): - List of job mutation results from a batch - mutate operation. It can change until operation - status is FINISHED, FAILED or CANCELLED. - """ - - class JobResult(proto.Message): - r"""Mutation result of a job. - - Attributes: - job (google.cloud.talent_v4beta1.types.Job): - Here [Job][google.cloud.talent.v4beta1.Job] only contains - basic information including - [name][google.cloud.talent.v4beta1.Job.name], - [company][google.cloud.talent.v4beta1.Job.company], - [language_code][google.cloud.talent.v4beta1.Job.language_code] - and - [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id], - use getJob method to retrieve detailed information of the - created/updated job. - status (google.rpc.status_pb2.Status): - The status of the job processed. This field is populated if - the processing of the - [job][google.cloud.talent.v4beta1.JobOperationResult.JobResult.job] - fails. - """ - - job = proto.Field( - proto.MESSAGE, - number=1, - message=gct_job.Job, - ) - status = proto.Field( - proto.MESSAGE, - number=2, - message=status_pb2.Status, - ) - - job_results = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=JobResult, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant.py deleted file mode 100644 index 842f5d71..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant.py +++ /dev/null @@ -1,91 +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 proto # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'Tenant', - }, -) - - -class Tenant(proto.Message): - r"""A Tenant resource represents a tenant in the service. A - tenant is a group or entity that shares common access with - specific privileges for resources like profiles. Customer may - create multiple tenants to provide data isolation for different - groups. - - Attributes: - name (str): - Required during tenant update. - - The resource name for a tenant. This is generated by the - service when a tenant is created. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - external_id (str): - Required. Client side tenant identifier, used - to uniquely identify the tenant. - The maximum number of allowed characters is 255. - usage_type (google.cloud.talent_v4beta1.types.Tenant.DataUsageType): - Indicates whether data owned by this tenant may be used to - provide product improvements across other tenants. - - Defaults behavior is - [DataUsageType.ISOLATED][google.cloud.talent.v4beta1.Tenant.DataUsageType.ISOLATED] - if it's unset. - keyword_searchable_profile_custom_attributes (Sequence[str]): - A list of keys of filterable - [Profile.custom_attributes][google.cloud.talent.v4beta1.Profile.custom_attributes], - whose corresponding ``string_values`` are used in keyword - searches. Profiles with ``string_values`` under these - specified field keys are returned if any of the values match - the search keyword. Custom field values with parenthesis, - brackets and special symbols are not searchable as-is, and - must be surrounded by quotes. - """ - class DataUsageType(proto.Enum): - r"""Enum that represents how user data owned by the tenant is - used. - """ - DATA_USAGE_TYPE_UNSPECIFIED = 0 - AGGREGATED = 1 - ISOLATED = 2 - - name = proto.Field( - proto.STRING, - number=1, - ) - external_id = proto.Field( - proto.STRING, - number=2, - ) - usage_type = proto.Field( - proto.ENUM, - number=3, - enum=DataUsageType, - ) - keyword_searchable_profile_custom_attributes = proto.RepeatedField( - proto.STRING, - number=4, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant_service.py b/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant_service.py deleted file mode 100644 index dae84765..00000000 --- a/owl-bot-staging/v4beta1/google/cloud/talent_v4beta1/types/tenant_service.py +++ /dev/null @@ -1,194 +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 proto # type: ignore - -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import tenant as gct_tenant -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.talent.v4beta1', - manifest={ - 'CreateTenantRequest', - 'GetTenantRequest', - 'UpdateTenantRequest', - 'DeleteTenantRequest', - 'ListTenantsRequest', - 'ListTenantsResponse', - }, -) - - -class CreateTenantRequest(proto.Message): - r"""The Request of the CreateTenant method. - - Attributes: - parent (str): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - tenant (google.cloud.talent_v4beta1.types.Tenant): - Required. The tenant to be created. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - tenant = proto.Field( - proto.MESSAGE, - number=2, - message=gct_tenant.Tenant, - ) - - -class GetTenantRequest(proto.Message): - r"""Request for getting a tenant by name. - - Attributes: - name (str): - Required. The resource name of the tenant to be retrieved. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateTenantRequest(proto.Message): - r"""Request for updating a specified tenant. - - Attributes: - tenant (google.cloud.talent_v4beta1.types.Tenant): - Required. The tenant 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.UpdateTenantRequest.update_mask] - is provided, only the specified fields in - [tenant][google.cloud.talent.v4beta1.UpdateTenantRequest.tenant] - are updated. Otherwise all the fields are updated. - - A field mask to specify the tenant fields to be updated. - Only top level fields of - [Tenant][google.cloud.talent.v4beta1.Tenant] are supported. - """ - - tenant = proto.Field( - proto.MESSAGE, - number=1, - message=gct_tenant.Tenant, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteTenantRequest(proto.Message): - r"""Request to delete a tenant. - - Attributes: - name (str): - Required. The resource name of the tenant to be deleted. - - The format is "projects/{project_id}/tenants/{tenant_id}", - for example, "projects/foo/tenants/bar". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListTenantsRequest(proto.Message): - r"""List tenants for which the client has ACL visibility. - - Attributes: - parent (str): - Required. Resource name of the project under which the - tenant is created. - - The format is "projects/{project_id}", for example, - "projects/foo". - page_token (str): - The starting indicator from which to return - results. - page_size (int): - The maximum number of tenants 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 ListTenantsResponse(proto.Message): - r"""The List tenants response object. - - Attributes: - tenants (Sequence[google.cloud.talent_v4beta1.types.Tenant]): - Tenants 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 - - tenants = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gct_tenant.Tenant, - ) - 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/owl-bot-staging/v4beta1/mypy.ini b/owl-bot-staging/v4beta1/mypy.ini deleted file mode 100644 index 574c5aed..00000000 --- a/owl-bot-staging/v4beta1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.7 -namespace_packages = True diff --git a/owl-bot-staging/v4beta1/noxfile.py b/owl-bot-staging/v4beta1/noxfile.py deleted file mode 100644 index 46aafa08..00000000 --- a/owl-bot-staging/v4beta1/noxfile.py +++ /dev/null @@ -1,179 +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 -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -ALL_PYTHON = [ - "3.7", - "3.8", - "3.9", - "3.10", -] - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - -BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] -DEFAULT_PYTHON_VERSION = "3.10" - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", - "blacken", - "lint", - "lint_setup_py", -] - -@nox.session(python=ALL_PYTHON) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/talent_v4beta1/', - '--cov=tests/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - 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", "erase") - - -@nox.session(python=ALL_PYTHON) -def mypy(session): - """Run the type checker.""" - session.install('mypy', 'types-pkg_resources') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx==4.0.1", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): - """Run linters. - - Returns a failure if the linters find linting errors or sufficiently - serious code quality issues. - """ - session.install("flake8", BLACK_VERSION) - session.run( - "black", - "--check", - *BLACK_PATHS, - ) - session.run("flake8", "google", "tests", "samples") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def blacken(session): - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - session.run( - "black", - *BLACK_PATHS, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint_setup_py(session): - """Verify that setup.py is valid (including RST check).""" - session.install("docutils", "pygments") - session.run("python", "setup.py", "check", "--restructuredtext", "--strict") diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py deleted file mode 100644 index beb39636..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py +++ /dev/null @@ -1,57 +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 CreateCompany -# 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_CompanyService_CreateCompany_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_create_company(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - company = talent_v4beta1.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4beta1.CreateCompanyRequest( - parent="parent_value", - company=company, - ) - - # Make the request - response = await client.create_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_CompanyService_CreateCompany_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py deleted file mode 100644 index 3c09bc1f..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py +++ /dev/null @@ -1,57 +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 CreateCompany -# 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_CompanyService_CreateCompany_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_create_company(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - company = talent_v4beta1.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4beta1.CreateCompanyRequest( - parent="parent_value", - company=company, - ) - - # Make the request - response = client.create_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_CompanyService_CreateCompany_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py deleted file mode 100644 index 3afbe7d5..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_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 DeleteCompany -# 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_CompanyService_DeleteCompany_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_delete_company(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteCompanyRequest( - name="name_value", - ) - - # Make the request - await client.delete_company(request=request) - - -# [END jobs_v4beta1_generated_CompanyService_DeleteCompany_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py deleted file mode 100644 index efaed012..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_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 DeleteCompany -# 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_CompanyService_DeleteCompany_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_delete_company(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteCompanyRequest( - name="name_value", - ) - - # Make the request - client.delete_company(request=request) - - -# [END jobs_v4beta1_generated_CompanyService_DeleteCompany_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py deleted file mode 100644 index f3c4a42a..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py +++ /dev/null @@ -1,52 +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 GetCompany -# 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_CompanyService_GetCompany_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_get_company(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetCompanyRequest( - name="name_value", - ) - - # Make the request - response = await client.get_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_CompanyService_GetCompany_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py deleted file mode 100644 index e8d8e57d..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py +++ /dev/null @@ -1,52 +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 GetCompany -# 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_CompanyService_GetCompany_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_get_company(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetCompanyRequest( - name="name_value", - ) - - # Make the request - response = client.get_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_CompanyService_GetCompany_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py deleted file mode 100644 index 4b45b106..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py +++ /dev/null @@ -1,53 +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 ListCompanies -# 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_CompanyService_ListCompanies_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_list_companies(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListCompaniesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_companies(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_CompanyService_ListCompanies_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py deleted file mode 100644 index 77f31bc4..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py +++ /dev/null @@ -1,53 +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 ListCompanies -# 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_CompanyService_ListCompanies_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_list_companies(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListCompaniesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_companies(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_CompanyService_ListCompanies_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py deleted file mode 100644 index cf6bd525..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py +++ /dev/null @@ -1,56 +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 UpdateCompany -# 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_CompanyService_UpdateCompany_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_update_company(): - # Create a client - client = talent_v4beta1.CompanyServiceAsyncClient() - - # Initialize request argument(s) - company = talent_v4beta1.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4beta1.UpdateCompanyRequest( - company=company, - ) - - # Make the request - response = await client.update_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_CompanyService_UpdateCompany_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py deleted file mode 100644 index 091111cf..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py +++ /dev/null @@ -1,56 +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 UpdateCompany -# 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_CompanyService_UpdateCompany_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_update_company(): - # Create a client - client = talent_v4beta1.CompanyServiceClient() - - # Initialize request argument(s) - company = talent_v4beta1.Company() - company.display_name = "display_name_value" - company.external_id = "external_id_value" - - request = talent_v4beta1.UpdateCompanyRequest( - company=company, - ) - - # Make the request - response = client.update_company(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_CompanyService_UpdateCompany_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py deleted file mode 100644 index 79699ead..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py +++ /dev/null @@ -1,54 +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 CompleteQuery -# 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_Completion_CompleteQuery_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_complete_query(): - # Create a client - client = talent_v4beta1.CompletionAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.CompleteQueryRequest( - parent="parent_value", - query="query_value", - page_size=951, - ) - - # Make the request - response = await client.complete_query(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_Completion_CompleteQuery_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py deleted file mode 100644 index 9d46cef2..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py +++ /dev/null @@ -1,54 +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 CompleteQuery -# 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_Completion_CompleteQuery_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_complete_query(): - # Create a client - client = talent_v4beta1.CompletionClient() - - # Initialize request argument(s) - request = talent_v4beta1.CompleteQueryRequest( - parent="parent_value", - query="query_value", - page_size=951, - ) - - # Make the request - response = client.complete_query(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_Completion_CompleteQuery_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py deleted file mode 100644 index d6a45c89..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py +++ /dev/null @@ -1,58 +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 CreateClientEvent -# 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_EventService_CreateClientEvent_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_create_client_event(): - # Create a client - client = talent_v4beta1.EventServiceAsyncClient() - - # Initialize request argument(s) - client_event = talent_v4beta1.ClientEvent() - client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] - client_event.event_id = "event_id_value" - - request = talent_v4beta1.CreateClientEventRequest( - parent="parent_value", - client_event=client_event, - ) - - # Make the request - response = await client.create_client_event(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_EventService_CreateClientEvent_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py deleted file mode 100644 index 15421a47..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py +++ /dev/null @@ -1,58 +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 CreateClientEvent -# 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_EventService_CreateClientEvent_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_create_client_event(): - # Create a client - client = talent_v4beta1.EventServiceClient() - - # Initialize request argument(s) - client_event = talent_v4beta1.ClientEvent() - client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] - client_event.event_id = "event_id_value" - - request = talent_v4beta1.CreateClientEventRequest( - parent="parent_value", - client_event=client_event, - ) - - # Make the request - response = client.create_client_event(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_EventService_CreateClientEvent_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py deleted file mode 100644 index 6a13b56b..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py +++ /dev/null @@ -1,63 +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 BatchCreateJobs -# 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_JobService_BatchCreateJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_batch_create_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - jobs = talent_v4beta1.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4beta1.BatchCreateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_create_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_BatchCreateJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py deleted file mode 100644 index 0bd3f5ed..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py +++ /dev/null @@ -1,63 +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 BatchCreateJobs -# 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_JobService_BatchCreateJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_batch_create_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - jobs = talent_v4beta1.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4beta1.BatchCreateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_create_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_BatchCreateJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py deleted file mode 100644 index 43bcb71e..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_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 BatchDeleteJobs -# 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_JobService_BatchDeleteJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_batch_delete_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.BatchDeleteJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - await client.batch_delete_jobs(request=request) - - -# [END jobs_v4beta1_generated_JobService_BatchDeleteJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py deleted file mode 100644 index 953ac105..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_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 BatchDeleteJobs -# 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_JobService_BatchDeleteJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_batch_delete_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.BatchDeleteJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - client.batch_delete_jobs(request=request) - - -# [END jobs_v4beta1_generated_JobService_BatchDeleteJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py deleted file mode 100644 index 698e644d..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py +++ /dev/null @@ -1,63 +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 BatchUpdateJobs -# 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_JobService_BatchUpdateJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_batch_update_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - jobs = talent_v4beta1.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4beta1.BatchUpdateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_update_jobs(request=request) - - print("Waiting for operation to complete...") - - response = await operation.result() - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_BatchUpdateJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py deleted file mode 100644 index e80971da..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py +++ /dev/null @@ -1,63 +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 BatchUpdateJobs -# 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_JobService_BatchUpdateJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_batch_update_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - jobs = talent_v4beta1.Job() - jobs.company = "company_value" - jobs.requisition_id = "requisition_id_value" - jobs.title = "title_value" - jobs.description = "description_value" - - request = talent_v4beta1.BatchUpdateJobsRequest( - parent="parent_value", - jobs=jobs, - ) - - # Make the request - operation = client.batch_update_jobs(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_BatchUpdateJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py deleted file mode 100644 index 7e36a95f..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py +++ /dev/null @@ -1,59 +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 CreateJob -# 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_JobService_CreateJob_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_create_job(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - job = talent_v4beta1.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4beta1.CreateJobRequest( - parent="parent_value", - job=job, - ) - - # Make the request - response = await client.create_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_CreateJob_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py deleted file mode 100644 index 600d8be9..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py +++ /dev/null @@ -1,59 +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 CreateJob -# 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_JobService_CreateJob_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_create_job(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - job = talent_v4beta1.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4beta1.CreateJobRequest( - parent="parent_value", - job=job, - ) - - # Make the request - response = client.create_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_CreateJob_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py deleted file mode 100644 index ad8224b5..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_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 DeleteJob -# 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_JobService_DeleteJob_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_delete_job(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteJobRequest( - name="name_value", - ) - - # Make the request - await client.delete_job(request=request) - - -# [END jobs_v4beta1_generated_JobService_DeleteJob_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py deleted file mode 100644 index 1ef01e19..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_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 DeleteJob -# 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_JobService_DeleteJob_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_delete_job(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteJobRequest( - name="name_value", - ) - - # Make the request - client.delete_job(request=request) - - -# [END jobs_v4beta1_generated_JobService_DeleteJob_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py deleted file mode 100644 index d9a57ad5..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py +++ /dev/null @@ -1,52 +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 GetJob -# 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_JobService_GetJob_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_get_job(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetJobRequest( - name="name_value", - ) - - # Make the request - response = await client.get_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_GetJob_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py deleted file mode 100644 index 4a9bc662..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py +++ /dev/null @@ -1,52 +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 GetJob -# 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_JobService_GetJob_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_get_job(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetJobRequest( - name="name_value", - ) - - # Make the request - response = client.get_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_GetJob_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py deleted file mode 100644 index 5ec12499..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py +++ /dev/null @@ -1,54 +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 ListJobs -# 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_JobService_ListJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_list_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - page_result = client.list_jobs(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_JobService_ListJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py deleted file mode 100644 index 793a4653..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py +++ /dev/null @@ -1,54 +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 ListJobs -# 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_JobService_ListJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_list_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListJobsRequest( - parent="parent_value", - filter="filter_value", - ) - - # Make the request - page_result = client.list_jobs(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_JobService_ListJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py deleted file mode 100644 index 9f5a1335..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py +++ /dev/null @@ -1,53 +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 SearchJobs -# 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_JobService_SearchJobs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_search_jobs(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_jobs(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_JobService_SearchJobs_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py deleted file mode 100644 index eeffc48d..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py +++ /dev/null @@ -1,53 +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 SearchJobsForAlert -# 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_JobService_SearchJobsForAlert_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_search_jobs_for_alert(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_jobs_for_alert(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_JobService_SearchJobsForAlert_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py deleted file mode 100644 index 93c7cd15..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py +++ /dev/null @@ -1,53 +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 SearchJobsForAlert -# 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_JobService_SearchJobsForAlert_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_search_jobs_for_alert(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_jobs_for_alert(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_JobService_SearchJobsForAlert_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py deleted file mode 100644 index 0df23612..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py +++ /dev/null @@ -1,53 +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 SearchJobs -# 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_JobService_SearchJobs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_search_jobs(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.SearchJobsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.search_jobs(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_JobService_SearchJobs_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py deleted file mode 100644 index 60555fa8..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py +++ /dev/null @@ -1,58 +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 UpdateJob -# 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_JobService_UpdateJob_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_update_job(): - # Create a client - client = talent_v4beta1.JobServiceAsyncClient() - - # Initialize request argument(s) - job = talent_v4beta1.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4beta1.UpdateJobRequest( - job=job, - ) - - # Make the request - response = await client.update_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_UpdateJob_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py deleted file mode 100644 index 8170b2d5..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py +++ /dev/null @@ -1,58 +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 UpdateJob -# 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_JobService_UpdateJob_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_update_job(): - # Create a client - client = talent_v4beta1.JobServiceClient() - - # Initialize request argument(s) - job = talent_v4beta1.Job() - job.company = "company_value" - job.requisition_id = "requisition_id_value" - job.title = "title_value" - job.description = "description_value" - - request = talent_v4beta1.UpdateJobRequest( - job=job, - ) - - # Make the request - response = client.update_job(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_JobService_UpdateJob_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py deleted file mode 100644 index 239e5dbd..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py +++ /dev/null @@ -1,56 +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 CreateTenant -# 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_TenantService_CreateTenant_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_create_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - tenant = talent_v4beta1.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4beta1.CreateTenantRequest( - parent="parent_value", - tenant=tenant, - ) - - # Make the request - response = await client.create_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_TenantService_CreateTenant_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py deleted file mode 100644 index a8673253..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py +++ /dev/null @@ -1,56 +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 CreateTenant -# 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_TenantService_CreateTenant_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_create_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - tenant = talent_v4beta1.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4beta1.CreateTenantRequest( - parent="parent_value", - tenant=tenant, - ) - - # Make the request - response = client.create_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_TenantService_CreateTenant_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py deleted file mode 100644 index 3425f2e7..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_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 DeleteTenant -# 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_TenantService_DeleteTenant_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_delete_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteTenantRequest( - name="name_value", - ) - - # Make the request - await client.delete_tenant(request=request) - - -# [END jobs_v4beta1_generated_TenantService_DeleteTenant_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py deleted file mode 100644 index 756cb030..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_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 DeleteTenant -# 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_TenantService_DeleteTenant_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_delete_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.DeleteTenantRequest( - name="name_value", - ) - - # Make the request - client.delete_tenant(request=request) - - -# [END jobs_v4beta1_generated_TenantService_DeleteTenant_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py deleted file mode 100644 index 492c8e7d..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py +++ /dev/null @@ -1,52 +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 GetTenant -# 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_TenantService_GetTenant_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_get_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetTenantRequest( - name="name_value", - ) - - # Make the request - response = await client.get_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_TenantService_GetTenant_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py deleted file mode 100644 index 1bfdfab9..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py +++ /dev/null @@ -1,52 +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 GetTenant -# 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_TenantService_GetTenant_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_get_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.GetTenantRequest( - name="name_value", - ) - - # Make the request - response = client.get_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_TenantService_GetTenant_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py deleted file mode 100644 index fc99a810..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py +++ /dev/null @@ -1,53 +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 ListTenants -# 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_TenantService_ListTenants_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_list_tenants(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListTenantsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_tenants(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_TenantService_ListTenants_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py deleted file mode 100644 index 08f8a75c..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py +++ /dev/null @@ -1,53 +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 ListTenants -# 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_TenantService_ListTenants_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_list_tenants(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - request = talent_v4beta1.ListTenantsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_tenants(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END jobs_v4beta1_generated_TenantService_ListTenants_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py deleted file mode 100644 index 7f60e81e..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py +++ /dev/null @@ -1,55 +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 UpdateTenant -# 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_TenantService_UpdateTenant_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -async def sample_update_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceAsyncClient() - - # Initialize request argument(s) - tenant = talent_v4beta1.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4beta1.UpdateTenantRequest( - tenant=tenant, - ) - - # Make the request - response = await client.update_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_TenantService_UpdateTenant_async] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py b/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py deleted file mode 100644 index 60849278..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py +++ /dev/null @@ -1,55 +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 UpdateTenant -# 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_TenantService_UpdateTenant_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import talent_v4beta1 - - -def sample_update_tenant(): - # Create a client - client = talent_v4beta1.TenantServiceClient() - - # Initialize request argument(s) - tenant = talent_v4beta1.Tenant() - tenant.external_id = "external_id_value" - - request = talent_v4beta1.UpdateTenantRequest( - tenant=tenant, - ) - - # Make the request - response = client.update_tenant(request=request) - - # Handle the response - print(response) - -# [END jobs_v4beta1_generated_TenantService_UpdateTenant_sync] diff --git a/owl-bot-staging/v4beta1/samples/generated_samples/snippet_metadata_talent_v4beta1.json b/owl-bot-staging/v4beta1/samples/generated_samples/snippet_metadata_talent_v4beta1.json deleted file mode 100644 index 5b2bf382..00000000 --- a/owl-bot-staging/v4beta1/samples/generated_samples/snippet_metadata_talent_v4beta1.json +++ /dev/null @@ -1,3572 +0,0 @@ -{ - "clientLibrary": { - "apis": [ - { - "id": "google.cloud.talent.v4beta1", - "version": "v4beta1" - } - ], - "language": "PYTHON", - "name": "google-cloud-talent" - }, - "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient", - "shortName": "CompanyServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.CompanyServiceAsyncClient.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_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_CompanyService_CreateCompany_async", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_company_service_create_company_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.CompanyServiceClient", - "shortName": "CompanyServiceClient" - }, - "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": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "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": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "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": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "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": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "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": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "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": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "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": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "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": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "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": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "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": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "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": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "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": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "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": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "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": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "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": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "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": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "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": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "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": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "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": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "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": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "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": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "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": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "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", - "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_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_DeleteJob_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_delete_job_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.get_job", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.GetJob", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "GetJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetJobRequest" - }, - { - "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.Job", - "shortName": "get_job" - }, - "description": "Sample for GetJob", - "file": "jobs_v4beta1_generated_job_service_get_job_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_GetJob_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_get_job_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.get_job", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.GetJob", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "GetJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetJobRequest" - }, - { - "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.Job", - "shortName": "get_job" - }, - "description": "Sample for GetJob", - "file": "jobs_v4beta1_generated_job_service_get_job_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_GetJob_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_get_job_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.list_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.ListJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "ListJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListJobsRequest" - }, - { - "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]" - } - ], - "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsAsyncPager", - "shortName": "list_jobs" - }, - "description": "Sample for ListJobs", - "file": "jobs_v4beta1_generated_job_service_list_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_async", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_list_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.list_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.ListJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "ListJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListJobsRequest" - }, - { - "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]" - } - ], - "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsPager", - "shortName": "list_jobs" - }, - "description": "Sample for ListJobs", - "file": "jobs_v4beta1_generated_job_service_list_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_sync", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_list_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.search_jobs_for_alert", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "SearchJobsForAlert" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" - }, - { - "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.job_service.pagers.SearchJobsForAlertAsyncPager", - "shortName": "search_jobs_for_alert" - }, - "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_JobService_SearchJobsForAlert_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.search_jobs_for_alert", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "SearchJobsForAlert" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" - }, - { - "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.job_service.pagers.SearchJobsForAlertPager", - "shortName": "search_jobs_for_alert" - }, - "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_JobService_SearchJobsForAlert_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.search_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "SearchJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" - }, - { - "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.job_service.pagers.SearchJobsAsyncPager", - "shortName": "search_jobs" - }, - "description": "Sample for SearchJobs", - "file": "jobs_v4beta1_generated_job_service_search_jobs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_search_jobs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.search_jobs", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.SearchJobs", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "SearchJobs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.SearchJobsRequest" - }, - { - "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.job_service.pagers.SearchJobsPager", - "shortName": "search_jobs" - }, - "description": "Sample for SearchJobs", - "file": "jobs_v4beta1_generated_job_service_search_jobs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_search_jobs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient", - "shortName": "JobServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceAsyncClient.update_job", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.UpdateJob", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "UpdateJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateJobRequest" - }, - { - "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": "update_job" - }, - "description": "Sample for UpdateJob", - "file": "jobs_v4beta1_generated_job_service_update_job_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_async", - "segments": [ - { - "end": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_update_job_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.JobServiceClient", - "shortName": "JobServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.JobServiceClient.update_job", - "method": { - "fullName": "google.cloud.talent.v4beta1.JobService.UpdateJob", - "service": { - "fullName": "google.cloud.talent.v4beta1.JobService", - "shortName": "JobService" - }, - "shortName": "UpdateJob" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateJobRequest" - }, - { - "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": "update_job" - }, - "description": "Sample for UpdateJob", - "file": "jobs_v4beta1_generated_job_service_update_job_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_sync", - "segments": [ - { - "end": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_job_service_update_job_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.create_tenant", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.CreateTenant", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "CreateTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateTenantRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "tenant", - "type": "google.cloud.talent_v4beta1.types.Tenant" - }, - { - "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.Tenant", - "shortName": "create_tenant" - }, - "description": "Sample for CreateTenant", - "file": "jobs_v4beta1_generated_tenant_service_create_tenant_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_CreateTenant_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_create_tenant_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.create_tenant", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.CreateTenant", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "CreateTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.CreateTenantRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "tenant", - "type": "google.cloud.talent_v4beta1.types.Tenant" - }, - { - "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.Tenant", - "shortName": "create_tenant" - }, - "description": "Sample for CreateTenant", - "file": "jobs_v4beta1_generated_tenant_service_create_tenant_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_CreateTenant_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_create_tenant_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.delete_tenant", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.DeleteTenant", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "DeleteTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteTenantRequest" - }, - { - "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_tenant" - }, - "description": "Sample for DeleteTenant", - "file": "jobs_v4beta1_generated_tenant_service_delete_tenant_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_DeleteTenant_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_delete_tenant_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.delete_tenant", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.DeleteTenant", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "DeleteTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.DeleteTenantRequest" - }, - { - "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_tenant" - }, - "description": "Sample for DeleteTenant", - "file": "jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_DeleteTenant_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.get_tenant", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.GetTenant", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "GetTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetTenantRequest" - }, - { - "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.Tenant", - "shortName": "get_tenant" - }, - "description": "Sample for GetTenant", - "file": "jobs_v4beta1_generated_tenant_service_get_tenant_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_GetTenant_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_get_tenant_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.get_tenant", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.GetTenant", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "GetTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.GetTenantRequest" - }, - { - "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.Tenant", - "shortName": "get_tenant" - }, - "description": "Sample for GetTenant", - "file": "jobs_v4beta1_generated_tenant_service_get_tenant_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_GetTenant_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_get_tenant_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.list_tenants", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.ListTenants", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "ListTenants" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListTenantsRequest" - }, - { - "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.tenant_service.pagers.ListTenantsAsyncPager", - "shortName": "list_tenants" - }, - "description": "Sample for ListTenants", - "file": "jobs_v4beta1_generated_tenant_service_list_tenants_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_ListTenants_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_list_tenants_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.list_tenants", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.ListTenants", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "ListTenants" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.ListTenantsRequest" - }, - { - "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.tenant_service.pagers.ListTenantsPager", - "shortName": "list_tenants" - }, - "description": "Sample for ListTenants", - "file": "jobs_v4beta1_generated_tenant_service_list_tenants_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_ListTenants_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_list_tenants_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient", - "shortName": "TenantServiceAsyncClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceAsyncClient.update_tenant", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.UpdateTenant", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "UpdateTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateTenantRequest" - }, - { - "name": "tenant", - "type": "google.cloud.talent_v4beta1.types.Tenant" - }, - { - "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.Tenant", - "shortName": "update_tenant" - }, - "description": "Sample for UpdateTenant", - "file": "jobs_v4beta1_generated_tenant_service_update_tenant_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_UpdateTenant_async", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_update_tenant_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient", - "shortName": "TenantServiceClient" - }, - "fullName": "google.cloud.talent_v4beta1.TenantServiceClient.update_tenant", - "method": { - "fullName": "google.cloud.talent.v4beta1.TenantService.UpdateTenant", - "service": { - "fullName": "google.cloud.talent.v4beta1.TenantService", - "shortName": "TenantService" - }, - "shortName": "UpdateTenant" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.talent_v4beta1.types.UpdateTenantRequest" - }, - { - "name": "tenant", - "type": "google.cloud.talent_v4beta1.types.Tenant" - }, - { - "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.Tenant", - "shortName": "update_tenant" - }, - "description": "Sample for UpdateTenant", - "file": "jobs_v4beta1_generated_tenant_service_update_tenant_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "jobs_v4beta1_generated_TenantService_UpdateTenant_sync", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "jobs_v4beta1_generated_tenant_service_update_tenant_sync.py" - } - ] -} diff --git a/owl-bot-staging/v4beta1/scripts/fixup_talent_v4beta1_keywords.py b/owl-bot-staging/v4beta1/scripts/fixup_talent_v4beta1_keywords.py deleted file mode 100644 index 3058f60b..00000000 --- a/owl-bot-staging/v4beta1/scripts/fixup_talent_v4beta1_keywords.py +++ /dev/null @@ -1,197 +0,0 @@ -#! /usr/bin/env python3 -# -*- 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 argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class talentCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'batch_create_jobs': ('parent', 'jobs', ), - 'batch_delete_jobs': ('parent', 'filter', ), - 'batch_update_jobs': ('parent', 'jobs', 'update_mask', ), - 'complete_query': ('parent', 'query', 'page_size', 'language_codes', 'company', 'scope', 'type_', ), - 'create_client_event': ('parent', 'client_event', ), - 'create_company': ('parent', 'company', ), - 'create_job': ('parent', 'job', ), - 'create_tenant': ('parent', 'tenant', ), - 'delete_company': ('name', ), - 'delete_job': ('name', ), - 'delete_tenant': ('name', ), - 'get_company': ('name', ), - 'get_job': ('name', ), - 'get_tenant': ('name', ), - 'list_companies': ('parent', 'page_token', 'page_size', 'require_open_jobs', ), - 'list_jobs': ('parent', 'filter', 'page_token', 'page_size', 'job_view', ), - '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', '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_tenant': ('tenant', 'update_mask', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: a.keyword.value not in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=talentCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the talent client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v4beta1/setup.py b/owl-bot-staging/v4beta1/setup.py deleted file mode 100644 index ddcd0c82..00000000 --- a/owl-bot-staging/v4beta1/setup.py +++ /dev/null @@ -1,58 +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 io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-talent', - author="Google LLC", - author_email="googleapis-packages@google.com", - url="https://github.com/googleapis/python-google-cloud-talent", - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 2.10.0, < 3.0.0dev', - 'libcst >= 0.2.5', - 'googleapis-common-protos >= 1.55.0, <2.0.0dev', - 'proto-plus >= 1.19.7', - ), - python_requires='>=3.7', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v4beta1/tests/__init__.py b/owl-bot-staging/v4beta1/tests/__init__.py deleted file mode 100644 index 231bc125..00000000 --- a/owl-bot-staging/v4beta1/tests/__init__.py +++ /dev/null @@ -1,16 +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. -# diff --git a/owl-bot-staging/v4beta1/tests/unit/__init__.py b/owl-bot-staging/v4beta1/tests/unit/__init__.py deleted file mode 100644 index 231bc125..00000000 --- a/owl-bot-staging/v4beta1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +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. -# diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/__init__.py b/owl-bot-staging/v4beta1/tests/unit/gapic/__init__.py deleted file mode 100644 index 231bc125..00000000 --- a/owl-bot-staging/v4beta1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +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. -# diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/__init__.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/__init__.py deleted file mode 100644 index 231bc125..00000000 --- a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/__init__.py +++ /dev/null @@ -1,16 +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. -# diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_company_service.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_company_service.py deleted file mode 100644 index 9e8ecd15..00000000 --- a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_company_service.py +++ /dev/null @@ -1,2789 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4beta1.services.company_service import CompanyServiceAsyncClient -from google.cloud.talent_v4beta1.services.company_service import CompanyServiceClient -from google.cloud.talent_v4beta1.services.company_service import pagers -from google.cloud.talent_v4beta1.services.company_service import transports -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import company -from google.cloud.talent_v4beta1.types import company as gct_company -from google.cloud.talent_v4beta1.types import company_service -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 -from google.type import postal_address_pb2 # type: ignore -import google.auth - - -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 CompanyServiceClient._get_default_mtls_endpoint(None) is None - assert CompanyServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert CompanyServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert CompanyServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert CompanyServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert CompanyServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (CompanyServiceClient, "grpc"), - (CompanyServiceAsyncClient, "grpc_asyncio"), -]) -def test_company_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.CompanyServiceGrpcTransport, "grpc"), - (transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_company_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", [ - (CompanyServiceClient, "grpc"), - (CompanyServiceAsyncClient, "grpc_asyncio"), -]) -def test_company_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_company_service_client_get_transport_class(): - transport = CompanyServiceClient.get_transport_class() - available_transports = [ - transports.CompanyServiceGrpcTransport, - ] - assert transport in available_transports - - transport = CompanyServiceClient.get_transport_class("grpc") - assert transport == transports.CompanyServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc"), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) -@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) -def test_company_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(CompanyServiceClient, '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(CompanyServiceClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", "true"), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", "false"), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) -@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_company_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - CompanyServiceClient, CompanyServiceAsyncClient -]) -@mock.patch.object(CompanyServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceClient)) -@mock.patch.object(CompanyServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompanyServiceAsyncClient)) -def test_company_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", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc"), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_company_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", grpc_helpers), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_company_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, - api_audience=None, - ) - -def test_company_service_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4beta1.services.company_service.transports.CompanyServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = CompanyServiceClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport, "grpc", grpc_helpers), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_company_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, - api_audience=None, - ) - - # 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", [ - company_service.CreateCompanyRequest, - dict, -]) -def test_create_company(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - ) - response = client.create_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.CreateCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -def test_create_company_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 = CompanyServiceClient( - 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_company), - '__call__') as call: - client.create_company() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.CreateCompanyRequest() - -@pytest.mark.asyncio -async def test_create_company_async(transport: str = 'grpc_asyncio', request_type=company_service.CreateCompanyRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - )) - response = await client.create_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.CreateCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -@pytest.mark.asyncio -async def test_create_company_async_from_dict(): - await test_create_company_async(request_type=dict) - - -def test_create_company_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 = company_service.CreateCompanyRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_company), - '__call__') as call: - call.return_value = gct_company.Company() - client.create_company(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_company_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 = company_service.CreateCompanyRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_company), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) - await client.create_company(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_company_flattened(): - 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.create_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_company( - parent='parent_value', - company=gct_company.Company(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].company - mock_val = gct_company.Company(name='name_value') - assert arg == mock_val - - -def test_create_company_flattened_error(): - client = CompanyServiceClient( - 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_company( - company_service.CreateCompanyRequest(), - parent='parent_value', - company=gct_company.Company(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_company_flattened_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.create_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_company( - parent='parent_value', - company=gct_company.Company(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].company - mock_val = gct_company.Company(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_company_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_company( - company_service.CreateCompanyRequest(), - parent='parent_value', - company=gct_company.Company(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - company_service.GetCompanyRequest, - dict, -]) -def test_get_company(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - ) - response = client.get_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.GetCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -def test_get_company_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 = CompanyServiceClient( - 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_company), - '__call__') as call: - client.get_company() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.GetCompanyRequest() - -@pytest.mark.asyncio -async def test_get_company_async(transport: str = 'grpc_asyncio', request_type=company_service.GetCompanyRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - )) - response = await client.get_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.GetCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -@pytest.mark.asyncio -async def test_get_company_async_from_dict(): - await test_get_company_async(request_type=dict) - - -def test_get_company_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 = company_service.GetCompanyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_company), - '__call__') as call: - call.return_value = company.Company() - client.get_company(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_company_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 = company_service.GetCompanyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_company), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) - await client.get_company(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_company_flattened(): - 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_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company.Company() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_company( - 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_company_flattened_error(): - client = CompanyServiceClient( - 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_company( - company_service.GetCompanyRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_company_flattened_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_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company.Company() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_company( - 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_company_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_company( - company_service.GetCompanyRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - company_service.UpdateCompanyRequest, - dict, -]) -def test_update_company(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - ) - response = client.update_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.UpdateCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -def test_update_company_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 = CompanyServiceClient( - 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_company), - '__call__') as call: - client.update_company() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.UpdateCompanyRequest() - -@pytest.mark.asyncio -async def test_update_company_async(transport: str = 'grpc_asyncio', request_type=company_service.UpdateCompanyRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company( - name='name_value', - display_name='display_name_value', - external_id='external_id_value', - size=common.CompanySize.MINI, - headquarters_address='headquarters_address_value', - hiring_agency=True, - eeo_text='eeo_text_value', - website_uri='website_uri_value', - career_site_uri='career_site_uri_value', - image_uri='image_uri_value', - keyword_searchable_job_custom_attributes=['keyword_searchable_job_custom_attributes_value'], - suspended=True, - )) - response = await client.update_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.UpdateCompanyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_company.Company) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.external_id == 'external_id_value' - assert response.size == common.CompanySize.MINI - assert response.headquarters_address == 'headquarters_address_value' - assert response.hiring_agency is True - assert response.eeo_text == 'eeo_text_value' - assert response.website_uri == 'website_uri_value' - assert response.career_site_uri == 'career_site_uri_value' - assert response.image_uri == 'image_uri_value' - assert response.keyword_searchable_job_custom_attributes == ['keyword_searchable_job_custom_attributes_value'] - assert response.suspended is True - - -@pytest.mark.asyncio -async def test_update_company_async_from_dict(): - await test_update_company_async(request_type=dict) - - -def test_update_company_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 = company_service.UpdateCompanyRequest() - - request.company.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_company), - '__call__') as call: - call.return_value = gct_company.Company() - client.update_company(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', - 'company.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_company_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 = company_service.UpdateCompanyRequest() - - request.company.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_company), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) - await client.update_company(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', - 'company.name=name_value', - ) in kw['metadata'] - - -def test_update_company_flattened(): - 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.update_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_company( - company=gct_company.Company(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].company - mock_val = gct_company.Company(name='name_value') - assert arg == mock_val - - -def test_update_company_flattened_error(): - client = CompanyServiceClient( - 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_company( - company_service.UpdateCompanyRequest(), - company=gct_company.Company(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_update_company_flattened_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.update_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_company.Company() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_company( - company=gct_company.Company(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].company - mock_val = gct_company.Company(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_company_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_company( - company_service.UpdateCompanyRequest(), - company=gct_company.Company(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - company_service.DeleteCompanyRequest, - dict, -]) -def test_delete_company(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.DeleteCompanyRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_company_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 = CompanyServiceClient( - 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_company), - '__call__') as call: - client.delete_company() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.DeleteCompanyRequest() - -@pytest.mark.asyncio -async def test_delete_company_async(transport: str = 'grpc_asyncio', request_type=company_service.DeleteCompanyRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_company), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_company(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.DeleteCompanyRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_company_async_from_dict(): - await test_delete_company_async(request_type=dict) - - -def test_delete_company_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 = company_service.DeleteCompanyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_company), - '__call__') as call: - call.return_value = None - client.delete_company(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_company_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 = company_service.DeleteCompanyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_company), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_company(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_company_flattened(): - 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.delete_company), - '__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_company( - 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_company_flattened_error(): - client = CompanyServiceClient( - 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_company( - company_service.DeleteCompanyRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_company_flattened_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.delete_company), - '__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_company( - 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_company_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_company( - company_service.DeleteCompanyRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - company_service.ListCompaniesRequest, - dict, -]) -def test_list_companies(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_companies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company_service.ListCompaniesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_companies(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.ListCompaniesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCompaniesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_companies_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 = CompanyServiceClient( - 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_companies), - '__call__') as call: - client.list_companies() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.ListCompaniesRequest() - -@pytest.mark.asyncio -async def test_list_companies_async(transport: str = 'grpc_asyncio', request_type=company_service.ListCompaniesRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_companies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_companies(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == company_service.ListCompaniesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCompaniesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_companies_async_from_dict(): - await test_list_companies_async(request_type=dict) - - -def test_list_companies_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 = company_service.ListCompaniesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_companies), - '__call__') as call: - call.return_value = company_service.ListCompaniesResponse() - client.list_companies(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_companies_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 = company_service.ListCompaniesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_companies), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse()) - await client.list_companies(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_companies_flattened(): - 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.list_companies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company_service.ListCompaniesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_companies( - 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_companies_flattened_error(): - client = CompanyServiceClient( - 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_companies( - company_service.ListCompaniesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_companies_flattened_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.list_companies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = company_service.ListCompaniesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company_service.ListCompaniesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_companies( - 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_companies_flattened_error_async(): - client = CompanyServiceAsyncClient( - 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_companies( - company_service.ListCompaniesRequest(), - parent='parent_value', - ) - - -def test_list_companies_pager(transport_name: str = "grpc"): - client = CompanyServiceClient( - 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_companies), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - company.Company(), - ], - next_page_token='abc', - ), - company_service.ListCompaniesResponse( - companies=[], - next_page_token='def', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - ], - next_page_token='ghi', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_companies(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, company.Company) - for i in results) -def test_list_companies_pages(transport_name: str = "grpc"): - client = CompanyServiceClient( - 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_companies), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - company.Company(), - ], - next_page_token='abc', - ), - company_service.ListCompaniesResponse( - companies=[], - next_page_token='def', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - ], - next_page_token='ghi', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - ], - ), - RuntimeError, - ) - pages = list(client.list_companies(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_companies_async_pager(): - 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.list_companies), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - company.Company(), - ], - next_page_token='abc', - ), - company_service.ListCompaniesResponse( - companies=[], - next_page_token='def', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - ], - next_page_token='ghi', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_companies(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, company.Company) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_companies_async_pages(): - 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.list_companies), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - company.Company(), - ], - next_page_token='abc', - ), - company_service.ListCompaniesResponse( - companies=[], - next_page_token='def', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - ], - next_page_token='ghi', - ), - company_service.ListCompaniesResponse( - companies=[ - company.Company(), - company.Company(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_companies(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.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompanyServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompanyServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CompanyServiceClient( - 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 = CompanyServiceClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompanyServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = CompanyServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CompanyServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.CompanyServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.CompanyServiceGrpcTransport, - transports.CompanyServiceGrpcAsyncIOTransport, -]) -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 = CompanyServiceClient.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 = CompanyServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CompanyServiceGrpcTransport, - ) - -def test_company_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CompanyServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_company_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4beta1.services.company_service.transports.CompanyServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.CompanyServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_company', - 'get_company', - 'update_company', - 'delete_company', - 'list_companies', - 'get_operation', - ) - 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_company_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.company_service.transports.CompanyServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CompanyServiceTransport( - 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_company_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.company_service.transports.CompanyServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CompanyServiceTransport() - adc.assert_called_once() - - -def test_company_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) - CompanyServiceClient() - 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.CompanyServiceGrpcTransport, - transports.CompanyServiceGrpcAsyncIOTransport, - ], -) -def test_company_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", - [ - 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", - [ - (transports.CompanyServiceGrpcTransport, grpc_helpers), - (transports.CompanyServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_company_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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) -def test_company_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_company_service_host_no_port(transport_name): - client = CompanyServiceClient( - 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_company_service_host_with_port(transport_name): - client = CompanyServiceClient( - 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_company_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CompanyServiceGrpcTransport( - 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_company_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CompanyServiceGrpcAsyncIOTransport( - 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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) -def test_company_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.CompanyServiceGrpcTransport, transports.CompanyServiceGrpcAsyncIOTransport]) -def test_company_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_company_path(): - project = "squid" - tenant = "clam" - company = "whelk" - expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) - actual = CompanyServiceClient.company_path(project, tenant, company) - assert expected == actual - - -def test_parse_company_path(): - expected = { - "project": "octopus", - "tenant": "oyster", - "company": "nudibranch", - } - path = CompanyServiceClient.company_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.parse_company_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = CompanyServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "mussel", - } - path = CompanyServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "winkle" - expected = "folders/{folder}".format(folder=folder, ) - actual = CompanyServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nautilus", - } - path = CompanyServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "scallop" - expected = "organizations/{organization}".format(organization=organization, ) - actual = CompanyServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "abalone", - } - path = CompanyServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "squid" - expected = "projects/{project}".format(project=project, ) - actual = CompanyServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "clam", - } - path = CompanyServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "whelk" - location = "octopus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = CompanyServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - } - path = CompanyServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = CompanyServiceClient.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.CompanyServiceTransport, '_prep_wrapped_messages') as prep: - client = CompanyServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.CompanyServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = CompanyServiceClient.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 = CompanyServiceAsyncClient( - 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_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_async(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", - } - - for transport, close_name in transports.items(): - client = CompanyServiceClient( - 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 = CompanyServiceClient( - 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", [ - (CompanyServiceClient, transports.CompanyServiceGrpcTransport), - (CompanyServiceAsyncClient, transports.CompanyServiceGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_completion.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_completion.py deleted file mode 100644 index a6d8a976..00000000 --- a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_completion.py +++ /dev/null @@ -1,1440 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4beta1.services.completion import CompletionAsyncClient -from google.cloud.talent_v4beta1.services.completion import CompletionClient -from google.cloud.talent_v4beta1.services.completion import transports -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import completion_service -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -import google.auth - - -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 CompletionClient._get_default_mtls_endpoint(None) is None - assert CompletionClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert CompletionClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert CompletionClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert CompletionClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert CompletionClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (CompletionClient, "grpc"), - (CompletionAsyncClient, "grpc_asyncio"), -]) -def test_completion_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.CompletionGrpcTransport, "grpc"), - (transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_completion_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", [ - (CompletionClient, "grpc"), - (CompletionAsyncClient, "grpc_asyncio"), -]) -def test_completion_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_completion_client_get_transport_class(): - transport = CompletionClient.get_transport_class() - available_transports = [ - transports.CompletionGrpcTransport, - ] - assert transport in available_transports - - transport = CompletionClient.get_transport_class("grpc") - assert transport == transports.CompletionGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc"), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) -@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) -def test_completion_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(CompletionClient, '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(CompletionClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc", "true"), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (CompletionClient, transports.CompletionGrpcTransport, "grpc", "false"), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) -@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_completion_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - CompletionClient, CompletionAsyncClient -]) -@mock.patch.object(CompletionClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionClient)) -@mock.patch.object(CompletionAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CompletionAsyncClient)) -def test_completion_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", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc"), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_completion_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc", grpc_helpers), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_completion_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, - api_audience=None, - ) - -def test_completion_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4beta1.services.completion.transports.CompletionGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = CompletionClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CompletionClient, transports.CompletionGrpcTransport, "grpc", grpc_helpers), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_completion_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, - api_audience=None, - ) - - # 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", [ - completion_service.CompleteQueryRequest, - dict, -]) -def test_complete_query(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.complete_query), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = completion_service.CompleteQueryResponse( - ) - response = client.complete_query(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == completion_service.CompleteQueryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, completion_service.CompleteQueryResponse) - - -def test_complete_query_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 = CompletionClient( - 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.complete_query), - '__call__') as call: - client.complete_query() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == completion_service.CompleteQueryRequest() - -@pytest.mark.asyncio -async def test_complete_query_async(transport: str = 'grpc_asyncio', request_type=completion_service.CompleteQueryRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.complete_query), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(completion_service.CompleteQueryResponse( - )) - response = await client.complete_query(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == completion_service.CompleteQueryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, completion_service.CompleteQueryResponse) - - -@pytest.mark.asyncio -async def test_complete_query_async_from_dict(): - await test_complete_query_async(request_type=dict) - - -def test_complete_query_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 = completion_service.CompleteQueryRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.complete_query), - '__call__') as call: - call.return_value = completion_service.CompleteQueryResponse() - client.complete_query(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_complete_query_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 = completion_service.CompleteQueryRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.complete_query), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(completion_service.CompleteQueryResponse()) - await client.complete_query(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_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompletionClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompletionClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CompletionClient( - 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 = CompletionClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CompletionClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = CompletionClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CompletionGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.CompletionGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.CompletionGrpcTransport, - transports.CompletionGrpcAsyncIOTransport, -]) -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 = CompletionClient.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 = CompletionClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CompletionGrpcTransport, - ) - -def test_completion_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CompletionTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_completion_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4beta1.services.completion.transports.CompletionTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.CompletionTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'complete_query', - 'get_operation', - ) - 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_completion_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.completion.transports.CompletionTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CompletionTransport( - 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_completion_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.completion.transports.CompletionTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CompletionTransport() - adc.assert_called_once() - - -def test_completion_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) - CompletionClient() - 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.CompletionGrpcTransport, - transports.CompletionGrpcAsyncIOTransport, - ], -) -def test_completion_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", - [ - 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", - [ - (transports.CompletionGrpcTransport, grpc_helpers), - (transports.CompletionGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_completion_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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) -def test_completion_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_completion_host_no_port(transport_name): - client = CompletionClient( - 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_completion_host_with_port(transport_name): - client = CompletionClient( - 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_completion_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CompletionGrpcTransport( - 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_completion_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CompletionGrpcAsyncIOTransport( - 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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) -def test_completion_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.CompletionGrpcTransport, transports.CompletionGrpcAsyncIOTransport]) -def test_completion_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_company_path(): - project = "squid" - tenant = "clam" - company = "whelk" - expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) - actual = CompletionClient.company_path(project, tenant, company) - assert expected == actual - - -def test_parse_company_path(): - expected = { - "project": "octopus", - "tenant": "oyster", - "company": "nudibranch", - } - path = CompletionClient.company_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.parse_company_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = CompletionClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "mussel", - } - path = CompletionClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "winkle" - expected = "folders/{folder}".format(folder=folder, ) - actual = CompletionClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nautilus", - } - path = CompletionClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "scallop" - expected = "organizations/{organization}".format(organization=organization, ) - actual = CompletionClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "abalone", - } - path = CompletionClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "squid" - expected = "projects/{project}".format(project=project, ) - actual = CompletionClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "clam", - } - path = CompletionClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "whelk" - location = "octopus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = CompletionClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - } - path = CompletionClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = CompletionClient.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.CompletionTransport, '_prep_wrapped_messages') as prep: - client = CompletionClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.CompletionTransport, '_prep_wrapped_messages') as prep: - transport_class = CompletionClient.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 = CompletionAsyncClient( - 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_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_async(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", - } - - for transport, close_name in transports.items(): - client = CompletionClient( - 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 = CompletionClient( - 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", [ - (CompletionClient, transports.CompletionGrpcTransport), - (CompletionAsyncClient, transports.CompletionGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_event_service.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_event_service.py deleted file mode 100644 index 72e9251b..00000000 --- a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_event_service.py +++ /dev/null @@ -1,1546 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4beta1.services.event_service import EventServiceAsyncClient -from google.cloud.talent_v4beta1.services.event_service import EventServiceClient -from google.cloud.talent_v4beta1.services.event_service import transports -from google.cloud.talent_v4beta1.types import event -from google.cloud.talent_v4beta1.types import event_service -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import timestamp_pb2 # type: ignore -import google.auth - - -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 EventServiceClient._get_default_mtls_endpoint(None) is None - assert EventServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert EventServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert EventServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert EventServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert EventServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (EventServiceClient, "grpc"), - (EventServiceAsyncClient, "grpc_asyncio"), -]) -def test_event_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.EventServiceGrpcTransport, "grpc"), - (transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_event_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", [ - (EventServiceClient, "grpc"), - (EventServiceAsyncClient, "grpc_asyncio"), -]) -def test_event_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_event_service_client_get_transport_class(): - transport = EventServiceClient.get_transport_class() - available_transports = [ - transports.EventServiceGrpcTransport, - ] - assert transport in available_transports - - transport = EventServiceClient.get_transport_class("grpc") - assert transport == transports.EventServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc"), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) -@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) -def test_event_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(EventServiceClient, '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(EventServiceClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", "true"), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", "false"), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) -@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_event_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - EventServiceClient, EventServiceAsyncClient -]) -@mock.patch.object(EventServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceClient)) -@mock.patch.object(EventServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EventServiceAsyncClient)) -def test_event_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", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc"), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_event_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", grpc_helpers), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_event_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, - api_audience=None, - ) - -def test_event_service_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4beta1.services.event_service.transports.EventServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = EventServiceClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (EventServiceClient, transports.EventServiceGrpcTransport, "grpc", grpc_helpers), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_event_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, - api_audience=None, - ) - - # 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", [ - event_service.CreateClientEventRequest, - dict, -]) -def test_create_client_event(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_client_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = event.ClientEvent( - request_id='request_id_value', - event_id='event_id_value', - event_notes='event_notes_value', - job_event=event.JobEvent(type_=event.JobEvent.JobEventType.IMPRESSION), - ) - response = client.create_client_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == event_service.CreateClientEventRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, event.ClientEvent) - assert response.request_id == 'request_id_value' - assert response.event_id == 'event_id_value' - assert response.event_notes == 'event_notes_value' - - -def test_create_client_event_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 = EventServiceClient( - 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_client_event), - '__call__') as call: - client.create_client_event() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == event_service.CreateClientEventRequest() - -@pytest.mark.asyncio -async def test_create_client_event_async(transport: str = 'grpc_asyncio', request_type=event_service.CreateClientEventRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_client_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent( - request_id='request_id_value', - event_id='event_id_value', - event_notes='event_notes_value', - )) - response = await client.create_client_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == event_service.CreateClientEventRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, event.ClientEvent) - assert response.request_id == 'request_id_value' - assert response.event_id == 'event_id_value' - assert response.event_notes == 'event_notes_value' - - -@pytest.mark.asyncio -async def test_create_client_event_async_from_dict(): - await test_create_client_event_async(request_type=dict) - - -def test_create_client_event_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 = event_service.CreateClientEventRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_client_event), - '__call__') as call: - call.return_value = event.ClientEvent() - client.create_client_event(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_client_event_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 = event_service.CreateClientEventRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_client_event), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) - await client.create_client_event(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_client_event_flattened(): - 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.create_client_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = event.ClientEvent() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_client_event( - parent='parent_value', - client_event=event.ClientEvent(request_id='request_id_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].client_event - mock_val = event.ClientEvent(request_id='request_id_value') - assert arg == mock_val - - -def test_create_client_event_flattened_error(): - client = EventServiceClient( - 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_client_event( - event_service.CreateClientEventRequest(), - parent='parent_value', - client_event=event.ClientEvent(request_id='request_id_value'), - ) - -@pytest.mark.asyncio -async def test_create_client_event_flattened_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.create_client_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = event.ClientEvent() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_client_event( - parent='parent_value', - client_event=event.ClientEvent(request_id='request_id_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].client_event - mock_val = event.ClientEvent(request_id='request_id_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_client_event_flattened_error_async(): - client = EventServiceAsyncClient( - 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_client_event( - event_service.CreateClientEventRequest(), - parent='parent_value', - client_event=event.ClientEvent(request_id='request_id_value'), - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = EventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = EventServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = EventServiceClient( - 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 = EventServiceClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = EventServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = EventServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.EventServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.EventServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.EventServiceGrpcTransport, - transports.EventServiceGrpcAsyncIOTransport, -]) -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 = EventServiceClient.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 = EventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.EventServiceGrpcTransport, - ) - -def test_event_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.EventServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_event_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4beta1.services.event_service.transports.EventServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.EventServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_client_event', - 'get_operation', - ) - 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_event_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.event_service.transports.EventServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.EventServiceTransport( - 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_event_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.event_service.transports.EventServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.EventServiceTransport() - adc.assert_called_once() - - -def test_event_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) - EventServiceClient() - 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.EventServiceGrpcTransport, - transports.EventServiceGrpcAsyncIOTransport, - ], -) -def test_event_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", - [ - 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", - [ - (transports.EventServiceGrpcTransport, grpc_helpers), - (transports.EventServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_event_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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) -def test_event_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_event_service_host_no_port(transport_name): - client = EventServiceClient( - 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_event_service_host_with_port(transport_name): - client = EventServiceClient( - 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_event_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.EventServiceGrpcTransport( - 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_event_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.EventServiceGrpcAsyncIOTransport( - 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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) -def test_event_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.EventServiceGrpcTransport, transports.EventServiceGrpcAsyncIOTransport]) -def test_event_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_company_path(): - project = "squid" - tenant = "clam" - company = "whelk" - expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) - actual = EventServiceClient.company_path(project, tenant, company) - assert expected == actual - - -def test_parse_company_path(): - expected = { - "project": "octopus", - "tenant": "oyster", - "company": "nudibranch", - } - path = EventServiceClient.company_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_company_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = EventServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "mussel", - } - path = EventServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "winkle" - expected = "folders/{folder}".format(folder=folder, ) - actual = EventServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nautilus", - } - path = EventServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "scallop" - expected = "organizations/{organization}".format(organization=organization, ) - actual = EventServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "abalone", - } - path = EventServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "squid" - expected = "projects/{project}".format(project=project, ) - actual = EventServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "clam", - } - path = EventServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "whelk" - location = "octopus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = EventServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - } - path = EventServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = EventServiceClient.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.EventServiceTransport, '_prep_wrapped_messages') as prep: - client = EventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.EventServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = EventServiceClient.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 = EventServiceAsyncClient( - 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_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_async(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", - } - - for transport, close_name in transports.items(): - client = EventServiceClient( - 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 = EventServiceClient( - 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", [ - (EventServiceClient, transports.EventServiceGrpcTransport), - (EventServiceAsyncClient, transports.EventServiceGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_job_service.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_job_service.py deleted file mode 100644 index 505bdff3..00000000 --- a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_job_service.py +++ /dev/null @@ -1,4375 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation -from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4beta1.services.job_service import JobServiceAsyncClient -from google.cloud.talent_v4beta1.services.job_service import JobServiceClient -from google.cloud.talent_v4beta1.services.job_service import pagers -from google.cloud.talent_v4beta1.services.job_service import transports -from google.cloud.talent_v4beta1.types import common -from google.cloud.talent_v4beta1.types import filters -from google.cloud.talent_v4beta1.types import histogram -from google.cloud.talent_v4beta1.types import job -from google.cloud.talent_v4beta1.types import job as gct_job -from google.cloud.talent_v4beta1.types import job_service -from google.longrunning import operations_pb2 -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 latlng_pb2 # type: ignore -from google.type import money_pb2 # type: ignore -from google.type import postal_address_pb2 # type: ignore -from google.type import timeofday_pb2 # type: ignore -import google.auth - - -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 JobServiceClient._get_default_mtls_endpoint(None) is None - assert JobServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert JobServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert JobServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert JobServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert JobServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (JobServiceClient, "grpc"), - (JobServiceAsyncClient, "grpc_asyncio"), -]) -def test_job_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.JobServiceGrpcTransport, "grpc"), - (transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_job_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", [ - (JobServiceClient, "grpc"), - (JobServiceAsyncClient, "grpc_asyncio"), -]) -def test_job_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_job_service_client_get_transport_class(): - transport = JobServiceClient.get_transport_class() - available_transports = [ - transports.JobServiceGrpcTransport, - ] - assert transport in available_transports - - transport = JobServiceClient.get_transport_class("grpc") - assert transport == transports.JobServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc"), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) -@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) -def test_job_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(JobServiceClient, '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(JobServiceClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", "true"), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", "false"), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) -@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_job_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - JobServiceClient, JobServiceAsyncClient -]) -@mock.patch.object(JobServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceClient)) -@mock.patch.object(JobServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(JobServiceAsyncClient)) -def test_job_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", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc"), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_job_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", grpc_helpers), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_job_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, - api_audience=None, - ) - -def test_job_service_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4beta1.services.job_service.transports.JobServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = JobServiceClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (JobServiceClient, transports.JobServiceGrpcTransport, "grpc", grpc_helpers), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_job_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, - api_audience=None, - ) - - # 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", [ - job_service.CreateJobRequest, - dict, -]) -def test_create_job(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - ) - response = client.create_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -def test_create_job_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 = JobServiceClient( - 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_job), - '__call__') as call: - client.create_job() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateJobRequest() - -@pytest.mark.asyncio -async def test_create_job_async(transport: str = 'grpc_asyncio', request_type=job_service.CreateJobRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - )) - response = await client.create_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -@pytest.mark.asyncio -async def test_create_job_async_from_dict(): - await test_create_job_async(request_type=dict) - - -def test_create_job_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 = job_service.CreateJobRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_job), - '__call__') as call: - call.return_value = gct_job.Job() - client.create_job(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_job_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 = job_service.CreateJobRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_job), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) - await client.create_job(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_job_flattened(): - 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.create_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_job( - parent='parent_value', - job=gct_job.Job(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].job - mock_val = gct_job.Job(name='name_value') - assert arg == mock_val - - -def test_create_job_flattened_error(): - client = JobServiceClient( - 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_job( - job_service.CreateJobRequest(), - parent='parent_value', - job=gct_job.Job(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_job_flattened_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.create_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_job( - parent='parent_value', - job=gct_job.Job(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].job - mock_val = gct_job.Job(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_job_flattened_error_async(): - client = JobServiceAsyncClient( - 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_job( - job_service.CreateJobRequest(), - parent='parent_value', - job=gct_job.Job(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.BatchCreateJobsRequest, - dict, -]) -def test_batch_create_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.batch_create_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchCreateJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_batch_create_jobs_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 = JobServiceClient( - 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.batch_create_jobs), - '__call__') as call: - client.batch_create_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchCreateJobsRequest() - -@pytest.mark.asyncio -async def test_batch_create_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchCreateJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.batch_create_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchCreateJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_batch_create_jobs_async_from_dict(): - await test_batch_create_jobs_async(request_type=dict) - - -def test_batch_create_jobs_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 = job_service.BatchCreateJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_jobs), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.batch_create_jobs(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_batch_create_jobs_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 = job_service.BatchCreateJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.batch_create_jobs(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_batch_create_jobs_flattened(): - 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.batch_create_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.batch_create_jobs( - parent='parent_value', - jobs=[job.Job(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].jobs - mock_val = [job.Job(name='name_value')] - assert arg == mock_val - - -def test_batch_create_jobs_flattened_error(): - client = JobServiceClient( - 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.batch_create_jobs( - job_service.BatchCreateJobsRequest(), - parent='parent_value', - jobs=[job.Job(name='name_value')], - ) - -@pytest.mark.asyncio -async def test_batch_create_jobs_flattened_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.batch_create_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.batch_create_jobs( - parent='parent_value', - jobs=[job.Job(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].jobs - mock_val = [job.Job(name='name_value')] - assert arg == mock_val - -@pytest.mark.asyncio -async def test_batch_create_jobs_flattened_error_async(): - client = JobServiceAsyncClient( - 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.batch_create_jobs( - job_service.BatchCreateJobsRequest(), - parent='parent_value', - jobs=[job.Job(name='name_value')], - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.GetJobRequest, - dict, -]) -def test_get_job(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - ) - response = client.get_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -def test_get_job_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 = JobServiceClient( - 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_job), - '__call__') as call: - client.get_job() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetJobRequest() - -@pytest.mark.asyncio -async def test_get_job_async(transport: str = 'grpc_asyncio', request_type=job_service.GetJobRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - )) - response = await client.get_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -@pytest.mark.asyncio -async def test_get_job_async_from_dict(): - await test_get_job_async(request_type=dict) - - -def test_get_job_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 = job_service.GetJobRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_job), - '__call__') as call: - call.return_value = job.Job() - client.get_job(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_job_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 = job_service.GetJobRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_job), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) - await client.get_job(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_job_flattened(): - 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_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job.Job() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_job( - 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_job_flattened_error(): - client = JobServiceClient( - 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_job( - job_service.GetJobRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_job_flattened_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_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job.Job() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_job( - 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_job_flattened_error_async(): - client = JobServiceAsyncClient( - 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_job( - job_service.GetJobRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.UpdateJobRequest, - dict, -]) -def test_update_job(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - ) - response = client.update_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.UpdateJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -def test_update_job_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 = JobServiceClient( - 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_job), - '__call__') as call: - client.update_job() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.UpdateJobRequest() - -@pytest.mark.asyncio -async def test_update_job_async(transport: str = 'grpc_asyncio', request_type=job_service.UpdateJobRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job( - name='name_value', - company='company_value', - requisition_id='requisition_id_value', - title='title_value', - description='description_value', - addresses=['addresses_value'], - job_benefits=[common.JobBenefit.CHILD_CARE], - degree_types=[common.DegreeType.PRIMARY_EDUCATION], - department='department_value', - employment_types=[common.EmploymentType.FULL_TIME], - incentives='incentives_value', - language_code='language_code_value', - job_level=common.JobLevel.ENTRY_LEVEL, - promotion_value=1635, - qualifications='qualifications_value', - responsibilities='responsibilities_value', - posting_region=common.PostingRegion.ADMINISTRATIVE_AREA, - visibility=common.Visibility.ACCOUNT_ONLY, - company_display_name='company_display_name_value', - )) - response = await client.update_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.UpdateJobRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_job.Job) - assert response.name == 'name_value' - assert response.company == 'company_value' - assert response.requisition_id == 'requisition_id_value' - assert response.title == 'title_value' - assert response.description == 'description_value' - assert response.addresses == ['addresses_value'] - assert response.job_benefits == [common.JobBenefit.CHILD_CARE] - assert response.degree_types == [common.DegreeType.PRIMARY_EDUCATION] - assert response.department == 'department_value' - assert response.employment_types == [common.EmploymentType.FULL_TIME] - assert response.incentives == 'incentives_value' - assert response.language_code == 'language_code_value' - assert response.job_level == common.JobLevel.ENTRY_LEVEL - assert response.promotion_value == 1635 - assert response.qualifications == 'qualifications_value' - assert response.responsibilities == 'responsibilities_value' - assert response.posting_region == common.PostingRegion.ADMINISTRATIVE_AREA - assert response.visibility == common.Visibility.ACCOUNT_ONLY - assert response.company_display_name == 'company_display_name_value' - - -@pytest.mark.asyncio -async def test_update_job_async_from_dict(): - await test_update_job_async(request_type=dict) - - -def test_update_job_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 = job_service.UpdateJobRequest() - - request.job.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_job), - '__call__') as call: - call.return_value = gct_job.Job() - client.update_job(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', - 'job.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_job_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 = job_service.UpdateJobRequest() - - request.job.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_job), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) - await client.update_job(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', - 'job.name=name_value', - ) in kw['metadata'] - - -def test_update_job_flattened(): - 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.update_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_job( - job=gct_job.Job(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].job - mock_val = gct_job.Job(name='name_value') - assert arg == mock_val - - -def test_update_job_flattened_error(): - client = JobServiceClient( - 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_job( - job_service.UpdateJobRequest(), - job=gct_job.Job(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_update_job_flattened_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.update_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_job.Job() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_job( - job=gct_job.Job(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].job - mock_val = gct_job.Job(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_job_flattened_error_async(): - client = JobServiceAsyncClient( - 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_job( - job_service.UpdateJobRequest(), - job=gct_job.Job(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.BatchUpdateJobsRequest, - dict, -]) -def test_batch_update_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.batch_update_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchUpdateJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_batch_update_jobs_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 = JobServiceClient( - 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.batch_update_jobs), - '__call__') as call: - client.batch_update_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchUpdateJobsRequest() - -@pytest.mark.asyncio -async def test_batch_update_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchUpdateJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.batch_update_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchUpdateJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_batch_update_jobs_async_from_dict(): - await test_batch_update_jobs_async(request_type=dict) - - -def test_batch_update_jobs_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 = job_service.BatchUpdateJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_jobs), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.batch_update_jobs(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_batch_update_jobs_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 = job_service.BatchUpdateJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.batch_update_jobs(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_batch_update_jobs_flattened(): - 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.batch_update_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.batch_update_jobs( - parent='parent_value', - jobs=[job.Job(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].jobs - mock_val = [job.Job(name='name_value')] - assert arg == mock_val - - -def test_batch_update_jobs_flattened_error(): - client = JobServiceClient( - 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.batch_update_jobs( - job_service.BatchUpdateJobsRequest(), - parent='parent_value', - jobs=[job.Job(name='name_value')], - ) - -@pytest.mark.asyncio -async def test_batch_update_jobs_flattened_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.batch_update_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.batch_update_jobs( - parent='parent_value', - jobs=[job.Job(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].jobs - mock_val = [job.Job(name='name_value')] - assert arg == mock_val - -@pytest.mark.asyncio -async def test_batch_update_jobs_flattened_error_async(): - client = JobServiceAsyncClient( - 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.batch_update_jobs( - job_service.BatchUpdateJobsRequest(), - parent='parent_value', - jobs=[job.Job(name='name_value')], - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.DeleteJobRequest, - dict, -]) -def test_delete_job(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteJobRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_job_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 = JobServiceClient( - 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_job), - '__call__') as call: - client.delete_job() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteJobRequest() - -@pytest.mark.asyncio -async def test_delete_job_async(transport: str = 'grpc_asyncio', request_type=job_service.DeleteJobRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_job), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_job(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteJobRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_job_async_from_dict(): - await test_delete_job_async(request_type=dict) - - -def test_delete_job_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 = job_service.DeleteJobRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_job), - '__call__') as call: - call.return_value = None - client.delete_job(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_job_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 = job_service.DeleteJobRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_job), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_job(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_job_flattened(): - 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.delete_job), - '__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_job( - 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_job_flattened_error(): - client = JobServiceClient( - 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_job( - job_service.DeleteJobRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_job_flattened_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.delete_job), - '__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_job( - 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_job_flattened_error_async(): - client = JobServiceAsyncClient( - 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_job( - job_service.DeleteJobRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.BatchDeleteJobsRequest, - dict, -]) -def test_batch_delete_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.batch_delete_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchDeleteJobsRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_batch_delete_jobs_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 = JobServiceClient( - 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.batch_delete_jobs), - '__call__') as call: - client.batch_delete_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchDeleteJobsRequest() - -@pytest.mark.asyncio -async def test_batch_delete_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.BatchDeleteJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.batch_delete_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.BatchDeleteJobsRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_batch_delete_jobs_async_from_dict(): - await test_batch_delete_jobs_async(request_type=dict) - - -def test_batch_delete_jobs_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 = job_service.BatchDeleteJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_jobs), - '__call__') as call: - call.return_value = None - client.batch_delete_jobs(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_batch_delete_jobs_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 = job_service.BatchDeleteJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.batch_delete_jobs(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_batch_delete_jobs_flattened(): - 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.batch_delete_jobs), - '__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.batch_delete_jobs( - parent='parent_value', - filter='filter_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].filter - mock_val = 'filter_value' - assert arg == mock_val - - -def test_batch_delete_jobs_flattened_error(): - client = JobServiceClient( - 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.batch_delete_jobs( - job_service.BatchDeleteJobsRequest(), - parent='parent_value', - filter='filter_value', - ) - -@pytest.mark.asyncio -async def test_batch_delete_jobs_flattened_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.batch_delete_jobs), - '__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.batch_delete_jobs( - parent='parent_value', - filter='filter_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].filter - mock_val = 'filter_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_batch_delete_jobs_flattened_error_async(): - client = JobServiceAsyncClient( - 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.batch_delete_jobs( - job_service.BatchDeleteJobsRequest(), - parent='parent_value', - filter='filter_value', - ) - - -@pytest.mark.parametrize("request_type", [ - job_service.ListJobsRequest, - dict, -]) -def test_list_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.ListJobsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListJobsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_jobs_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 = JobServiceClient( - 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_jobs), - '__call__') as call: - client.list_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListJobsRequest() - -@pytest.mark.asyncio -async def test_list_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.ListJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListJobsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_jobs_async_from_dict(): - await test_list_jobs_async(request_type=dict) - - -def test_list_jobs_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 = job_service.ListJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_jobs), - '__call__') as call: - call.return_value = job_service.ListJobsResponse() - client.list_jobs(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_jobs_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 = job_service.ListJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse()) - await client.list_jobs(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_jobs_flattened(): - 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.list_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.ListJobsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_jobs( - parent='parent_value', - filter='filter_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].filter - mock_val = 'filter_value' - assert arg == mock_val - - -def test_list_jobs_flattened_error(): - client = JobServiceClient( - 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_jobs( - job_service.ListJobsRequest(), - parent='parent_value', - filter='filter_value', - ) - -@pytest.mark.asyncio -async def test_list_jobs_flattened_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.list_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.ListJobsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.ListJobsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_jobs( - parent='parent_value', - filter='filter_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].filter - mock_val = 'filter_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_jobs_flattened_error_async(): - client = JobServiceAsyncClient( - 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_jobs( - job_service.ListJobsRequest(), - parent='parent_value', - filter='filter_value', - ) - - -def test_list_jobs_pager(transport_name: str = "grpc"): - client = JobServiceClient( - 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_jobs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - job.Job(), - ], - next_page_token='abc', - ), - job_service.ListJobsResponse( - jobs=[], - next_page_token='def', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - ], - next_page_token='ghi', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_jobs(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, job.Job) - for i in results) -def test_list_jobs_pages(transport_name: str = "grpc"): - client = JobServiceClient( - 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_jobs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - job.Job(), - ], - next_page_token='abc', - ), - job_service.ListJobsResponse( - jobs=[], - next_page_token='def', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - ], - next_page_token='ghi', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - ], - ), - RuntimeError, - ) - pages = list(client.list_jobs(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_jobs_async_pager(): - 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.list_jobs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - job.Job(), - ], - next_page_token='abc', - ), - job_service.ListJobsResponse( - jobs=[], - next_page_token='def', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - ], - next_page_token='ghi', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_jobs(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, job.Job) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_jobs_async_pages(): - 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.list_jobs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - job.Job(), - ], - next_page_token='abc', - ), - job_service.ListJobsResponse( - jobs=[], - next_page_token='def', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - ], - next_page_token='ghi', - ), - job_service.ListJobsResponse( - jobs=[ - job.Job(), - job.Job(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_jobs(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", [ - job_service.SearchJobsRequest, - dict, -]) -def test_search_jobs(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.SearchJobsResponse( - next_page_token='next_page_token_value', - estimated_total_size=2141, - total_size=1086, - broadened_query_jobs_count=2766, - ) - response = client.search_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchJobsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.estimated_total_size == 2141 - assert response.total_size == 1086 - assert response.broadened_query_jobs_count == 2766 - - -def test_search_jobs_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 = JobServiceClient( - 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_jobs), - '__call__') as call: - client.search_jobs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - -@pytest.mark.asyncio -async def test_search_jobs_async(transport: str = 'grpc_asyncio', request_type=job_service.SearchJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse( - next_page_token='next_page_token_value', - estimated_total_size=2141, - total_size=1086, - broadened_query_jobs_count=2766, - )) - response = await client.search_jobs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchJobsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.estimated_total_size == 2141 - assert response.total_size == 1086 - assert response.broadened_query_jobs_count == 2766 - - -@pytest.mark.asyncio -async def test_search_jobs_async_from_dict(): - await test_search_jobs_async(request_type=dict) - - -def test_search_jobs_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 = job_service.SearchJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs), - '__call__') as call: - call.return_value = job_service.SearchJobsResponse() - client.search_jobs(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_jobs_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 = job_service.SearchJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse()) - await client.search_jobs(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_jobs_pager(transport_name: str = "grpc"): - client = JobServiceClient( - 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_jobs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='abc', - ), - job_service.SearchJobsResponse( - matching_jobs=[], - next_page_token='def', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='ghi', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.search_jobs(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, job_service.SearchJobsResponse.MatchingJob) - for i in results) -def test_search_jobs_pages(transport_name: str = "grpc"): - client = JobServiceClient( - 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_jobs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='abc', - ), - job_service.SearchJobsResponse( - matching_jobs=[], - next_page_token='def', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='ghi', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - ), - RuntimeError, - ) - pages = list(client.search_jobs(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_jobs_async_pager(): - 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.search_jobs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='abc', - ), - job_service.SearchJobsResponse( - matching_jobs=[], - next_page_token='def', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='ghi', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - ), - RuntimeError, - ) - async_pager = await client.search_jobs(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, job_service.SearchJobsResponse.MatchingJob) - for i in responses) - - -@pytest.mark.asyncio -async def test_search_jobs_async_pages(): - 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.search_jobs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='abc', - ), - job_service.SearchJobsResponse( - matching_jobs=[], - next_page_token='def', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='ghi', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.search_jobs(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", [ - job_service.SearchJobsRequest, - dict, -]) -def test_search_jobs_for_alert(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs_for_alert), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = job_service.SearchJobsResponse( - next_page_token='next_page_token_value', - estimated_total_size=2141, - total_size=1086, - broadened_query_jobs_count=2766, - ) - response = client.search_jobs_for_alert(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchJobsForAlertPager) - assert response.next_page_token == 'next_page_token_value' - assert response.estimated_total_size == 2141 - assert response.total_size == 1086 - assert response.broadened_query_jobs_count == 2766 - - -def test_search_jobs_for_alert_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 = JobServiceClient( - 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_jobs_for_alert), - '__call__') as call: - client.search_jobs_for_alert() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - -@pytest.mark.asyncio -async def test_search_jobs_for_alert_async(transport: str = 'grpc_asyncio', request_type=job_service.SearchJobsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs_for_alert), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse( - next_page_token='next_page_token_value', - estimated_total_size=2141, - total_size=1086, - broadened_query_jobs_count=2766, - )) - response = await client.search_jobs_for_alert(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == job_service.SearchJobsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchJobsForAlertAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.estimated_total_size == 2141 - assert response.total_size == 1086 - assert response.broadened_query_jobs_count == 2766 - - -@pytest.mark.asyncio -async def test_search_jobs_for_alert_async_from_dict(): - await test_search_jobs_for_alert_async(request_type=dict) - - -def test_search_jobs_for_alert_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 = job_service.SearchJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs_for_alert), - '__call__') as call: - call.return_value = job_service.SearchJobsResponse() - client.search_jobs_for_alert(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_jobs_for_alert_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 = job_service.SearchJobsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_jobs_for_alert), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job_service.SearchJobsResponse()) - await client.search_jobs_for_alert(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_jobs_for_alert_pager(transport_name: str = "grpc"): - client = JobServiceClient( - 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_jobs_for_alert), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='abc', - ), - job_service.SearchJobsResponse( - matching_jobs=[], - next_page_token='def', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='ghi', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.search_jobs_for_alert(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, job_service.SearchJobsResponse.MatchingJob) - for i in results) -def test_search_jobs_for_alert_pages(transport_name: str = "grpc"): - client = JobServiceClient( - 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_jobs_for_alert), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='abc', - ), - job_service.SearchJobsResponse( - matching_jobs=[], - next_page_token='def', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='ghi', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - ), - RuntimeError, - ) - pages = list(client.search_jobs_for_alert(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_jobs_for_alert_async_pager(): - 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.search_jobs_for_alert), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='abc', - ), - job_service.SearchJobsResponse( - matching_jobs=[], - next_page_token='def', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='ghi', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - ), - RuntimeError, - ) - async_pager = await client.search_jobs_for_alert(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, job_service.SearchJobsResponse.MatchingJob) - for i in responses) - - -@pytest.mark.asyncio -async def test_search_jobs_for_alert_async_pages(): - 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.search_jobs_for_alert), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='abc', - ), - job_service.SearchJobsResponse( - matching_jobs=[], - next_page_token='def', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - ], - next_page_token='ghi', - ), - job_service.SearchJobsResponse( - matching_jobs=[ - job_service.SearchJobsResponse.MatchingJob(), - job_service.SearchJobsResponse.MatchingJob(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.search_jobs_for_alert(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.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = JobServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = JobServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = JobServiceClient( - 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 = JobServiceClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = JobServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = JobServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.JobServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.JobServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.JobServiceGrpcTransport, - transports.JobServiceGrpcAsyncIOTransport, -]) -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 = JobServiceClient.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 = JobServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.JobServiceGrpcTransport, - ) - -def test_job_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.JobServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_job_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4beta1.services.job_service.transports.JobServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.JobServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_job', - 'batch_create_jobs', - 'get_job', - 'update_job', - 'batch_update_jobs', - 'delete_job', - 'batch_delete_jobs', - 'list_jobs', - 'search_jobs', - 'search_jobs_for_alert', - 'get_operation', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - # Catch all for all remaining methods and properties - remainder = [ - 'kind', - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_job_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.job_service.transports.JobServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.JobServiceTransport( - 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_job_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.job_service.transports.JobServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.JobServiceTransport() - adc.assert_called_once() - - -def test_job_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) - JobServiceClient() - 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.JobServiceGrpcTransport, - transports.JobServiceGrpcAsyncIOTransport, - ], -) -def test_job_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", - [ - 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", - [ - (transports.JobServiceGrpcTransport, grpc_helpers), - (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_job_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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) -def test_job_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_job_service_host_no_port(transport_name): - client = JobServiceClient( - 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_job_service_host_with_port(transport_name): - client = JobServiceClient( - 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_job_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.JobServiceGrpcTransport( - 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_job_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.JobServiceGrpcAsyncIOTransport( - 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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) -def test_job_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.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport]) -def test_job_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_job_service_grpc_lro_client(): - client = JobServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_job_service_grpc_lro_async_client(): - client = JobServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_company_path(): - project = "squid" - tenant = "clam" - company = "whelk" - expected = "projects/{project}/tenants/{tenant}/companies/{company}".format(project=project, tenant=tenant, company=company, ) - actual = JobServiceClient.company_path(project, tenant, company) - assert expected == actual - - -def test_parse_company_path(): - expected = { - "project": "octopus", - "tenant": "oyster", - "company": "nudibranch", - } - path = JobServiceClient.company_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_company_path(path) - assert expected == actual - -def test_job_path(): - project = "cuttlefish" - tenant = "mussel" - job = "winkle" - expected = "projects/{project}/tenants/{tenant}/jobs/{job}".format(project=project, tenant=tenant, job=job, ) - actual = JobServiceClient.job_path(project, tenant, job) - assert expected == actual - - -def test_parse_job_path(): - expected = { - "project": "nautilus", - "tenant": "scallop", - "job": "abalone", - } - path = JobServiceClient.job_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_job_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "squid" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = JobServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "clam", - } - path = JobServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "whelk" - expected = "folders/{folder}".format(folder=folder, ) - actual = JobServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "octopus", - } - path = JobServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "oyster" - expected = "organizations/{organization}".format(organization=organization, ) - actual = JobServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nudibranch", - } - path = JobServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "cuttlefish" - expected = "projects/{project}".format(project=project, ) - actual = JobServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "mussel", - } - path = JobServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "winkle" - location = "nautilus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = JobServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "scallop", - "location": "abalone", - } - path = JobServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = JobServiceClient.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.JobServiceTransport, '_prep_wrapped_messages') as prep: - client = JobServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.JobServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = JobServiceClient.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 = JobServiceAsyncClient( - 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_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_async(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", - } - - for transport, close_name in transports.items(): - client = JobServiceClient( - 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 = JobServiceClient( - 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", [ - (JobServiceClient, transports.JobServiceGrpcTransport), - (JobServiceAsyncClient, transports.JobServiceGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_tenant_service.py b/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_tenant_service.py deleted file mode 100644 index 4169d32c..00000000 --- a/owl-bot-staging/v4beta1/tests/unit/gapic/talent_v4beta1/test_tenant_service.py +++ /dev/null @@ -1,2688 +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 grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.talent_v4beta1.services.tenant_service import TenantServiceAsyncClient -from google.cloud.talent_v4beta1.services.tenant_service import TenantServiceClient -from google.cloud.talent_v4beta1.services.tenant_service import pagers -from google.cloud.talent_v4beta1.services.tenant_service import transports -from google.cloud.talent_v4beta1.types import tenant -from google.cloud.talent_v4beta1.types import tenant as gct_tenant -from google.cloud.talent_v4beta1.types import tenant_service -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -import google.auth - - -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 TenantServiceClient._get_default_mtls_endpoint(None) is None - assert TenantServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert TenantServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert TenantServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert TenantServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert TenantServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (TenantServiceClient, "grpc"), - (TenantServiceAsyncClient, "grpc_asyncio"), -]) -def test_tenant_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.TenantServiceGrpcTransport, "grpc"), - (transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_tenant_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", [ - (TenantServiceClient, "grpc"), - (TenantServiceAsyncClient, "grpc_asyncio"), -]) -def test_tenant_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_tenant_service_client_get_transport_class(): - transport = TenantServiceClient.get_transport_class() - available_transports = [ - transports.TenantServiceGrpcTransport, - ] - assert transport in available_transports - - transport = TenantServiceClient.get_transport_class("grpc") - assert transport == transports.TenantServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc"), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) -@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) -def test_tenant_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(TenantServiceClient, '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(TenantServiceClient, '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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - 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" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", "true"), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", "false"), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) -@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_tenant_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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - # 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - TenantServiceClient, TenantServiceAsyncClient -]) -@mock.patch.object(TenantServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceClient)) -@mock.patch.object(TenantServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TenantServiceAsyncClient)) -def test_tenant_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", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc"), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_tenant_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, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", grpc_helpers), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_tenant_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, - api_audience=None, - ) - -def test_tenant_service_client_client_options_from_dict(): - with mock.patch('google.cloud.talent_v4beta1.services.tenant_service.transports.TenantServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = TenantServiceClient( - 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, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport, "grpc", grpc_helpers), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_tenant_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, - api_audience=None, - ) - - # 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", [ - tenant_service.CreateTenantRequest, - dict, -]) -def test_create_tenant(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant( - name='name_value', - external_id='external_id_value', - usage_type=gct_tenant.Tenant.DataUsageType.AGGREGATED, - keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], - ) - response = client.create_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.CreateTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - assert response.usage_type == gct_tenant.Tenant.DataUsageType.AGGREGATED - assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] - - -def test_create_tenant_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 = TenantServiceClient( - 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_tenant), - '__call__') as call: - client.create_tenant() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.CreateTenantRequest() - -@pytest.mark.asyncio -async def test_create_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.CreateTenantRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant( - name='name_value', - external_id='external_id_value', - usage_type=gct_tenant.Tenant.DataUsageType.AGGREGATED, - keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], - )) - response = await client.create_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.CreateTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - assert response.usage_type == gct_tenant.Tenant.DataUsageType.AGGREGATED - assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] - - -@pytest.mark.asyncio -async def test_create_tenant_async_from_dict(): - await test_create_tenant_async(request_type=dict) - - -def test_create_tenant_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 = tenant_service.CreateTenantRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tenant), - '__call__') as call: - call.return_value = gct_tenant.Tenant() - client.create_tenant(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_tenant_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 = tenant_service.CreateTenantRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tenant), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) - await client.create_tenant(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_tenant_flattened(): - 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.create_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_tenant( - parent='parent_value', - tenant=gct_tenant.Tenant(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].tenant - mock_val = gct_tenant.Tenant(name='name_value') - assert arg == mock_val - - -def test_create_tenant_flattened_error(): - client = TenantServiceClient( - 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_tenant( - tenant_service.CreateTenantRequest(), - parent='parent_value', - tenant=gct_tenant.Tenant(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_tenant_flattened_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.create_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_tenant( - parent='parent_value', - tenant=gct_tenant.Tenant(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].tenant - mock_val = gct_tenant.Tenant(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_tenant_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenant( - tenant_service.CreateTenantRequest(), - parent='parent_value', - tenant=gct_tenant.Tenant(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - tenant_service.GetTenantRequest, - dict, -]) -def test_get_tenant(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant.Tenant( - name='name_value', - external_id='external_id_value', - usage_type=tenant.Tenant.DataUsageType.AGGREGATED, - keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], - ) - response = client.get_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.GetTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - assert response.usage_type == tenant.Tenant.DataUsageType.AGGREGATED - assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] - - -def test_get_tenant_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 = TenantServiceClient( - 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_tenant), - '__call__') as call: - client.get_tenant() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.GetTenantRequest() - -@pytest.mark.asyncio -async def test_get_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.GetTenantRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant( - name='name_value', - external_id='external_id_value', - usage_type=tenant.Tenant.DataUsageType.AGGREGATED, - keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], - )) - response = await client.get_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.GetTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - assert response.usage_type == tenant.Tenant.DataUsageType.AGGREGATED - assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] - - -@pytest.mark.asyncio -async def test_get_tenant_async_from_dict(): - await test_get_tenant_async(request_type=dict) - - -def test_get_tenant_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 = tenant_service.GetTenantRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tenant), - '__call__') as call: - call.return_value = tenant.Tenant() - client.get_tenant(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_tenant_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 = tenant_service.GetTenantRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tenant), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) - await client.get_tenant(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_tenant_flattened(): - 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_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant.Tenant() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_tenant( - 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_tenant_flattened_error(): - client = TenantServiceClient( - 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_tenant( - tenant_service.GetTenantRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_tenant_flattened_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_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant.Tenant() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_tenant( - 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_tenant_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenant( - tenant_service.GetTenantRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - tenant_service.UpdateTenantRequest, - dict, -]) -def test_update_tenant(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant( - name='name_value', - external_id='external_id_value', - usage_type=gct_tenant.Tenant.DataUsageType.AGGREGATED, - keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], - ) - response = client.update_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.UpdateTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - assert response.usage_type == gct_tenant.Tenant.DataUsageType.AGGREGATED - assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] - - -def test_update_tenant_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 = TenantServiceClient( - 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_tenant), - '__call__') as call: - client.update_tenant() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.UpdateTenantRequest() - -@pytest.mark.asyncio -async def test_update_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.UpdateTenantRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant( - name='name_value', - external_id='external_id_value', - usage_type=gct_tenant.Tenant.DataUsageType.AGGREGATED, - keyword_searchable_profile_custom_attributes=['keyword_searchable_profile_custom_attributes_value'], - )) - response = await client.update_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.UpdateTenantRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, gct_tenant.Tenant) - assert response.name == 'name_value' - assert response.external_id == 'external_id_value' - assert response.usage_type == gct_tenant.Tenant.DataUsageType.AGGREGATED - assert response.keyword_searchable_profile_custom_attributes == ['keyword_searchable_profile_custom_attributes_value'] - - -@pytest.mark.asyncio -async def test_update_tenant_async_from_dict(): - await test_update_tenant_async(request_type=dict) - - -def test_update_tenant_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 = tenant_service.UpdateTenantRequest() - - request.tenant.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tenant), - '__call__') as call: - call.return_value = gct_tenant.Tenant() - client.update_tenant(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', - 'tenant.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_tenant_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 = tenant_service.UpdateTenantRequest() - - request.tenant.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tenant), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) - await client.update_tenant(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', - 'tenant.name=name_value', - ) in kw['metadata'] - - -def test_update_tenant_flattened(): - 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.update_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_tenant( - tenant=gct_tenant.Tenant(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].tenant - mock_val = gct_tenant.Tenant(name='name_value') - assert arg == mock_val - - -def test_update_tenant_flattened_error(): - client = TenantServiceClient( - 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_tenant( - tenant_service.UpdateTenantRequest(), - tenant=gct_tenant.Tenant(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_update_tenant_flattened_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.update_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gct_tenant.Tenant() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_tenant( - tenant=gct_tenant.Tenant(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].tenant - mock_val = gct_tenant.Tenant(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_tenant_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenant( - tenant_service.UpdateTenantRequest(), - tenant=gct_tenant.Tenant(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - tenant_service.DeleteTenantRequest, - dict, -]) -def test_delete_tenant(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.DeleteTenantRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_tenant_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 = TenantServiceClient( - 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_tenant), - '__call__') as call: - client.delete_tenant() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.DeleteTenantRequest() - -@pytest.mark.asyncio -async def test_delete_tenant_async(transport: str = 'grpc_asyncio', request_type=tenant_service.DeleteTenantRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tenant), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_tenant(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.DeleteTenantRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_tenant_async_from_dict(): - await test_delete_tenant_async(request_type=dict) - - -def test_delete_tenant_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 = tenant_service.DeleteTenantRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tenant), - '__call__') as call: - call.return_value = None - client.delete_tenant(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_tenant_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 = tenant_service.DeleteTenantRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tenant), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_tenant(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_tenant_flattened(): - 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.delete_tenant), - '__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_tenant( - 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_tenant_flattened_error(): - client = TenantServiceClient( - 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_tenant( - tenant_service.DeleteTenantRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_tenant_flattened_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.delete_tenant), - '__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_tenant( - 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_tenant_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenant( - tenant_service.DeleteTenantRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - tenant_service.ListTenantsRequest, - dict, -]) -def test_list_tenants(request_type, 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tenants), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant_service.ListTenantsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_tenants(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.ListTenantsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTenantsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_tenants_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 = TenantServiceClient( - 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_tenants), - '__call__') as call: - client.list_tenants() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.ListTenantsRequest() - -@pytest.mark.asyncio -async def test_list_tenants_async(transport: str = 'grpc_asyncio', request_type=tenant_service.ListTenantsRequest): - 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 = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tenants), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_tenants(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == tenant_service.ListTenantsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTenantsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_tenants_async_from_dict(): - await test_list_tenants_async(request_type=dict) - - -def test_list_tenants_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 = tenant_service.ListTenantsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tenants), - '__call__') as call: - call.return_value = tenant_service.ListTenantsResponse() - client.list_tenants(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_tenants_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 = tenant_service.ListTenantsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tenants), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse()) - await client.list_tenants(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_tenants_flattened(): - 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.list_tenants), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant_service.ListTenantsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_tenants( - 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_tenants_flattened_error(): - client = TenantServiceClient( - 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_tenants( - tenant_service.ListTenantsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_tenants_flattened_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.list_tenants), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tenant_service.ListTenantsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant_service.ListTenantsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_tenants( - 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_tenants_flattened_error_async(): - client = TenantServiceAsyncClient( - 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_tenants( - tenant_service.ListTenantsRequest(), - parent='parent_value', - ) - - -def test_list_tenants_pager(transport_name: str = "grpc"): - client = TenantServiceClient( - 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_tenants), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - tenant.Tenant(), - ], - next_page_token='abc', - ), - tenant_service.ListTenantsResponse( - tenants=[], - next_page_token='def', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - ], - next_page_token='ghi', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_tenants(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, tenant.Tenant) - for i in results) -def test_list_tenants_pages(transport_name: str = "grpc"): - client = TenantServiceClient( - 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_tenants), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - tenant.Tenant(), - ], - next_page_token='abc', - ), - tenant_service.ListTenantsResponse( - tenants=[], - next_page_token='def', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - ], - next_page_token='ghi', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - ], - ), - RuntimeError, - ) - pages = list(client.list_tenants(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_tenants_async_pager(): - 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.list_tenants), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - tenant.Tenant(), - ], - next_page_token='abc', - ), - tenant_service.ListTenantsResponse( - tenants=[], - next_page_token='def', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - ], - next_page_token='ghi', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_tenants(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, tenant.Tenant) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_tenants_async_pages(): - 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.list_tenants), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - tenant.Tenant(), - ], - next_page_token='abc', - ), - tenant_service.ListTenantsResponse( - tenants=[], - next_page_token='def', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - ], - next_page_token='ghi', - ), - tenant_service.ListTenantsResponse( - tenants=[ - tenant.Tenant(), - tenant.Tenant(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_tenants(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.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = TenantServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = TenantServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = TenantServiceClient( - 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 = TenantServiceClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = TenantServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = TenantServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.TenantServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.TenantServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.TenantServiceGrpcTransport, - transports.TenantServiceGrpcAsyncIOTransport, -]) -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 = TenantServiceClient.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 = TenantServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.TenantServiceGrpcTransport, - ) - -def test_tenant_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.TenantServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_tenant_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.talent_v4beta1.services.tenant_service.transports.TenantServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.TenantServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_tenant', - 'get_tenant', - 'update_tenant', - 'delete_tenant', - 'list_tenants', - 'get_operation', - ) - 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_tenant_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.tenant_service.transports.TenantServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.TenantServiceTransport( - 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_tenant_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.tenant_service.transports.TenantServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.TenantServiceTransport() - adc.assert_called_once() - - -def test_tenant_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) - TenantServiceClient() - 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.TenantServiceGrpcTransport, - transports.TenantServiceGrpcAsyncIOTransport, - ], -) -def test_tenant_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", - [ - 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", - [ - (transports.TenantServiceGrpcTransport, grpc_helpers), - (transports.TenantServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_tenant_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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) -def test_tenant_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_tenant_service_host_no_port(transport_name): - client = TenantServiceClient( - 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_tenant_service_host_with_port(transport_name): - client = TenantServiceClient( - 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_tenant_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.TenantServiceGrpcTransport( - 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_tenant_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.TenantServiceGrpcAsyncIOTransport( - 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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) -def test_tenant_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.TenantServiceGrpcTransport, transports.TenantServiceGrpcAsyncIOTransport]) -def test_tenant_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_tenant_path(): - project = "squid" - tenant = "clam" - expected = "projects/{project}/tenants/{tenant}".format(project=project, tenant=tenant, ) - actual = TenantServiceClient.tenant_path(project, tenant) - assert expected == actual - - -def test_parse_tenant_path(): - expected = { - "project": "whelk", - "tenant": "octopus", - } - path = TenantServiceClient.tenant_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_tenant_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = TenantServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "nudibranch", - } - path = TenantServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder, ) - actual = TenantServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "mussel", - } - path = TenantServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "winkle" - expected = "organizations/{organization}".format(organization=organization, ) - actual = TenantServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nautilus", - } - path = TenantServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "scallop" - expected = "projects/{project}".format(project=project, ) - actual = TenantServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "abalone", - } - path = TenantServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "squid" - location = "clam" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = TenantServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "whelk", - "location": "octopus", - } - path = TenantServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = TenantServiceClient.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.TenantServiceTransport, '_prep_wrapped_messages') as prep: - client = TenantServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.TenantServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = TenantServiceClient.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 = TenantServiceAsyncClient( - 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_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_async(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", - } - - for transport, close_name in transports.items(): - client = TenantServiceClient( - 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 = TenantServiceClient( - 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", [ - (TenantServiceClient, transports.TenantServiceGrpcTransport), - (TenantServiceAsyncClient, transports.TenantServiceGrpcAsyncIOTransport), -]) -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, - api_audience=None, - ) diff --git a/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py b/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py index 6b77867e..3d8f0347 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_create_company_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_CreateCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py b/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py index 1cd0488a..27af7ae7 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_create_company_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_CreateCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py b/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py index fa80c908..caa9c658 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_delete_company_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_DeleteCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py b/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py index 9cfaef34..b2340952 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_delete_company_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_DeleteCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py b/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py index 870311e2..413260e0 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_get_company_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_GetCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py b/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py index fe138109..d7a20735 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_get_company_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_GetCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py b/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py index abe4949f..acfa5f8c 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_list_companies_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_ListCompanies_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py b/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py index 92b50945..8fc4f9a4 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_list_companies_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_ListCompanies_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py b/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py index 91c251ce..15895bf7 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_update_company_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_UpdateCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py b/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py index c2403d25..f382f1d7 100644 --- a/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py +++ b/samples/generated_samples/jobs_v4_generated_company_service_update_company_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_CompanyService_UpdateCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py b/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py index e897e85e..9e06a6b2 100644 --- a/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py +++ b/samples/generated_samples/jobs_v4_generated_completion_complete_query_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_Completion_CompleteQuery_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py b/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py index e5b421ee..8859bc96 100644 --- a/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py +++ b/samples/generated_samples/jobs_v4_generated_completion_complete_query_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_Completion_CompleteQuery_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py b/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py index 8ff8edc8..cbb8a812 100644 --- a/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py +++ b/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_EventService_CreateClientEvent_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 @@ -34,7 +41,7 @@ async def sample_create_client_event(): # Initialize request argument(s) client_event = talent_v4.ClientEvent() client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value_1', 'jobs_value_2'] + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] client_event.event_id = "event_id_value" request = talent_v4.CreateClientEventRequest( diff --git a/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py b/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py index debd6f4a..21337ce6 100644 --- a/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py +++ b/samples/generated_samples/jobs_v4_generated_event_service_create_client_event_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_EventService_CreateClientEvent_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 @@ -34,7 +41,7 @@ def sample_create_client_event(): # Initialize request argument(s) client_event = talent_v4.ClientEvent() client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value_1', 'jobs_value_2'] + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] client_event.event_id = "event_id_value" request = talent_v4.CreateClientEventRequest( diff --git a/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py b/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py index 2f2f0e2a..489582dd 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_BatchCreateJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py index c39497d8..b6d2524a 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_batch_create_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_BatchCreateJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py b/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py index ed59b217..3fc26c7d 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_BatchDeleteJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py index b6cc7857..d9be665a 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_batch_delete_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_BatchDeleteJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py b/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py index 911ed83c..780f7ddd 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_BatchUpdateJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py index 825d8108..952a835e 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_batch_update_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_BatchUpdateJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py b/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py index ed1a99c9..d5c1f62e 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_create_job_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_CreateJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py index beef27d9..b9a794a1 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_create_job_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_CreateJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py b/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py index 71a50b70..9bf6acb8 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_delete_job_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_DeleteJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py index 14a7c4b8..88bd9f96 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_delete_job_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_DeleteJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py b/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py index b3eaec7b..d69b7c04 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_get_job_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_GetJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py index cf459e61..f757ceea 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_get_job_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_GetJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py b/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py index cb902393..2bf1f6cd 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_ListJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py index 9c25febc..5537f71f 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_list_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_ListJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py b/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py index 9bc34626..76fb33fd 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_SearchJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py b/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py index d44a032a..fb28ec78 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_SearchJobsForAlert_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py index d13e114d..65151219 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_for_alert_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_SearchJobsForAlert_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py index 7d871908..b629c86d 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_search_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_SearchJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py b/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py index 836482a7..295e6fde 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_update_job_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_UpdateJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py b/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py index a462877a..b0488902 100644 --- a/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py +++ b/samples/generated_samples/jobs_v4_generated_job_service_update_job_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_JobService_UpdateJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py b/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py index 5b04c6da..6dc93795 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_CreateTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py b/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py index faaf0ab0..350b7d5b 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_create_tenant_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_CreateTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py b/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py index b21a1c5a..4938c7d5 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_DeleteTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py b/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py index 39079d8b..948fb992 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_delete_tenant_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_DeleteTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py b/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py index 59beafb0..329d4493 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_GetTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py b/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py index 37f3687e..d6b4a785 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_get_tenant_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_GetTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py b/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py index 8e71153d..1be0cc08 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_ListTenants_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py b/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py index 884fd2ec..df7fa906 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_list_tenants_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_ListTenants_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py b/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py index 931f1e2d..4098de41 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_async.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_UpdateTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py b/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py index e2e3e8ec..d70a2de6 100644 --- a/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py +++ b/samples/generated_samples/jobs_v4_generated_tenant_service_update_tenant_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4_generated_TenantService_UpdateTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py index 2f35ec16..beb39636 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_CreateCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py index b1c2d446..3c09bc1f 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_create_company_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_CreateCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py index 981d3c06..3afbe7d5 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_DeleteCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py index c88c0f43..efaed012 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_delete_company_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_DeleteCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py index 7db11f1b..f3c4a42a 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_GetCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py index 0dba2921..e8d8e57d 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_get_company_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_GetCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py index a64d3181..4b45b106 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_ListCompanies_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py index df20efd1..77f31bc4 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_list_companies_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_ListCompanies_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py index 7581fcd3..cf6bd525 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_UpdateCompany_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py b/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py index c7a53840..091111cf 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_company_service_update_company_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_CompanyService_UpdateCompany_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py b/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py index 0a40267d..79699ead 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_Completion_CompleteQuery_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py b/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py index 8745d731..9d46cef2 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_completion_complete_query_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_Completion_CompleteQuery_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py b/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py index adabee37..d6a45c89 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_EventService_CreateClientEvent_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 @@ -34,7 +41,7 @@ async def sample_create_client_event(): # Initialize request argument(s) client_event = talent_v4beta1.ClientEvent() client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value_1', 'jobs_value_2'] + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] client_event.event_id = "event_id_value" request = talent_v4beta1.CreateClientEventRequest( diff --git a/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py b/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py index c7d9bd2e..15421a47 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_event_service_create_client_event_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_EventService_CreateClientEvent_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 @@ -34,7 +41,7 @@ def sample_create_client_event(): # Initialize request argument(s) client_event = talent_v4beta1.ClientEvent() client_event.job_event.type_ = "INTERVIEW_GRANTED" - client_event.job_event.jobs = ['jobs_value_1', 'jobs_value_2'] + client_event.job_event.jobs = ['jobs_value1', 'jobs_value2'] client_event.event_id = "event_id_value" request = talent_v4beta1.CreateClientEventRequest( diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py index 0c9a5136..6a13b56b 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_BatchCreateJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py index d0617387..0bd3f5ed 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_create_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_BatchCreateJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py index 9b3a77fe..43bcb71e 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_BatchDeleteJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py index 17e1868c..953ac105 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_delete_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_BatchDeleteJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py index 2cd69d62..698e644d 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_BatchUpdateJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py index 37f986a8..e80971da 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_batch_update_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_BatchUpdateJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py index 8e518101..7e36a95f 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_CreateJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py index b8ccda7e..600d8be9 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_create_job_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_CreateJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py index 7df0a80f..ad8224b5 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_DeleteJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py index a8cef04e..1ef01e19 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_delete_job_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_DeleteJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py index de278670..d9a57ad5 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_GetJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py index 7053e3be..4a9bc662 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_get_job_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_GetJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py index 0d626d02..5ec12499 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_ListJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py index 5e2ad80f..793a4653 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_list_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_ListJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py index 38e54bc0..9f5a1335 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_SearchJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py index d14b134b..eeffc48d 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_SearchJobsForAlert_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py index 26de437b..93c7cd15 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_for_alert_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_SearchJobsForAlert_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py index 212e5310..0df23612 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_search_jobs_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_SearchJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py index 3595198f..60555fa8 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_UpdateJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py b/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py index eb1495a5..8170b2d5 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_job_service_update_job_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_JobService_UpdateJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py index 7baf97f7..239e5dbd 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_CreateTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py index d4c3c679..a8673253 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_create_tenant_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_CreateTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py index 2dcbea55..3425f2e7 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_DeleteTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py index cb6d6f36..756cb030 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_delete_tenant_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_DeleteTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py index 52972845..492c8e7d 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_GetTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py index f52ea235..1bfdfab9 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_get_tenant_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_GetTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py index bf4c8a35..fc99a810 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_ListTenants_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py index 122cf002..08f8a75c 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_list_tenants_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_ListTenants_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py index 9ebb9cfe..7f60e81e 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_async.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_UpdateTenant_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py index b08a442f..60849278 100644 --- a/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py +++ b/samples/generated_samples/jobs_v4beta1_generated_tenant_service_update_tenant_sync.py @@ -24,6 +24,13 @@ # [START jobs_v4beta1_generated_TenantService_UpdateTenant_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import talent_v4beta1 diff --git a/samples/generated_samples/snippet_metadata_talent_v4.json b/samples/generated_samples/snippet_metadata_talent_v4.json index b705b9f3..abf91447 100644 --- a/samples/generated_samples/snippet_metadata_talent_v4.json +++ b/samples/generated_samples/snippet_metadata_talent_v4.json @@ -63,33 +63,33 @@ "regionTag": "jobs_v4_generated_CompanyService_CreateCompany_async", "segments": [ { - "end": 49, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 56, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 43, - "start": 34, + "end": 50, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 53, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], @@ -147,33 +147,33 @@ "regionTag": "jobs_v4_generated_CompanyService_CreateCompany_sync", "segments": [ { - "end": 49, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 56, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 43, - "start": 34, + "end": 50, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 53, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], @@ -227,31 +227,31 @@ "regionTag": "jobs_v4_generated_CompanyService_DeleteCompany_async", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -304,31 +304,31 @@ "regionTag": "jobs_v4_generated_CompanyService_DeleteCompany_sync", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -383,33 +383,33 @@ "regionTag": "jobs_v4_generated_CompanyService_GetCompany_async", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -463,33 +463,33 @@ "regionTag": "jobs_v4_generated_CompanyService_GetCompany_sync", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -544,33 +544,33 @@ "regionTag": "jobs_v4_generated_CompanyService_ListCompanies_async", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -624,33 +624,33 @@ "regionTag": "jobs_v4_generated_CompanyService_ListCompanies_sync", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -709,33 +709,33 @@ "regionTag": "jobs_v4_generated_CompanyService_UpdateCompany_async", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 42, - "start": 34, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 43, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -793,33 +793,33 @@ "regionTag": "jobs_v4_generated_CompanyService_UpdateCompany_sync", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 42, - "start": 34, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 43, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -870,33 +870,33 @@ "regionTag": "jobs_v4_generated_Completion_CompleteQuery_async", "segments": [ { - "end": 46, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 53, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 40, - "start": 34, + "end": 47, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 43, - "start": 41, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 44, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], @@ -946,33 +946,33 @@ "regionTag": "jobs_v4_generated_Completion_CompleteQuery_sync", "segments": [ { - "end": 46, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 53, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 40, - "start": 34, + "end": 47, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 43, - "start": 41, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 44, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], @@ -1031,33 +1031,33 @@ "regionTag": "jobs_v4_generated_EventService_CreateClientEvent_async", "segments": [ { - "end": 50, + "end": 57, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 57, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 44, - "start": 34, + "end": 51, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 54, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 58, + "start": 55, "type": "RESPONSE_HANDLING" } ], @@ -1115,33 +1115,33 @@ "regionTag": "jobs_v4_generated_EventService_CreateClientEvent_sync", "segments": [ { - "end": 50, + "end": 57, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 57, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 44, - "start": 34, + "end": 51, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 54, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 58, + "start": 55, "type": "RESPONSE_HANDLING" } ], @@ -1200,33 +1200,33 @@ "regionTag": "jobs_v4_generated_JobService_BatchCreateJobs_async", "segments": [ { - "end": 55, + "end": 62, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 62, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 59, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 63, + "start": 60, "type": "RESPONSE_HANDLING" } ], @@ -1284,33 +1284,33 @@ "regionTag": "jobs_v4_generated_JobService_BatchCreateJobs_sync", "segments": [ { - "end": 55, + "end": 62, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 62, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 59, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 63, + "start": 60, "type": "RESPONSE_HANDLING" } ], @@ -1369,33 +1369,33 @@ "regionTag": "jobs_v4_generated_JobService_BatchDeleteJobs_async", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 39, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -1453,33 +1453,33 @@ "regionTag": "jobs_v4_generated_JobService_BatchDeleteJobs_sync", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 39, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -1538,33 +1538,33 @@ "regionTag": "jobs_v4_generated_JobService_BatchUpdateJobs_async", "segments": [ { - "end": 55, + "end": 62, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 62, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 59, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 63, + "start": 60, "type": "RESPONSE_HANDLING" } ], @@ -1622,33 +1622,33 @@ "regionTag": "jobs_v4_generated_JobService_BatchUpdateJobs_sync", "segments": [ { - "end": 55, + "end": 62, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 62, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 59, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 63, + "start": 60, "type": "RESPONSE_HANDLING" } ], @@ -1707,33 +1707,33 @@ "regionTag": "jobs_v4_generated_JobService_CreateJob_async", "segments": [ { - "end": 51, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 58, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 55, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], @@ -1791,33 +1791,33 @@ "regionTag": "jobs_v4_generated_JobService_CreateJob_sync", "segments": [ { - "end": 51, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 58, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 55, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], @@ -1871,31 +1871,31 @@ "regionTag": "jobs_v4_generated_JobService_DeleteJob_async", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -1948,31 +1948,31 @@ "regionTag": "jobs_v4_generated_JobService_DeleteJob_sync", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -2027,33 +2027,33 @@ "regionTag": "jobs_v4_generated_JobService_GetJob_async", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2107,33 +2107,33 @@ "regionTag": "jobs_v4_generated_JobService_GetJob_sync", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2192,33 +2192,33 @@ "regionTag": "jobs_v4_generated_JobService_ListJobs_async", "segments": [ { - "end": 46, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 53, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 46, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 43, + "end": 54, + "start": 50, "type": "RESPONSE_HANDLING" } ], @@ -2276,33 +2276,33 @@ "regionTag": "jobs_v4_generated_JobService_ListJobs_sync", "segments": [ { - "end": 46, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 53, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 46, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 43, + "end": 54, + "start": 50, "type": "RESPONSE_HANDLING" } ], @@ -2353,33 +2353,33 @@ "regionTag": "jobs_v4_generated_JobService_SearchJobsForAlert_async", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2429,33 +2429,33 @@ "regionTag": "jobs_v4_generated_JobService_SearchJobsForAlert_sync", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2506,33 +2506,33 @@ "regionTag": "jobs_v4_generated_JobService_SearchJobs_async", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2582,33 +2582,33 @@ "regionTag": "jobs_v4_generated_JobService_SearchJobs_sync", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2667,33 +2667,33 @@ "regionTag": "jobs_v4_generated_JobService_UpdateJob_async", "segments": [ { - "end": 50, + "end": 57, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 57, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 44, - "start": 34, + "end": 51, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 54, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 58, + "start": 55, "type": "RESPONSE_HANDLING" } ], @@ -2751,33 +2751,33 @@ "regionTag": "jobs_v4_generated_JobService_UpdateJob_sync", "segments": [ { - "end": 50, + "end": 57, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 57, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 44, - "start": 34, + "end": 51, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 54, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 58, + "start": 55, "type": "RESPONSE_HANDLING" } ], @@ -2836,33 +2836,33 @@ "regionTag": "jobs_v4_generated_TenantService_CreateTenant_async", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 42, - "start": 34, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 43, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -2920,33 +2920,33 @@ "regionTag": "jobs_v4_generated_TenantService_CreateTenant_sync", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 42, - "start": 34, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 43, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -3000,31 +3000,31 @@ "regionTag": "jobs_v4_generated_TenantService_DeleteTenant_async", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -3077,31 +3077,31 @@ "regionTag": "jobs_v4_generated_TenantService_DeleteTenant_sync", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -3156,33 +3156,33 @@ "regionTag": "jobs_v4_generated_TenantService_GetTenant_async", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -3236,33 +3236,33 @@ "regionTag": "jobs_v4_generated_TenantService_GetTenant_sync", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -3317,33 +3317,33 @@ "regionTag": "jobs_v4_generated_TenantService_ListTenants_async", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -3397,33 +3397,33 @@ "regionTag": "jobs_v4_generated_TenantService_ListTenants_sync", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -3482,33 +3482,33 @@ "regionTag": "jobs_v4_generated_TenantService_UpdateTenant_async", "segments": [ { - "end": 47, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 47, + "end": 54, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 41, - "start": 34, + "end": 48, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 44, - "start": 42, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 48, - "start": 45, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], @@ -3566,33 +3566,33 @@ "regionTag": "jobs_v4_generated_TenantService_UpdateTenant_sync", "segments": [ { - "end": 47, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 47, + "end": 54, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 41, - "start": 34, + "end": 48, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 44, - "start": 42, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 48, - "start": 45, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], diff --git a/samples/generated_samples/snippet_metadata_talent_v4beta1.json b/samples/generated_samples/snippet_metadata_talent_v4beta1.json index 7d67e977..5b2bf382 100644 --- a/samples/generated_samples/snippet_metadata_talent_v4beta1.json +++ b/samples/generated_samples/snippet_metadata_talent_v4beta1.json @@ -63,33 +63,33 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_CreateCompany_async", "segments": [ { - "end": 49, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 56, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 43, - "start": 34, + "end": 50, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 53, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], @@ -147,33 +147,33 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_CreateCompany_sync", "segments": [ { - "end": 49, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 56, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 43, - "start": 34, + "end": 50, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 46, - "start": 44, + "end": 53, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 50, - "start": 47, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], @@ -227,31 +227,31 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_DeleteCompany_async", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -304,31 +304,31 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_DeleteCompany_sync", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -383,33 +383,33 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_GetCompany_async", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -463,33 +463,33 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_GetCompany_sync", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -544,33 +544,33 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_ListCompanies_async", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -624,33 +624,33 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_ListCompanies_sync", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -705,33 +705,33 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_UpdateCompany_async", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 42, - "start": 34, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 43, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -785,33 +785,33 @@ "regionTag": "jobs_v4beta1_generated_CompanyService_UpdateCompany_sync", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 42, - "start": 34, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 43, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -862,33 +862,33 @@ "regionTag": "jobs_v4beta1_generated_Completion_CompleteQuery_async", "segments": [ { - "end": 46, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 53, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 40, - "start": 34, + "end": 47, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 43, - "start": 41, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 44, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], @@ -938,33 +938,33 @@ "regionTag": "jobs_v4beta1_generated_Completion_CompleteQuery_sync", "segments": [ { - "end": 46, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 53, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 40, - "start": 34, + "end": 47, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 43, - "start": 41, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 44, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], @@ -1023,33 +1023,33 @@ "regionTag": "jobs_v4beta1_generated_EventService_CreateClientEvent_async", "segments": [ { - "end": 50, + "end": 57, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 57, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 44, - "start": 34, + "end": 51, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 54, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 58, + "start": 55, "type": "RESPONSE_HANDLING" } ], @@ -1107,33 +1107,33 @@ "regionTag": "jobs_v4beta1_generated_EventService_CreateClientEvent_sync", "segments": [ { - "end": 50, + "end": 57, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 57, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 44, - "start": 34, + "end": 51, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 54, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 58, + "start": 55, "type": "RESPONSE_HANDLING" } ], @@ -1192,33 +1192,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_BatchCreateJobs_async", "segments": [ { - "end": 55, + "end": 62, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 62, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 59, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 63, + "start": 60, "type": "RESPONSE_HANDLING" } ], @@ -1276,33 +1276,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_BatchCreateJobs_sync", "segments": [ { - "end": 55, + "end": 62, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 62, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 59, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 63, + "start": 60, "type": "RESPONSE_HANDLING" } ], @@ -1360,31 +1360,31 @@ "regionTag": "jobs_v4beta1_generated_JobService_BatchDeleteJobs_async", "segments": [ { - "end": 43, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 43, + "end": 50, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 46, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 40, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 44, + "end": 51, "type": "RESPONSE_HANDLING" } ], @@ -1441,31 +1441,31 @@ "regionTag": "jobs_v4beta1_generated_JobService_BatchDeleteJobs_sync", "segments": [ { - "end": 43, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 43, + "end": 50, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 46, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 40, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 44, + "end": 51, "type": "RESPONSE_HANDLING" } ], @@ -1524,33 +1524,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_BatchUpdateJobs_async", "segments": [ { - "end": 55, + "end": 62, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 62, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 59, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 63, + "start": 60, "type": "RESPONSE_HANDLING" } ], @@ -1608,33 +1608,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_BatchUpdateJobs_sync", "segments": [ { - "end": 55, + "end": 62, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 62, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 59, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 63, + "start": 60, "type": "RESPONSE_HANDLING" } ], @@ -1693,33 +1693,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_CreateJob_async", "segments": [ { - "end": 51, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 58, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 55, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], @@ -1777,33 +1777,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_CreateJob_sync", "segments": [ { - "end": 51, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 58, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 34, + "end": 52, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 55, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], @@ -1857,31 +1857,31 @@ "regionTag": "jobs_v4beta1_generated_JobService_DeleteJob_async", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -1934,31 +1934,31 @@ "regionTag": "jobs_v4beta1_generated_JobService_DeleteJob_sync", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -2013,33 +2013,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_GetJob_async", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2093,33 +2093,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_GetJob_sync", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2178,33 +2178,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_async", "segments": [ { - "end": 46, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 53, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 46, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 43, + "end": 54, + "start": 50, "type": "RESPONSE_HANDLING" } ], @@ -2262,33 +2262,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_ListJobs_sync", "segments": [ { - "end": 46, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 46, + "end": 53, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 46, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 47, - "start": 43, + "end": 54, + "start": 50, "type": "RESPONSE_HANDLING" } ], @@ -2339,33 +2339,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_SearchJobsForAlert_async", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2415,33 +2415,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_SearchJobsForAlert_sync", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2492,33 +2492,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_async", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2568,33 +2568,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_SearchJobs_sync", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -2649,33 +2649,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_async", "segments": [ { - "end": 50, + "end": 57, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 57, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 44, - "start": 34, + "end": 51, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 54, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 58, + "start": 55, "type": "RESPONSE_HANDLING" } ], @@ -2729,33 +2729,33 @@ "regionTag": "jobs_v4beta1_generated_JobService_UpdateJob_sync", "segments": [ { - "end": 50, + "end": 57, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 57, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 44, - "start": 34, + "end": 51, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 54, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 58, + "start": 55, "type": "RESPONSE_HANDLING" } ], @@ -2814,33 +2814,33 @@ "regionTag": "jobs_v4beta1_generated_TenantService_CreateTenant_async", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 42, - "start": 34, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 43, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -2898,33 +2898,33 @@ "regionTag": "jobs_v4beta1_generated_TenantService_CreateTenant_sync", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 42, - "start": 34, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 45, - "start": 43, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 49, - "start": 46, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -2978,31 +2978,31 @@ "regionTag": "jobs_v4beta1_generated_TenantService_DeleteTenant_async", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -3055,31 +3055,31 @@ "regionTag": "jobs_v4beta1_generated_TenantService_DeleteTenant_sync", "segments": [ { - "end": 42, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 42, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 39, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 43, + "end": 50, "type": "RESPONSE_HANDLING" } ], @@ -3134,33 +3134,33 @@ "regionTag": "jobs_v4beta1_generated_TenantService_GetTenant_async", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -3214,33 +3214,33 @@ "regionTag": "jobs_v4beta1_generated_TenantService_GetTenant_sync", "segments": [ { - "end": 44, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 51, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -3295,33 +3295,33 @@ "regionTag": "jobs_v4beta1_generated_TenantService_ListTenants_async", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -3375,33 +3375,33 @@ "regionTag": "jobs_v4beta1_generated_TenantService_ListTenants_sync", "segments": [ { - "end": 45, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 42, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -3456,33 +3456,33 @@ "regionTag": "jobs_v4beta1_generated_TenantService_UpdateTenant_async", "segments": [ { - "end": 47, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 47, + "end": 54, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 41, - "start": 34, + "end": 48, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 44, - "start": 42, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 48, - "start": 45, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], @@ -3536,33 +3536,33 @@ "regionTag": "jobs_v4beta1_generated_TenantService_UpdateTenant_sync", "segments": [ { - "end": 47, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 47, + "end": 54, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 41, - "start": 34, + "end": 48, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 44, - "start": 42, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 48, - "start": 45, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ],