diff --git a/.librarian/state.yaml b/.librarian/state.yaml index b617825dd602..6eff59ec6595 100644 --- a/.librarian/state.yaml +++ b/.librarian/state.yaml @@ -2,7 +2,7 @@ image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-li libraries: - id: google-cloud-dlp version: 3.32.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/privacy/dlp/v2 service_config: dlp_v2.yaml @@ -21,7 +21,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-eventarc version: 1.16.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/eventarc/v1 service_config: eventarc_v1.yaml @@ -40,7 +40,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-video-live-stream version: 1.13.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/video/livestream/v1 service_config: livestream_v1.yaml @@ -59,7 +59,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-ads-marketingplatform-admin version: 0.1.6 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/marketingplatform/admin/v1alpha service_config: marketingplatformadmin_v1alpha.yaml @@ -78,7 +78,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-ai-generativelanguage version: 0.7.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/ai/generativelanguage/v1 service_config: generativelanguage_v1.yaml @@ -105,7 +105,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-analytics-admin version: 0.25.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/analytics/admin/v1beta service_config: analyticsadmin_v1beta.yaml @@ -126,7 +126,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-analytics-data version: 0.18.19 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/analytics/data/v1alpha service_config: analyticsdata_v1alpha.yaml @@ -147,7 +147,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-ads-admanager version: 0.4.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/ads/admanager/v1 service_config: admanager_v1.yaml @@ -166,7 +166,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-card version: 0.1.8 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/apps/card/v1 service_config: "" @@ -186,7 +186,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-chat version: 0.2.9 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/chat/v1 service_config: chat_v1.yaml @@ -205,7 +205,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-events-subscriptions version: 0.2.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/apps/events/subscriptions/v1 service_config: workspaceevents_v1.yaml @@ -226,7 +226,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-meet version: 0.1.16 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/apps/meet/v2beta service_config: meet_v2beta.yaml @@ -247,7 +247,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-area120-tables version: 0.11.17 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/area120/tables/v1alpha1 service_config: area120tables_v1alpha1.yaml @@ -266,7 +266,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-access-approval version: 1.16.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/accessapproval/v1 service_config: accessapproval_v1.yaml @@ -285,7 +285,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-advisorynotifications version: 0.3.16 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/advisorynotifications/v1 service_config: advisorynotifications_v1.yaml @@ -304,7 +304,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-alloydb version: 0.5.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/alloydb/v1beta service_config: alloydb_v1beta.yaml @@ -327,7 +327,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-alloydb-connectors version: 0.1.11 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/alloydb/connectors/v1 service_config: connectors_v1.yaml @@ -351,7 +351,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-api-gateway version: 1.12.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/apigateway/v1 service_config: apigateway_v1.yaml @@ -370,7 +370,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-api-keys version: 0.5.17 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/api/apikeys/v2 service_config: apikeys_v2.yaml @@ -389,7 +389,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-apigee-connect version: 1.12.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/apigeeconnect/v1 service_config: apigeeconnect_v1.yaml @@ -408,7 +408,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-apigee-registry version: 0.6.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/apigeeregistry/v1 service_config: apigeeregistry_v1.yaml @@ -427,7 +427,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-appengine-admin version: 1.14.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/appengine/v1 service_config: appengine_v1.yaml @@ -446,7 +446,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-appengine-logging version: 1.6.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/appengine/logging/v1 service_config: "" @@ -466,7 +466,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-apphub version: 0.1.10 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/apphub/v1 service_config: apphub_v1.yaml @@ -485,7 +485,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-artifact-registry version: 1.16.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/devtools/artifactregistry/v1 service_config: artifactregistry_v1.yaml @@ -506,7 +506,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-automl version: 2.16.4 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/automl/v1beta1 service_config: automl_v1beta1.yaml @@ -532,7 +532,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-backupdr version: 0.2.5 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/backupdr/v1 service_config: backupdr_v1.yaml @@ -551,7 +551,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bare-metal-solution version: 1.10.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/baremetalsolution/v2 service_config: baremetalsolution_v2.yaml @@ -570,7 +570,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-batch version: 0.17.37 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/batch/v1alpha service_config: batch_v1alpha.yaml @@ -591,7 +591,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-support version: 0.1.19 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/support/v2beta service_config: cloudsupport_v2beta.yaml @@ -612,7 +612,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-talent version: 2.17.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/talent/v4beta1 service_config: jobs_v4beta1.yaml @@ -633,7 +633,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-tpu version: 1.23.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/tpu/v2alpha1 service_config: tpu_v2alpha1.yaml @@ -656,7 +656,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-video-transcoder version: 1.17.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/video/transcoder/v1 service_config: transcoder_v1.yaml @@ -675,7 +675,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-visionai version: 0.1.10 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/visionai/v1alpha1 service_config: visionai_v1alpha1.yaml @@ -696,7 +696,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-vm-migration version: 1.12.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/vmmigration/v1 service_config: vmmigration_v1.yaml @@ -715,7 +715,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-vmwareengine version: 1.8.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/vmwareengine/v1 service_config: vmwareengine_v1.yaml @@ -734,7 +734,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-vpc-access version: 1.13.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/vpcaccess/v1 service_config: vpcaccess_v1.yaml @@ -753,7 +753,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-websecurityscanner version: 1.17.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/websecurityscanner/v1alpha service_config: websecurityscanner_v1alpha.yaml @@ -776,7 +776,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-workstations version: 0.5.15 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/workstations/v1beta service_config: workstations_v1beta.yaml @@ -797,7 +797,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-apihub version: 0.3.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/apihub/v1 service_config: apihub_v1.yaml @@ -816,7 +816,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-asset version: 4.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/asset/v1p5beta1 service_config: cloudasset_v1p5beta1.yaml @@ -841,7 +841,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-assured-workloads version: 2.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/assuredworkloads/v1 service_config: assuredworkloads_v1.yaml @@ -862,7 +862,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-beyondcorp-appconnections version: 0.4.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/beyondcorp/appconnections/v1 service_config: beyondcorp_v1.yaml @@ -881,7 +881,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-beyondcorp-appconnectors version: 0.4.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/beyondcorp/appconnectors/v1 service_config: beyondcorp_v1.yaml @@ -900,7 +900,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-beyondcorp-appgateways version: 0.4.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/beyondcorp/appgateways/v1 service_config: beyondcorp_v1.yaml @@ -919,7 +919,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-beyondcorp-clientconnectorservices version: 0.4.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/beyondcorp/clientconnectorservices/v1 service_config: beyondcorp_v1.yaml @@ -938,7 +938,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-beyondcorp-clientgateways version: 0.4.17 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/beyondcorp/clientgateways/v1 service_config: beyondcorp_v1.yaml @@ -957,7 +957,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bigquery-analyticshub version: 0.4.20 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/bigquery/analyticshub/v1 service_config: analyticshub_v1.yaml @@ -976,7 +976,7 @@ libraries: tag_format: '{id}-v{version}' - id: googleapis-common-protos version: 1.70.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/api service_config: serviceconfig.yaml @@ -998,7 +998,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-storagebatchoperations version: 0.1.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/storagebatchoperations/v1 service_config: storagebatchoperations_v1.yaml @@ -1017,7 +1017,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-storageinsights version: 0.1.16 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/storageinsights/v1 service_config: storageinsights_v1.yaml @@ -1036,7 +1036,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-tasks version: 2.19.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/tasks/v2beta2 service_config: cloudtasks_v2beta2.yaml @@ -1060,7 +1060,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-telcoautomation version: 0.2.11 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/telcoautomation/v1 service_config: telcoautomation_v1.yaml @@ -1082,7 +1082,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-texttospeech version: 2.31.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/texttospeech/v1 service_config: texttospeech_v1.yaml @@ -1103,7 +1103,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-trace version: 1.16.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/devtools/cloudtrace/v2 service_config: cloudtrace_v2.yaml @@ -1124,7 +1124,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-videointelligence version: 2.16.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/videointelligence/v1p3beta1 service_config: videointelligence_v1p3beta1.yaml @@ -1151,7 +1151,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-vision version: 3.10.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/vision/v1p3beta1 service_config: vision_v1p3beta1.yaml @@ -1181,7 +1181,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-webrisk version: 1.18.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/webrisk/v1beta1 service_config: webrisk_v1beta1.yaml @@ -1202,7 +1202,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-access-context-manager version: 0.2.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/identity/accesscontextmanager/v1 service_config: accesscontextmanager_v1.yaml @@ -1216,7 +1216,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-audit-log version: 0.3.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/audit service_config: cloudaudit.yaml @@ -1228,7 +1228,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bigquery-biglake version: 0.4.15 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/bigquery/biglake/v1alpha1 service_config: biglake_v1alpha1.yaml @@ -1249,7 +1249,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bigquery-connection version: 1.18.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/bigquery/connection/v1 service_config: bigqueryconnection_v1.yaml @@ -1268,7 +1268,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bigquery-data-exchange version: 0.5.20 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/bigquery/dataexchange/v1beta1 service_config: analyticshub_v1beta1.yaml @@ -1287,7 +1287,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bigquery-datapolicies version: 0.6.16 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/bigquery/datapolicies/v2beta1 service_config: bigquerydatapolicy_v2beta1.yaml @@ -1312,7 +1312,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bigquery-datatransfer version: 3.19.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/bigquery/datatransfer/v1 service_config: bigquerydatatransfer_v1.yaml @@ -1331,7 +1331,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bigquery-logging version: 1.6.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/bigquery/logging/v1 service_config: "" @@ -1351,7 +1351,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bigquery-migration version: 0.11.15 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/bigquery/migration/v2alpha service_config: bigquerymigration_v2alpha.yaml @@ -1372,7 +1372,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bigquery-reservation version: 1.20.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/bigquery/reservation/v1 service_config: bigqueryreservation_v1.yaml @@ -1391,7 +1391,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-billing version: 1.16.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/billing/v1 service_config: cloudbilling_v1.yaml @@ -1410,7 +1410,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-billing-budgets version: 1.17.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/billing/budgets/v1 service_config: billingbudgets.yaml @@ -1431,7 +1431,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-translate version: 3.21.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/translate/v3beta1 service_config: translate_v3beta1.yaml @@ -1456,7 +1456,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-binary-authorization version: 1.13.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/binaryauthorization/v1 service_config: binaryauthorization_v1.yaml @@ -1477,7 +1477,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-build version: 3.32.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/devtools/cloudbuild/v1 service_config: cloudbuild_v1.yaml @@ -1498,7 +1498,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-capacityplanner version: 0.1.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/capacityplanner/v1beta service_config: capacityplanner_v1beta.yaml @@ -1517,7 +1517,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-certificate-manager version: 1.10.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/certificatemanager/v1 service_config: certificatemanager_v1.yaml @@ -1536,7 +1536,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-channel version: 1.23.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/channel/v1 service_config: cloudchannel_v1.yaml @@ -1555,7 +1555,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-chronicle version: 0.1.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/chronicle/v1 service_config: chronicle_v1.yaml @@ -1574,7 +1574,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-cloudcontrolspartner version: 0.2.7 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/cloudcontrolspartner/v1beta service_config: cloudcontrolspartner_v1beta.yaml @@ -1595,7 +1595,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-cloudsecuritycompliance version: 0.2.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/cloudsecuritycompliance/v1 service_config: cloudsecuritycompliance_v1.yaml @@ -1614,7 +1614,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-commerce-consumer-procurement version: 0.2.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/commerce/consumer/procurement/v1 service_config: cloudcommerceconsumerprocurement_v1.yaml @@ -1635,7 +1635,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-common version: 1.5.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/common service_config: common.yaml @@ -1655,7 +1655,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-compute version: 1.39.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/compute/v1 service_config: compute_v1.yaml @@ -1674,7 +1674,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-compute-v1beta version: 0.2.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/compute/v1beta service_config: compute_v1beta.yaml @@ -1693,7 +1693,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-confidentialcomputing version: 0.5.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/confidentialcomputing/v1 service_config: confidentialcomputing_v1.yaml @@ -1712,7 +1712,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-config version: 0.1.21 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/config/v1 service_config: config_v1.yaml @@ -1731,7 +1731,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-configdelivery version: 0.1.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/configdelivery/v1beta service_config: configdelivery_v1beta.yaml @@ -1754,7 +1754,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-contact-center-insights version: 1.23.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/contactcenterinsights/v1 service_config: contactcenterinsights_v1.yaml @@ -1773,7 +1773,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-container version: 2.59.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/container/v1 service_config: container_v1.yaml @@ -1794,7 +1794,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-containeranalysis version: 2.18.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/devtools/containeranalysis/v1 service_config: containeranalysis_v1.yaml @@ -1814,7 +1814,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-contentwarehouse version: 0.7.16 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/contentwarehouse/v1 service_config: contentwarehouse_v1.yaml @@ -1833,7 +1833,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-data-fusion version: 1.13.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/datafusion/v1 service_config: datafusion_v1.yaml @@ -1852,7 +1852,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-workflows version: 1.18.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/workflows/executions/v1 service_config: workflowexecutions_v1.yaml @@ -1877,7 +1877,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-video-stitcher version: 0.8.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/video/stitcher/v1 service_config: videostitcher_v1.yaml @@ -1896,7 +1896,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-redis-cluster version: 0.1.15 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/redis/cluster/v1 service_config: redis_v1.yaml @@ -1917,7 +1917,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-resource-manager version: 1.14.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/resourcemanager/v3 service_config: cloudresourcemanager_v3.yaml @@ -1936,7 +1936,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-retail version: 2.6.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/retail/v2 service_config: retail_v2.yaml @@ -1959,7 +1959,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-run version: 0.11.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/run/v2 service_config: run_v2.yaml @@ -1978,7 +1978,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-saasplatform-saasservicemgmt version: 0.1.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/saasplatform/saasservicemgmt/v1beta1 service_config: saasservicemgmt_v1beta1.yaml @@ -1997,7 +1997,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-scheduler version: 2.16.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/scheduler/v1 service_config: cloudscheduler_v1.yaml @@ -2018,7 +2018,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-securesourcemanager version: 0.1.17 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/securesourcemanager/v1 service_config: securesourcemanager_v1.yaml @@ -2037,7 +2037,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-securitycenter version: 1.40.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/securitycenter/v2 service_config: securitycenter_v2.yaml @@ -2062,7 +2062,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-securitycentermanagement version: 0.1.22 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/securitycentermanagement/v1 service_config: securitycentermanagement_v1.yaml @@ -2081,7 +2081,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-service-control version: 1.16.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/api/servicecontrol/v2 service_config: servicecontrol.yaml @@ -2102,7 +2102,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-service-directory version: 1.14.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/servicedirectory/v1 service_config: servicedirectory_v1.yaml @@ -2123,7 +2123,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-service-management version: 1.13.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/api/servicemanagement/v1 service_config: servicemanagement_v1.yaml @@ -2142,7 +2142,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-service-usage version: 1.13.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/api/serviceusage/v1 service_config: serviceusage_v1.yaml @@ -2161,7 +2161,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-servicehealth version: 0.1.12 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/servicehealth/v1 service_config: servicehealth_v1.yaml @@ -2180,7 +2180,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-shell version: 1.12.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/shell/v1 service_config: cloudshell_v1.yaml @@ -2199,7 +2199,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-source-context version: 1.7.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/devtools/source/v1 service_config: "" @@ -2219,7 +2219,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-speech version: 2.33.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/speech/v1 service_config: speech_v1.yaml @@ -2244,7 +2244,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-storage-control version: 1.7.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/storage/control/v2 service_config: storage_v2.yaml @@ -2263,7 +2263,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-storage-transfer version: 1.17.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/storagetransfer/v1 service_config: storagetransfer_v1.yaml @@ -2282,7 +2282,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-iam-logging version: 1.4.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/iam/v1/logging service_config: "" @@ -2302,7 +2302,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-iap version: 1.17.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/iap/v1 service_config: iap_v1.yaml @@ -2321,7 +2321,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-ids version: 1.10.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/ids/v1 service_config: ids_v1.yaml @@ -2340,7 +2340,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-kms version: 3.6.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/kms/v1 service_config: cloudkms_v1.yaml @@ -2359,7 +2359,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-kms-inventory version: 0.2.15 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/kms/inventory/v1 service_config: kmsinventory_v1.yaml @@ -2378,7 +2378,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-language version: 2.17.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/language/v1 service_config: language_v1.yaml @@ -2401,7 +2401,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-licensemanager version: 0.1.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/licensemanager/v1 service_config: licensemanager_v1.yaml @@ -2420,7 +2420,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-life-sciences version: 0.9.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/lifesciences/v2beta service_config: lifesciences_v2beta.yaml @@ -2439,7 +2439,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-lustre version: 0.1.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/lustre/v1 service_config: lustre_v1.yaml @@ -2458,7 +2458,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-maintenance-api version: 0.1.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/maintenance/api/v1beta service_config: maintenance_v1beta.yaml @@ -2477,7 +2477,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-managed-identities version: 1.12.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/managedidentities/v1 service_config: managedidentities_v1.yaml @@ -2496,7 +2496,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-managedkafka version: 0.1.12 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/managedkafka/v1 service_config: managedkafka_v1.yaml @@ -2515,7 +2515,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-managedkafka-schemaregistry version: 0.1.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/managedkafka/schemaregistry/v1 service_config: managedkafka_v1.yaml @@ -2534,7 +2534,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-media-translation version: 0.11.17 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/mediatranslation/v1beta1 service_config: mediatranslation_v1beta1.yaml @@ -2553,7 +2553,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-memcache version: 1.12.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/memcache/v1 service_config: memcache_v1.yaml @@ -2574,7 +2574,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-memorystore version: 0.1.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/memorystore/v1beta service_config: memorystore_v1beta.yaml @@ -2595,7 +2595,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-migrationcenter version: 0.1.15 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/migrationcenter/v1 service_config: migrationcenter_v1.yaml @@ -2614,7 +2614,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-modelarmor version: 0.2.8 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/modelarmor/v1beta service_config: modelarmor_v1beta.yaml @@ -2635,7 +2635,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-monitoring-metrics-scopes version: 1.9.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/monitoring/metricsscope/v1 service_config: monitoring.yaml @@ -2654,7 +2654,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-netapp version: 0.3.24 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/netapp/v1 service_config: netapp_v1.yaml @@ -2673,7 +2673,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-network-connectivity version: 2.10.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/networkconnectivity/v1 service_config: networkconnectivity_v1.yaml @@ -2694,7 +2694,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-network-management version: 1.28.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/networkmanagement/v1 service_config: networkmanagement_v1.yaml @@ -2713,7 +2713,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-network-services version: 0.5.24 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/networkservices/v1 service_config: networkservices_v1.yaml @@ -2732,7 +2732,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-notebooks version: 1.13.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/notebooks/v1beta1 service_config: notebooks_v1beta1.yaml @@ -2755,7 +2755,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-optimization version: 1.11.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/optimization/v1 service_config: cloudoptimization_v1.yaml @@ -2774,7 +2774,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-oracledatabase version: 0.1.10 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/oracledatabase/v1 service_config: oracledatabase_v1.yaml @@ -2793,7 +2793,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-orchestration-airflow version: 1.17.5 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/orchestration/airflow/service/v1 service_config: composer_v1.yaml @@ -2814,7 +2814,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-os-config version: 1.21.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/osconfig/v1alpha service_config: osconfig_v1alpha.yaml @@ -2835,7 +2835,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-parallelstore version: 0.2.15 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/parallelstore/v1 service_config: parallelstore_v1.yaml @@ -2856,7 +2856,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-parametermanager version: 0.1.5 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/parametermanager/v1 service_config: parametermanager_v1.yaml @@ -2875,7 +2875,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-phishing-protection version: 1.14.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/phishingprotection/v1beta1 service_config: phishingprotection_v1beta1.yaml @@ -2894,7 +2894,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-policy-troubleshooter version: 1.13.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/policytroubleshooter/v1 service_config: policytroubleshooter_v1.yaml @@ -2913,7 +2913,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-policysimulator version: 0.1.15 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/policysimulator/v1 service_config: policysimulator_v1.yaml @@ -2932,7 +2932,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-policytroubleshooter-iam version: 0.1.13 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/policytroubleshooter/iam/v3 service_config: policytroubleshooter_v3.yaml @@ -2951,7 +2951,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-private-ca version: 1.15.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/security/privateca/v1 service_config: privateca_v1.yaml @@ -2972,7 +2972,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-private-catalog version: 0.9.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/privatecatalog/v1beta1 service_config: cloudprivatecatalog_v1beta1.yaml @@ -2991,7 +2991,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-privilegedaccessmanager version: 0.1.9 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/privilegedaccessmanager/v1 service_config: privilegedaccessmanager_v1.yaml @@ -3010,7 +3010,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-quotas version: 0.1.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/api/cloudquotas/v1 service_config: cloudquotas_v1.yaml @@ -3031,7 +3031,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-rapidmigrationassessment version: 0.1.16 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/rapidmigrationassessment/v1 service_config: rapidmigrationassessment_v1.yaml @@ -3050,7 +3050,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-recaptcha-enterprise version: 1.28.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/recaptchaenterprise/v1 service_config: recaptchaenterprise_v1.yaml @@ -3069,7 +3069,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-recommendations-ai version: 0.10.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/recommendationengine/v1beta1 service_config: recommendationengine_v1beta1.yaml @@ -3088,7 +3088,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-recommender version: 2.18.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/recommender/v1beta1 service_config: recommender_v1beta1.yaml @@ -3109,7 +3109,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-redis version: 2.18.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/redis/v1 service_config: redis_v1.yaml @@ -3130,7 +3130,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-locationfinder version: 0.1.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/locationfinder/v1 service_config: cloudlocationfinder_v1.yaml @@ -3149,7 +3149,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-data-qna version: 0.10.17 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/dataqna/v1alpha service_config: dataqna_v1alpha.yaml @@ -3168,7 +3168,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-datacatalog version: 3.27.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/datacatalog/v1 service_config: datacatalog_v1.yaml @@ -3189,7 +3189,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-datacatalog-lineage version: 0.3.14 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/datacatalog/lineage/v1 service_config: datalineage_v1.yaml @@ -3208,7 +3208,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-dataflow-client version: 0.9.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/dataflow/v1beta3 service_config: dataflow_v1beta3.yaml @@ -3227,7 +3227,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-dataform version: 0.6.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/dataform/v1beta1 service_config: dataform_v1beta1.yaml @@ -3248,7 +3248,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-datalabeling version: 1.13.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/datalabeling/v1beta1 service_config: datalabeling_v1beta1.yaml @@ -3267,7 +3267,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-dataplex version: 2.12.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/dataplex/v1 service_config: dataplex_v1.yaml @@ -3286,7 +3286,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-dataproc version: 5.22.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/dataproc/v1 service_config: dataproc_v1.yaml @@ -3305,7 +3305,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-dataproc-metastore version: 1.19.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/metastore/v1alpha service_config: metastore_v1alpha.yaml @@ -3328,7 +3328,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-datastream version: 1.15.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/datastream/v1 service_config: datastream_v1.yaml @@ -3349,7 +3349,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-deploy version: 2.7.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/deploy/v1 service_config: clouddeploy_v1.yaml @@ -3368,7 +3368,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-developerconnect version: 0.1.10 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/developerconnect/v1 service_config: developerconnect_v1.yaml @@ -3387,7 +3387,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-devicestreaming version: 0.1.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/devicestreaming/v1 service_config: devicestreaming_v1.yaml @@ -3406,7 +3406,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-dialogflow version: 2.41.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/dialogflow/v2beta1 service_config: dialogflow_v2beta1.yaml @@ -3427,7 +3427,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-discoveryengine version: 0.13.12 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/discoveryengine/v1 service_config: discoveryengine_v1.yaml @@ -3450,7 +3450,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-dms version: 1.12.4 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/clouddms/v1 service_config: datamigration_v1.yaml @@ -3469,7 +3469,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-documentai version: 3.6.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/documentai/v1beta3 service_config: documentai_v1beta3.yaml @@ -3490,7 +3490,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-domains version: 1.10.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/domains/v1beta1 service_config: domains_v1beta1.yaml @@ -3511,7 +3511,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-edgecontainer version: 0.5.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/edgecontainer/v1 service_config: edgecontainer_v1.yaml @@ -3530,7 +3530,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-edgenetwork version: 0.1.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/edgenetwork/v1 service_config: edgenetwork_v1.yaml @@ -3549,7 +3549,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-enterpriseknowledgegraph version: 0.3.17 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/enterpriseknowledgegraph/v1 service_config: enterpriseknowledgegraph_v1.yaml @@ -3568,7 +3568,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-essential-contacts version: 1.10.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/essentialcontacts/v1 service_config: essentialcontacts_v1.yaml @@ -3587,7 +3587,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-eventarc-publishing version: 0.7.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/eventarc/publishing/v1 service_config: eventarcpublishing_v1.yaml @@ -3606,7 +3606,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-filestore version: 1.13.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/filestore/v1 service_config: file_v1.yaml @@ -3625,7 +3625,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-financialservices version: 0.1.3 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/financialservices/v1 service_config: financialservices_v1.yaml @@ -3644,7 +3644,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-functions version: 1.20.4 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/functions/v2 service_config: cloudfunctions_v2.yaml @@ -3665,7 +3665,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-gdchardwaremanagement version: 0.1.13 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/gdchardwaremanagement/v1alpha service_config: gdchardwaremanagement_v1alpha.yaml @@ -3684,7 +3684,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-geminidataanalytics version: 0.4.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/geminidataanalytics/v1beta service_config: geminidataanalytics_v1beta.yaml @@ -3705,7 +3705,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-gke-backup version: 0.5.19 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/gkebackup/v1 service_config: gkebackup_v1.yaml @@ -3724,7 +3724,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-gke-connect-gateway version: 0.10.4 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/gkeconnect/gateway/v1beta1 service_config: connectgateway_v1beta1.yaml @@ -3745,7 +3745,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-security-publicca version: 0.3.18 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/cloud/security/publicca/v1 service_config: publicca_v1.yaml @@ -3766,7 +3766,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-css version: 0.1.17 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/css/v1 service_config: css_v1.yaml @@ -3785,7 +3785,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-accounts version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/accounts/v1 service_config: merchantapi_v1.yaml @@ -3806,7 +3806,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-conversions version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/conversions/v1 service_config: merchantapi_v1.yaml @@ -3827,7 +3827,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-datasources version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/datasources/v1 service_config: merchantapi_v1.yaml @@ -3848,7 +3848,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-inventories version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/inventories/v1beta service_config: merchantapi_v1beta.yaml @@ -3869,7 +3869,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-issueresolution version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/issueresolution/v1 service_config: merchantapi_v1.yaml @@ -3890,7 +3890,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-lfp version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/lfp/v1beta service_config: merchantapi_v1beta.yaml @@ -3911,7 +3911,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-notifications version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/notifications/v1 service_config: merchantapi_v1.yaml @@ -3932,7 +3932,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-ordertracking version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/ordertracking/v1 service_config: merchantapi_v1.yaml @@ -3953,7 +3953,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-products version: 1.1.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/products/v1 service_config: merchantapi_v1.yaml @@ -3974,7 +3974,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-productstudio version: 0.1.1 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/productstudio/v1alpha service_config: merchantapi_v1alpha.yaml @@ -3993,7 +3993,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-promotions version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/promotions/v1 service_config: merchantapi_v1.yaml @@ -4014,7 +4014,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-quota version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/quota/v1beta service_config: merchantapi_v1beta.yaml @@ -4035,7 +4035,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-reports version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/reports/v1beta service_config: merchantapi_v1beta.yaml @@ -4058,7 +4058,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-merchant-reviews version: 0.2.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/merchant/reviews/v1beta service_config: merchantapi_v1beta.yaml @@ -4077,7 +4077,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-shopping-type version: 1.0.0 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/shopping/type service_config: "" @@ -4097,7 +4097,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-geo-type version: 0.3.13 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/geo/type service_config: type_geo.yaml @@ -4117,7 +4117,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-maps-addressvalidation version: 0.3.20 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/maps/addressvalidation/v1 service_config: addressvalidation_v1.yaml @@ -4136,7 +4136,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-maps-areainsights version: 0.1.8 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/maps/areainsights/v1 service_config: areainsights_v1.yaml @@ -4155,7 +4155,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-maps-fleetengine version: 0.2.11 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/maps/fleetengine/v1 service_config: fleetengine_v1.yaml @@ -4174,7 +4174,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-maps-fleetengine-delivery version: 0.2.13 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/maps/fleetengine/delivery/v1 service_config: fleetengine_v1.yaml @@ -4193,7 +4193,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-maps-mapsplatformdatasets version: 0.4.8 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/maps/mapsplatformdatasets/v1 service_config: mapsplatformdatasets_v1.yaml @@ -4212,7 +4212,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-maps-places version: 0.2.2 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/maps/places/v1 service_config: places_v1.yaml @@ -4231,7 +4231,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-maps-routeoptimization version: 0.1.11 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/maps/routeoptimization/v1 service_config: routeoptimization_v1.yaml @@ -4251,7 +4251,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-maps-routing version: 0.6.16 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/maps/routing/v2 service_config: routes_v2.yaml @@ -4270,7 +4270,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-maps-solar version: 0.1.9 - last_generated_commit: 6e79e73204aed17b11e724beebb9cf11f36ea57d + last_generated_commit: 2954ae6003c9cfb49ef49c4cbc2e12dc43a97546 apis: - path: google/maps/solar/v1 service_config: solar_v1.yaml diff --git a/packages/google-cloud-capacityplanner/docs/capacityplanner_v1beta/capacity_planning_service.rst b/packages/google-cloud-capacityplanner/docs/capacityplanner_v1beta/capacity_planning_service.rst deleted file mode 100644 index cfe2d3362dda..000000000000 --- a/packages/google-cloud-capacityplanner/docs/capacityplanner_v1beta/capacity_planning_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -CapacityPlanningService ------------------------------------------ - -.. automodule:: google.cloud.capacityplanner_v1beta.services.capacity_planning_service - :members: - :inherited-members: - -.. automodule:: google.cloud.capacityplanner_v1beta.services.capacity_planning_service.pagers - :members: - :inherited-members: diff --git a/packages/google-cloud-capacityplanner/docs/capacityplanner_v1beta/services_.rst b/packages/google-cloud-capacityplanner/docs/capacityplanner_v1beta/services_.rst index ed1ad88ae3b8..0d219ffa5643 100644 --- a/packages/google-cloud-capacityplanner/docs/capacityplanner_v1beta/services_.rst +++ b/packages/google-cloud-capacityplanner/docs/capacityplanner_v1beta/services_.rst @@ -3,5 +3,4 @@ Services for Google Cloud Capacityplanner v1beta API .. toctree:: :maxdepth: 2 - capacity_planning_service usage_service diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner/__init__.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner/__init__.py index 6b97478d08b1..16c67272ce49 100644 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner/__init__.py +++ b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner/__init__.py @@ -18,12 +18,6 @@ __version__ = package_version.__version__ -from google.cloud.capacityplanner_v1beta.services.capacity_planning_service.async_client import ( - CapacityPlanningServiceAsyncClient, -) -from google.cloud.capacityplanner_v1beta.services.capacity_planning_service.client import ( - CapacityPlanningServiceClient, -) from google.cloud.capacityplanner_v1beta.services.usage_service.async_client import ( UsageServiceAsyncClient, ) @@ -31,29 +25,6 @@ UsageServiceClient, ) from google.cloud.capacityplanner_v1beta.types.allocation import Allocation -from google.cloud.capacityplanner_v1beta.types.capacity_planning_service import ( - CapacityPlan, - CapacityPlanFilters, - CapacityPlanKey, - CapacityPlanView, - CapacityType, - ChildResourceDemand, - DemandMetadata, - DemandPreference, - DemandValue, - DemandValues, - GetCapacityPlanRequest, - QueryCapacityPlanInsightsRequest, - QueryCapacityPlanInsightsResponse, - QueryCapacityPlansRequest, - QueryCapacityPlansResponse, - ResourceDemand, - ServiceDemand, - State, - TimeSeriesView, - TimeValue, - User, -) from google.cloud.capacityplanner_v1beta.types.future_reservation import ( FutureReservation, ) @@ -96,32 +67,9 @@ ) __all__ = ( - "CapacityPlanningServiceClient", - "CapacityPlanningServiceAsyncClient", "UsageServiceClient", "UsageServiceAsyncClient", "Allocation", - "CapacityPlan", - "CapacityPlanFilters", - "CapacityPlanKey", - "CapacityPlanView", - "ChildResourceDemand", - "DemandMetadata", - "DemandPreference", - "DemandValue", - "DemandValues", - "GetCapacityPlanRequest", - "QueryCapacityPlanInsightsRequest", - "QueryCapacityPlanInsightsResponse", - "QueryCapacityPlansRequest", - "QueryCapacityPlansResponse", - "ResourceDemand", - "ServiceDemand", - "TimeSeriesView", - "TimeValue", - "User", - "CapacityType", - "State", "FutureReservation", "LocationIdentifier", "LocationLevel", diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/__init__.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/__init__.py index 24e17edfe51b..8f6a8d1cdabf 100644 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/__init__.py +++ b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/__init__.py @@ -18,35 +18,8 @@ __version__ = package_version.__version__ -from .services.capacity_planning_service import ( - CapacityPlanningServiceAsyncClient, - CapacityPlanningServiceClient, -) from .services.usage_service import UsageServiceAsyncClient, UsageServiceClient from .types.allocation import Allocation -from .types.capacity_planning_service import ( - CapacityPlan, - CapacityPlanFilters, - CapacityPlanKey, - CapacityPlanView, - CapacityType, - ChildResourceDemand, - DemandMetadata, - DemandPreference, - DemandValue, - DemandValues, - GetCapacityPlanRequest, - QueryCapacityPlanInsightsRequest, - QueryCapacityPlanInsightsResponse, - QueryCapacityPlansRequest, - QueryCapacityPlansResponse, - ResourceDemand, - ServiceDemand, - State, - TimeSeriesView, - TimeValue, - User, -) from .types.future_reservation import FutureReservation from .types.location import LocationIdentifier, LocationLevel from .types.resource import ( @@ -84,21 +57,9 @@ ) __all__ = ( - "CapacityPlanningServiceAsyncClient", "UsageServiceAsyncClient", "Allocation", "BigQueryDestination", - "CapacityPlan", - "CapacityPlanFilters", - "CapacityPlanKey", - "CapacityPlanView", - "CapacityPlanningServiceClient", - "CapacityType", - "ChildResourceDemand", - "DemandMetadata", - "DemandPreference", - "DemandValue", - "DemandValues", "ExportForecastsRequest", "ExportForecastsResponse", "ExportReservationsUsageRequest", @@ -108,17 +69,12 @@ "Forecast", "FutureReservation", "GcsDestination", - "GetCapacityPlanRequest", "LocationIdentifier", "LocationLevel", "MachineShape", "OperationMetadata", "OutputConfig", "Point", - "QueryCapacityPlanInsightsRequest", - "QueryCapacityPlanInsightsResponse", - "QueryCapacityPlansRequest", - "QueryCapacityPlansResponse", "QueryForecastsRequest", "QueryForecastsResponse", "QueryReservationsRequest", @@ -128,18 +84,12 @@ "ReservationData", "ResourceAttribute", "ResourceContainer", - "ResourceDemand", "ResourceIdKey", "ResourceIdentifier", "ResourceValue", - "ServiceDemand", - "State", "TimeSeries", - "TimeSeriesView", - "TimeValue", "Unit", "UsageHistory", "UsageServiceClient", - "User", "Value", ) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/gapic_metadata.json b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/gapic_metadata.json index 344321b5d4ea..6c9e38803636 100644 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/gapic_metadata.json +++ b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/gapic_metadata.json @@ -5,70 +5,6 @@ "protoPackage": "google.cloud.capacityplanner.v1beta", "schema": "1.0", "services": { - "CapacityPlanningService": { - "clients": { - "grpc": { - "libraryClient": "CapacityPlanningServiceClient", - "rpcs": { - "GetCapacityPlan": { - "methods": [ - "get_capacity_plan" - ] - }, - "QueryCapacityPlanInsights": { - "methods": [ - "query_capacity_plan_insights" - ] - }, - "QueryCapacityPlans": { - "methods": [ - "query_capacity_plans" - ] - } - } - }, - "grpc-async": { - "libraryClient": "CapacityPlanningServiceAsyncClient", - "rpcs": { - "GetCapacityPlan": { - "methods": [ - "get_capacity_plan" - ] - }, - "QueryCapacityPlanInsights": { - "methods": [ - "query_capacity_plan_insights" - ] - }, - "QueryCapacityPlans": { - "methods": [ - "query_capacity_plans" - ] - } - } - }, - "rest": { - "libraryClient": "CapacityPlanningServiceClient", - "rpcs": { - "GetCapacityPlan": { - "methods": [ - "get_capacity_plan" - ] - }, - "QueryCapacityPlanInsights": { - "methods": [ - "query_capacity_plan_insights" - ] - }, - "QueryCapacityPlans": { - "methods": [ - "query_capacity_plans" - ] - } - } - } - } - }, "UsageService": { "clients": { "grpc": { diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/__init__.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/__init__.py deleted file mode 100644 index f1029a6bdcca..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .async_client import CapacityPlanningServiceAsyncClient -from .client import CapacityPlanningServiceClient - -__all__ = ( - "CapacityPlanningServiceClient", - "CapacityPlanningServiceAsyncClient", -) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/async_client.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/async_client.py deleted file mode 100644 index b6b9ad9d2909..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/async_client.py +++ /dev/null @@ -1,707 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 logging as std_logging -import re -from typing import ( - Callable, - Dict, - Mapping, - MutableMapping, - MutableSequence, - Optional, - Sequence, - Tuple, - Type, - Union, -) - -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry_async as retries -from google.api_core.client_options import ClientOptions -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore -import google.protobuf - -from google.cloud.capacityplanner_v1beta import gapic_version as package_version - -try: - OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - -from google.cloud.capacityplanner_v1beta.services.capacity_planning_service import ( - pagers, -) -from google.cloud.capacityplanner_v1beta.types import capacity_planning_service - -from .client import CapacityPlanningServiceClient -from .transports.base import DEFAULT_CLIENT_INFO, CapacityPlanningServiceTransport -from .transports.grpc_asyncio import CapacityPlanningServiceGrpcAsyncIOTransport - -try: - from google.api_core import client_logging # type: ignore - - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - - -class CapacityPlanningServiceAsyncClient: - """This API allows users to plan for GCP capacity associated - with their projects. Users can request additional capacity for - GCP resources such as VMs, PDs, etc. - """ - - _client: CapacityPlanningServiceClient - - # Copy defaults from the synchronous client for use here. - # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. - DEFAULT_ENDPOINT = CapacityPlanningServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = CapacityPlanningServiceClient.DEFAULT_MTLS_ENDPOINT - _DEFAULT_ENDPOINT_TEMPLATE = ( - CapacityPlanningServiceClient._DEFAULT_ENDPOINT_TEMPLATE - ) - _DEFAULT_UNIVERSE = CapacityPlanningServiceClient._DEFAULT_UNIVERSE - - capacity_plan_path = staticmethod(CapacityPlanningServiceClient.capacity_plan_path) - parse_capacity_plan_path = staticmethod( - CapacityPlanningServiceClient.parse_capacity_plan_path - ) - common_billing_account_path = staticmethod( - CapacityPlanningServiceClient.common_billing_account_path - ) - parse_common_billing_account_path = staticmethod( - CapacityPlanningServiceClient.parse_common_billing_account_path - ) - common_folder_path = staticmethod(CapacityPlanningServiceClient.common_folder_path) - parse_common_folder_path = staticmethod( - CapacityPlanningServiceClient.parse_common_folder_path - ) - common_organization_path = staticmethod( - CapacityPlanningServiceClient.common_organization_path - ) - parse_common_organization_path = staticmethod( - CapacityPlanningServiceClient.parse_common_organization_path - ) - common_project_path = staticmethod( - CapacityPlanningServiceClient.common_project_path - ) - parse_common_project_path = staticmethod( - CapacityPlanningServiceClient.parse_common_project_path - ) - common_location_path = staticmethod( - CapacityPlanningServiceClient.common_location_path - ) - parse_common_location_path = staticmethod( - CapacityPlanningServiceClient.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: - CapacityPlanningServiceAsyncClient: The constructed client. - """ - return CapacityPlanningServiceClient.from_service_account_info.__func__(CapacityPlanningServiceAsyncClient, 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: - CapacityPlanningServiceAsyncClient: The constructed client. - """ - return CapacityPlanningServiceClient.from_service_account_file.__func__(CapacityPlanningServiceAsyncClient, 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 variable 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 CapacityPlanningServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> CapacityPlanningServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CapacityPlanningServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - @property - def api_endpoint(self): - """Return the API endpoint used by the client instance. - - Returns: - str: The API endpoint used by the client instance. - """ - return self._client._api_endpoint - - @property - def universe_domain(self) -> str: - """Return the universe domain used by the client instance. - - Returns: - str: The universe domain used - by the client instance. - """ - return self._client._universe_domain - - get_transport_class = CapacityPlanningServiceClient.get_transport_class - - def __init__( - self, - *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[ - Union[ - str, - CapacityPlanningServiceTransport, - Callable[..., CapacityPlanningServiceTransport], - ] - ] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the capacity planning service async 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 (Optional[Union[str,CapacityPlanningServiceTransport,Callable[..., CapacityPlanningServiceTransport]]]): - The transport to use, or a Callable that constructs and returns a new transport to use. - If a Callable is given, it will be called with the same set of initialization - arguments as used in the CapacityPlanningServiceTransport constructor. - If set to None, a transport is chosen automatically. - client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): - Custom options for the client. - - 1. The ``api_endpoint`` property can be used to override the - default endpoint provided by the client when ``transport`` is - not explicitly provided. Only if this property is not set and - ``transport`` was not explicitly provided, the endpoint is - determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment - variable, which have one of the following values: - "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). - - 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide a client certificate for mTLS 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. - - 3. The ``universe_domain`` property can be used to override the - default "googleapis.com" universe. Note that ``api_endpoint`` - property still takes precedence; and ``universe_domain`` is - currently not supported for mTLS. - - 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. - """ - self._client = CapacityPlanningServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - ) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - std_logging.DEBUG - ): # pragma: NO COVER - _LOGGER.debug( - "Created client `google.cloud.capacityplanner_v1beta.CapacityPlanningServiceAsyncClient`.", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "universeDomain": getattr( - self._client._transport._credentials, "universe_domain", "" - ), - "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", - "credentialsInfo": getattr( - self.transport._credentials, "get_cred_info", lambda: None - )(), - } - if hasattr(self._client._transport, "_credentials") - else { - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "credentialsType": None, - }, - ) - - async def get_capacity_plan( - self, - request: Optional[ - Union[capacity_planning_service.GetCapacityPlanRequest, dict] - ] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> capacity_planning_service.CapacityPlan: - r"""Returns information about the capacity plan. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import capacityplanner_v1beta - - async def sample_get_capacity_plan(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceAsyncClient() - - # Initialize request argument(s) - request = capacityplanner_v1beta.GetCapacityPlanRequest( - name="name_value", - ) - - # Make the request - response = await client.get_capacity_plan(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.capacityplanner_v1beta.types.GetCapacityPlanRequest, dict]]): - The request object. Request for getting a capacity plan. - name (:class:`str`): - Required. The name of the capacity plan to retrieve. - Format: projects/{project}/capacityPlans/{capacity_plan} - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.capacityplanner_v1beta.types.CapacityPlan: - A plan for additional capacity needed - by a Google Cloud Platform project. This - is synonymous with CapacityDemand, - CapacityRequest, and - CapacityDemandRequest. - - """ - # 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. - flattened_params = [name] - has_flattened_params = ( - len([param for param in flattened_params if param is not None]) > 0 - ) - 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." - ) - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, capacity_planning_service.GetCapacityPlanRequest): - request = capacity_planning_service.GetCapacityPlanRequest(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._client._transport._wrapped_methods[ - self._client._transport.get_capacity_plan - ] - - # 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),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def query_capacity_plans( - self, - request: Optional[ - Union[capacity_planning_service.QueryCapacityPlansRequest, dict] - ] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.QueryCapacityPlansAsyncPager: - r"""Returns a list of the capacity plans that are in the - parent parameter and match your specified filters. (The - maximum list length is limited by the pageSize - parameter.) - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import capacityplanner_v1beta - - async def sample_query_capacity_plans(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceAsyncClient() - - # Initialize request argument(s) - request = capacityplanner_v1beta.QueryCapacityPlansRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.query_capacity_plans(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansRequest, dict]]): - The request object. Request for querying capacity plans. - parent (:class:`str`): - Required. The parent resource - container. Format: - - projects/{project} or - folders/{folder} or - organizations/{organization} - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.capacityplanner_v1beta.services.capacity_planning_service.pagers.QueryCapacityPlansAsyncPager: - Response of querying capacity plans. - - 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. - flattened_params = [parent] - has_flattened_params = ( - len([param for param in flattened_params if param is not None]) > 0 - ) - 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." - ) - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, capacity_planning_service.QueryCapacityPlansRequest): - request = capacity_planning_service.QueryCapacityPlansRequest(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._client._transport._wrapped_methods[ - self._client._transport.query_capacity_plans - ] - - # 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),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.QueryCapacityPlansAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def query_capacity_plan_insights( - self, - request: Optional[ - Union[capacity_planning_service.QueryCapacityPlanInsightsRequest, dict] - ] = None, - *, - parent: Optional[str] = None, - capacity_plan_filters: Optional[ - capacity_planning_service.CapacityPlanFilters - ] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> capacity_planning_service.QueryCapacityPlanInsightsResponse: - r"""Query capacity plan insights that are in the parent - parameter and match your specified filters. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import capacityplanner_v1beta - - async def sample_query_capacity_plan_insights(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceAsyncClient() - - # Initialize request argument(s) - capacity_plan_filters = capacityplanner_v1beta.CapacityPlanFilters() - capacity_plan_filters.keys.resource_container.id = "id_value" - capacity_plan_filters.keys.resource_id_key.resource_code = "resource_code_value" - capacity_plan_filters.keys.location_id.source = "source_value" - capacity_plan_filters.capacity_types = ['CAPACITY_TYPE_INORGANIC_APPROVED'] - - request = capacityplanner_v1beta.QueryCapacityPlanInsightsRequest( - parent="parent_value", - capacity_plan_filters=capacity_plan_filters, - ) - - # Make the request - response = await client.query_capacity_plan_insights(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.capacityplanner_v1beta.types.QueryCapacityPlanInsightsRequest, dict]]): - The request object. Request for capacity plan insights. - parent (:class:`str`): - Required. The parent resource - container. Format: projects/{project} - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - capacity_plan_filters (:class:`google.cloud.capacityplanner_v1beta.types.CapacityPlanFilters`): - Required. The filters to apply to the - capacity plan. - - This corresponds to the ``capacity_plan_filters`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.capacityplanner_v1beta.types.QueryCapacityPlanInsightsResponse: - Response for capacity plan insights. - """ - # 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. - flattened_params = [parent, capacity_plan_filters] - has_flattened_params = ( - len([param for param in flattened_params if param is not None]) > 0 - ) - 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." - ) - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance( - request, capacity_planning_service.QueryCapacityPlanInsightsRequest - ): - request = capacity_planning_service.QueryCapacityPlanInsightsRequest( - request - ) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if capacity_plan_filters is not None: - request.capacity_plan_filters = capacity_plan_filters - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[ - self._client._transport.query_capacity_plan_insights - ] - - # 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),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def __aenter__(self) -> "CapacityPlanningServiceAsyncClient": - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=package_version.__version__ -) - -if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER - DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ - - -__all__ = ("CapacityPlanningServiceAsyncClient",) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/client.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/client.py deleted file mode 100644 index d22da6586f53..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/client.py +++ /dev/null @@ -1,1123 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 http import HTTPStatus -import json -import logging as std_logging -import os -import re -from typing import ( - Callable, - Dict, - Mapping, - MutableMapping, - MutableSequence, - Optional, - Sequence, - Tuple, - Type, - Union, - cast, -) -import warnings - -from google.api_core import client_options as client_options_lib -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.oauth2 import service_account # type: ignore -import google.protobuf - -from google.cloud.capacityplanner_v1beta import gapic_version as package_version - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - -try: - from google.api_core import client_logging # type: ignore - - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - -from google.protobuf import timestamp_pb2 # type: ignore - -from google.cloud.capacityplanner_v1beta.services.capacity_planning_service import ( - pagers, -) -from google.cloud.capacityplanner_v1beta.types import capacity_planning_service - -from .transports.base import DEFAULT_CLIENT_INFO, CapacityPlanningServiceTransport -from .transports.grpc import CapacityPlanningServiceGrpcTransport -from .transports.grpc_asyncio import CapacityPlanningServiceGrpcAsyncIOTransport -from .transports.rest import CapacityPlanningServiceRestTransport - - -class CapacityPlanningServiceClientMeta(type): - """Metaclass for the CapacityPlanningService 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[CapacityPlanningServiceTransport]] - _transport_registry["grpc"] = CapacityPlanningServiceGrpcTransport - _transport_registry["grpc_asyncio"] = CapacityPlanningServiceGrpcAsyncIOTransport - _transport_registry["rest"] = CapacityPlanningServiceRestTransport - - def get_transport_class( - cls, - label: Optional[str] = None, - ) -> Type[CapacityPlanningServiceTransport]: - """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 CapacityPlanningServiceClient(metaclass=CapacityPlanningServiceClientMeta): - """This API allows users to plan for GCP capacity associated - with their projects. Users can request additional capacity for - GCP resources such as VMs, PDs, etc. - """ - - @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") - - # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. - DEFAULT_ENDPOINT = "capacityplanner.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - _DEFAULT_ENDPOINT_TEMPLATE = "capacityplanner.{UNIVERSE_DOMAIN}" - _DEFAULT_UNIVERSE = "googleapis.com" - - @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: - CapacityPlanningServiceClient: 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: - CapacityPlanningServiceClient: 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) -> CapacityPlanningServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CapacityPlanningServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def capacity_plan_path( - project: str, - capacity_plan: str, - ) -> str: - """Returns a fully-qualified capacity_plan string.""" - return "projects/{project}/capacityPlans/{capacity_plan}".format( - project=project, - capacity_plan=capacity_plan, - ) - - @staticmethod - def parse_capacity_plan_path(path: str) -> Dict[str, str]: - """Parses a capacity_plan path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/capacityPlans/(?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 - ): - """Deprecated. 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 variable 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. - """ - - warnings.warn( - "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.", - DeprecationWarning, - ) - 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 - - @staticmethod - def _read_environment_variables(): - """Returns the environment variables used by the client. - - Returns: - Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE, - GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. - - Raises: - ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not - any of ["true", "false"]. - google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT - is not any of ["auto", "never", "always"]. - """ - use_client_cert = os.getenv( - "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false" - ).lower() - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower() - universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") - 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`" - ) - return use_client_cert == "true", use_mtls_endpoint, universe_domain_env - - @staticmethod - def _get_client_cert_source(provided_cert_source, use_cert_flag): - """Return the client cert source to be used by the client. - - Args: - provided_cert_source (bytes): The client certificate source provided. - use_cert_flag (bool): A flag indicating whether to use the client certificate. - - Returns: - bytes or None: The client cert source to be used by the client. - """ - client_cert_source = None - if use_cert_flag: - if provided_cert_source: - client_cert_source = provided_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - return client_cert_source - - @staticmethod - def _get_api_endpoint( - api_override, client_cert_source, universe_domain, use_mtls_endpoint - ): - """Return the API endpoint used by the client. - - Args: - api_override (str): The API endpoint override. If specified, this is always - the return value of this function and the other arguments are not used. - client_cert_source (bytes): The client certificate source used by the client. - universe_domain (str): The universe domain used by the client. - use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters. - Possible values are "always", "auto", or "never". - - Returns: - str: The API endpoint to be used by the client. - """ - if api_override is not None: - api_endpoint = api_override - elif use_mtls_endpoint == "always" or ( - use_mtls_endpoint == "auto" and client_cert_source - ): - _default_universe = CapacityPlanningServiceClient._DEFAULT_UNIVERSE - if universe_domain != _default_universe: - raise MutualTLSChannelError( - f"mTLS is not supported in any universe other than {_default_universe}." - ) - api_endpoint = CapacityPlanningServiceClient.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = ( - CapacityPlanningServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format( - UNIVERSE_DOMAIN=universe_domain - ) - ) - return api_endpoint - - @staticmethod - def _get_universe_domain( - client_universe_domain: Optional[str], universe_domain_env: Optional[str] - ) -> str: - """Return the universe domain used by the client. - - Args: - client_universe_domain (Optional[str]): The universe domain configured via the client options. - universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable. - - Returns: - str: The universe domain to be used by the client. - - Raises: - ValueError: If the universe domain is an empty string. - """ - universe_domain = CapacityPlanningServiceClient._DEFAULT_UNIVERSE - if client_universe_domain is not None: - universe_domain = client_universe_domain - elif universe_domain_env is not None: - universe_domain = universe_domain_env - if len(universe_domain.strip()) == 0: - raise ValueError("Universe Domain cannot be an empty string.") - return universe_domain - - def _validate_universe_domain(self): - """Validates client's and credentials' universe domains are consistent. - - Returns: - bool: True iff the configured universe domain is valid. - - Raises: - ValueError: If the configured universe domain is not valid. - """ - - # NOTE (b/349488459): universe validation is disabled until further notice. - return True - - def _add_cred_info_for_auth_errors( - self, error: core_exceptions.GoogleAPICallError - ) -> None: - """Adds credential info string to error details for 401/403/404 errors. - - Args: - error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info. - """ - if error.code not in [ - HTTPStatus.UNAUTHORIZED, - HTTPStatus.FORBIDDEN, - HTTPStatus.NOT_FOUND, - ]: - return - - cred = self._transport._credentials - - # get_cred_info is only available in google-auth>=2.35.0 - if not hasattr(cred, "get_cred_info"): - return - - # ignore the type check since pypy test fails when get_cred_info - # is not available - cred_info = cred.get_cred_info() # type: ignore - if cred_info and hasattr(error._details, "append"): - error._details.append(json.dumps(cred_info)) - - @property - def api_endpoint(self): - """Return the API endpoint used by the client instance. - - Returns: - str: The API endpoint used by the client instance. - """ - return self._api_endpoint - - @property - def universe_domain(self) -> str: - """Return the universe domain used by the client instance. - - Returns: - str: The universe domain used by the client instance. - """ - return self._universe_domain - - def __init__( - self, - *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[ - Union[ - str, - CapacityPlanningServiceTransport, - Callable[..., CapacityPlanningServiceTransport], - ] - ] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the capacity planning 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 (Optional[Union[str,CapacityPlanningServiceTransport,Callable[..., CapacityPlanningServiceTransport]]]): - The transport to use, or a Callable that constructs and returns a new transport. - If a Callable is given, it will be called with the same set of initialization - arguments as used in the CapacityPlanningServiceTransport constructor. - If set to None, a transport is chosen automatically. - client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): - Custom options for the client. - - 1. The ``api_endpoint`` property can be used to override the - default endpoint provided by the client when ``transport`` is - not explicitly provided. Only if this property is not set and - ``transport`` was not explicitly provided, the endpoint is - determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment - variable, which have one of the following values: - "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). - - 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide a client certificate for mTLS 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. - - 3. The ``universe_domain`` property can be used to override the - default "googleapis.com" universe. Note that the ``api_endpoint`` - property still takes precedence; and ``universe_domain`` is - currently not supported for mTLS. - - 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. - """ - self._client_options = client_options - if isinstance(self._client_options, dict): - self._client_options = client_options_lib.from_dict(self._client_options) - if self._client_options is None: - self._client_options = client_options_lib.ClientOptions() - self._client_options = cast( - client_options_lib.ClientOptions, self._client_options - ) - - universe_domain_opt = getattr(self._client_options, "universe_domain", None) - - ( - self._use_client_cert, - self._use_mtls_endpoint, - self._universe_domain_env, - ) = CapacityPlanningServiceClient._read_environment_variables() - self._client_cert_source = ( - CapacityPlanningServiceClient._get_client_cert_source( - self._client_options.client_cert_source, self._use_client_cert - ) - ) - self._universe_domain = CapacityPlanningServiceClient._get_universe_domain( - universe_domain_opt, self._universe_domain_env - ) - self._api_endpoint = None # updated below, depending on `transport` - - # Initialize the universe domain validation. - self._is_universe_domain_valid = False - - if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER - # Setup logging. - client_logging.initialize_logging() - - api_key_value = getattr(self._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. - transport_provided = isinstance(transport, CapacityPlanningServiceTransport) - if transport_provided: - # transport is a CapacityPlanningServiceTransport instance. - if credentials or self._client_options.credentials_file or api_key_value: - raise ValueError( - "When providing a transport instance, " - "provide its credentials directly." - ) - if self._client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = cast(CapacityPlanningServiceTransport, transport) - self._api_endpoint = self._transport.host - - self._api_endpoint = ( - self._api_endpoint - or CapacityPlanningServiceClient._get_api_endpoint( - self._client_options.api_endpoint, - self._client_cert_source, - self._universe_domain, - self._use_mtls_endpoint, - ) - ) - - if not transport_provided: - 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_init: Union[ - Type[CapacityPlanningServiceTransport], - Callable[..., CapacityPlanningServiceTransport], - ] = ( - CapacityPlanningServiceClient.get_transport_class(transport) - if isinstance(transport, str) or transport is None - else cast(Callable[..., CapacityPlanningServiceTransport], transport) - ) - # initialize with the provided callable or the passed in class - self._transport = transport_init( - credentials=credentials, - credentials_file=self._client_options.credentials_file, - host=self._api_endpoint, - scopes=self._client_options.scopes, - client_cert_source_for_mtls=self._client_cert_source, - quota_project_id=self._client_options.quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - api_audience=self._client_options.api_audience, - ) - - if "async" not in str(self._transport): - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - std_logging.DEBUG - ): # pragma: NO COVER - _LOGGER.debug( - "Created client `google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient`.", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "universeDomain": getattr( - self._transport._credentials, "universe_domain", "" - ), - "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", - "credentialsInfo": getattr( - self.transport._credentials, "get_cred_info", lambda: None - )(), - } - if hasattr(self._transport, "_credentials") - else { - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "credentialsType": None, - }, - ) - - def get_capacity_plan( - self, - request: Optional[ - Union[capacity_planning_service.GetCapacityPlanRequest, dict] - ] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> capacity_planning_service.CapacityPlan: - r"""Returns information about the capacity plan. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import capacityplanner_v1beta - - def sample_get_capacity_plan(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceClient() - - # Initialize request argument(s) - request = capacityplanner_v1beta.GetCapacityPlanRequest( - name="name_value", - ) - - # Make the request - response = client.get_capacity_plan(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.capacityplanner_v1beta.types.GetCapacityPlanRequest, dict]): - The request object. Request for getting a capacity plan. - name (str): - Required. The name of the capacity plan to retrieve. - Format: projects/{project}/capacityPlans/{capacity_plan} - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.capacityplanner_v1beta.types.CapacityPlan: - A plan for additional capacity needed - by a Google Cloud Platform project. This - is synonymous with CapacityDemand, - CapacityRequest, and - CapacityDemandRequest. - - """ - # 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. - flattened_params = [name] - has_flattened_params = ( - len([param for param in flattened_params if param is not None]) > 0 - ) - 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." - ) - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, capacity_planning_service.GetCapacityPlanRequest): - request = capacity_planning_service.GetCapacityPlanRequest(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_capacity_plan] - - # 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),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def query_capacity_plans( - self, - request: Optional[ - Union[capacity_planning_service.QueryCapacityPlansRequest, dict] - ] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.QueryCapacityPlansPager: - r"""Returns a list of the capacity plans that are in the - parent parameter and match your specified filters. (The - maximum list length is limited by the pageSize - parameter.) - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import capacityplanner_v1beta - - def sample_query_capacity_plans(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceClient() - - # Initialize request argument(s) - request = capacityplanner_v1beta.QueryCapacityPlansRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.query_capacity_plans(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansRequest, dict]): - The request object. Request for querying capacity plans. - parent (str): - Required. The parent resource - container. Format: - - projects/{project} or - folders/{folder} or - organizations/{organization} - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.capacityplanner_v1beta.services.capacity_planning_service.pagers.QueryCapacityPlansPager: - Response of querying capacity plans. - - 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. - flattened_params = [parent] - has_flattened_params = ( - len([param for param in flattened_params if param is not None]) > 0 - ) - 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." - ) - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, capacity_planning_service.QueryCapacityPlansRequest): - request = capacity_planning_service.QueryCapacityPlansRequest(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.query_capacity_plans] - - # 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),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.QueryCapacityPlansPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def query_capacity_plan_insights( - self, - request: Optional[ - Union[capacity_planning_service.QueryCapacityPlanInsightsRequest, dict] - ] = None, - *, - parent: Optional[str] = None, - capacity_plan_filters: Optional[ - capacity_planning_service.CapacityPlanFilters - ] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> capacity_planning_service.QueryCapacityPlanInsightsResponse: - r"""Query capacity plan insights that are in the parent - parameter and match your specified filters. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import capacityplanner_v1beta - - def sample_query_capacity_plan_insights(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceClient() - - # Initialize request argument(s) - capacity_plan_filters = capacityplanner_v1beta.CapacityPlanFilters() - capacity_plan_filters.keys.resource_container.id = "id_value" - capacity_plan_filters.keys.resource_id_key.resource_code = "resource_code_value" - capacity_plan_filters.keys.location_id.source = "source_value" - capacity_plan_filters.capacity_types = ['CAPACITY_TYPE_INORGANIC_APPROVED'] - - request = capacityplanner_v1beta.QueryCapacityPlanInsightsRequest( - parent="parent_value", - capacity_plan_filters=capacity_plan_filters, - ) - - # Make the request - response = client.query_capacity_plan_insights(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.capacityplanner_v1beta.types.QueryCapacityPlanInsightsRequest, dict]): - The request object. Request for capacity plan insights. - parent (str): - Required. The parent resource - container. Format: projects/{project} - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - capacity_plan_filters (google.cloud.capacityplanner_v1beta.types.CapacityPlanFilters): - Required. The filters to apply to the - capacity plan. - - This corresponds to the ``capacity_plan_filters`` 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.capacityplanner_v1beta.types.QueryCapacityPlanInsightsResponse: - Response for capacity plan insights. - """ - # 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. - flattened_params = [parent, capacity_plan_filters] - has_flattened_params = ( - len([param for param in flattened_params if param is not None]) > 0 - ) - 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." - ) - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance( - request, capacity_planning_service.QueryCapacityPlanInsightsRequest - ): - request = capacity_planning_service.QueryCapacityPlanInsightsRequest( - request - ) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if capacity_plan_filters is not None: - request.capacity_plan_filters = capacity_plan_filters - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[ - self._transport.query_capacity_plan_insights - ] - - # 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),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "CapacityPlanningServiceClient": - 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() - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=package_version.__version__ -) - -if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER - DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ - -__all__ = ("CapacityPlanningServiceClient",) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/pagers.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/pagers.py deleted file mode 100644 index 7889ebe415f8..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/pagers.py +++ /dev/null @@ -1,201 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import ( - Any, - AsyncIterator, - Awaitable, - Callable, - Iterator, - Optional, - Sequence, - Tuple, - Union, -) - -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core import retry_async as retries_async - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] - OptionalAsyncRetry = Union[ - retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None - ] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore - -from google.cloud.capacityplanner_v1beta.types import capacity_planning_service - - -class QueryCapacityPlansPager: - """A pager for iterating through ``query_capacity_plans`` requests. - - This class thinly wraps an initial - :class:`google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansResponse` object, and - provides an ``__iter__`` method to iterate through its - ``capacity_plans`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``QueryCapacityPlans`` requests and continue to iterate - through the ``capacity_plans`` field on the - corresponding responses. - - All the usual :class:`google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansResponse` - 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[..., capacity_planning_service.QueryCapacityPlansResponse], - request: capacity_planning_service.QueryCapacityPlansRequest, - response: capacity_planning_service.QueryCapacityPlansResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = () - ): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansRequest): - The initial request object. - response (google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansResponse): - The initial response object. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = capacity_planning_service.QueryCapacityPlansRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[capacity_planning_service.QueryCapacityPlansResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method( - self._request, - retry=self._retry, - timeout=self._timeout, - metadata=self._metadata, - ) - yield self._response - - def __iter__(self) -> Iterator[capacity_planning_service.CapacityPlan]: - for page in self.pages: - yield from page.capacity_plans - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) - - -class QueryCapacityPlansAsyncPager: - """A pager for iterating through ``query_capacity_plans`` requests. - - This class thinly wraps an initial - :class:`google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``capacity_plans`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``QueryCapacityPlans`` requests and continue to iterate - through the ``capacity_plans`` field on the - corresponding responses. - - All the usual :class:`google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansResponse` - 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[capacity_planning_service.QueryCapacityPlansResponse] - ], - request: capacity_planning_service.QueryCapacityPlansRequest, - response: capacity_planning_service.QueryCapacityPlansResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = () - ): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansRequest): - The initial request object. - response (google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = capacity_planning_service.QueryCapacityPlansRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages( - self, - ) -> AsyncIterator[capacity_planning_service.QueryCapacityPlansResponse]: - 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, - retry=self._retry, - timeout=self._timeout, - metadata=self._metadata, - ) - yield self._response - - def __aiter__(self) -> AsyncIterator[capacity_planning_service.CapacityPlan]: - async def async_generator(): - async for page in self.pages: - for response in page.capacity_plans: - yield response - - return async_generator() - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/README.rst b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/README.rst deleted file mode 100644 index d6a2b4adfa81..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/README.rst +++ /dev/null @@ -1,9 +0,0 @@ - -transport inheritance structure -_______________________________ - -`CapacityPlanningServiceTransport` is the ABC for all transports. -- public child `CapacityPlanningServiceGrpcTransport` for sync gRPC transport (defined in `grpc.py`). -- public child `CapacityPlanningServiceGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`). -- private child `_BaseCapacityPlanningServiceRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`). -- public child `CapacityPlanningServiceRestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`). diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/__init__.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/__init__.py deleted file mode 100644 index d7557d570e2e..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 CapacityPlanningServiceTransport -from .grpc import CapacityPlanningServiceGrpcTransport -from .grpc_asyncio import CapacityPlanningServiceGrpcAsyncIOTransport -from .rest import ( - CapacityPlanningServiceRestInterceptor, - CapacityPlanningServiceRestTransport, -) - -# Compile a registry of transports. -_transport_registry = ( - OrderedDict() -) # type: Dict[str, Type[CapacityPlanningServiceTransport]] -_transport_registry["grpc"] = CapacityPlanningServiceGrpcTransport -_transport_registry["grpc_asyncio"] = CapacityPlanningServiceGrpcAsyncIOTransport -_transport_registry["rest"] = CapacityPlanningServiceRestTransport - -__all__ = ( - "CapacityPlanningServiceTransport", - "CapacityPlanningServiceGrpcTransport", - "CapacityPlanningServiceGrpcAsyncIOTransport", - "CapacityPlanningServiceRestTransport", - "CapacityPlanningServiceRestInterceptor", -) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/base.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/base.py deleted file mode 100644 index 981b77840e99..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/base.py +++ /dev/null @@ -1,238 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union - -import google.api_core -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore -import google.protobuf - -from google.cloud.capacityplanner_v1beta import gapic_version as package_version -from google.cloud.capacityplanner_v1beta.types import capacity_planning_service - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=package_version.__version__ -) - -if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER - DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ - - -class CapacityPlanningServiceTransport(abc.ABC): - """Abstract transport class for CapacityPlanningService.""" - - AUTH_SCOPES = ( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/devstorage.full_control", - ) - - DEFAULT_HOST: str = "capacityplanner.googleapis.com" - - def __init__( - self, - *, - host: str = DEFAULT_HOST, - credentials: Optional[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 (default: 'capacityplanner.googleapis.com'). - 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 not hasattr(self, "_ignore_credentials"): - self._ignore_credentials: bool = False - - # 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 and not self._ignore_credentials: - 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 - - @property - def host(self): - return self._host - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.get_capacity_plan: gapic_v1.method.wrap_method( - self.get_capacity_plan, - default_retry=retries.Retry( - initial=1.0, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.InternalServerError, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.query_capacity_plans: gapic_v1.method.wrap_method( - self.query_capacity_plans, - default_retry=retries.Retry( - initial=1.0, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.InternalServerError, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.query_capacity_plan_insights: gapic_v1.method.wrap_method( - self.query_capacity_plan_insights, - default_retry=retries.Retry( - initial=1.0, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.InternalServerError, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.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 get_capacity_plan( - self, - ) -> Callable[ - [capacity_planning_service.GetCapacityPlanRequest], - Union[ - capacity_planning_service.CapacityPlan, - Awaitable[capacity_planning_service.CapacityPlan], - ], - ]: - raise NotImplementedError() - - @property - def query_capacity_plans( - self, - ) -> Callable[ - [capacity_planning_service.QueryCapacityPlansRequest], - Union[ - capacity_planning_service.QueryCapacityPlansResponse, - Awaitable[capacity_planning_service.QueryCapacityPlansResponse], - ], - ]: - raise NotImplementedError() - - @property - def query_capacity_plan_insights( - self, - ) -> Callable[ - [capacity_planning_service.QueryCapacityPlanInsightsRequest], - Union[ - capacity_planning_service.QueryCapacityPlanInsightsResponse, - Awaitable[capacity_planning_service.QueryCapacityPlanInsightsResponse], - ], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ("CapacityPlanningServiceTransport",) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/grpc.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/grpc.py deleted file mode 100644 index 9bdba4f403eb..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/grpc.py +++ /dev/null @@ -1,425 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 json -import logging as std_logging -import pickle -from typing import Callable, Dict, Optional, Sequence, Tuple, Union -import warnings - -from google.api_core import gapic_v1, grpc_helpers -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.protobuf.json_format import MessageToJson -import google.protobuf.message -import grpc # type: ignore -import proto # type: ignore - -from google.cloud.capacityplanner_v1beta.types import capacity_planning_service - -from .base import DEFAULT_CLIENT_INFO, CapacityPlanningServiceTransport - -try: - from google.api_core import client_logging # type: ignore - - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - - -class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER - def intercept_unary_unary(self, continuation, client_call_details, request): - logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - std_logging.DEBUG - ) - if logging_enabled: # pragma: NO COVER - request_metadata = client_call_details.metadata - if isinstance(request, proto.Message): - request_payload = type(request).to_json(request) - elif isinstance(request, google.protobuf.message.Message): - request_payload = MessageToJson(request) - else: - request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" - - request_metadata = { - key: value.decode("utf-8") if isinstance(value, bytes) else value - for key, value in request_metadata - } - grpc_request = { - "payload": request_payload, - "requestMethod": "grpc", - "metadata": dict(request_metadata), - } - _LOGGER.debug( - f"Sending request for {client_call_details.method}", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": str(client_call_details.method), - "request": grpc_request, - "metadata": grpc_request["metadata"], - }, - ) - response = continuation(client_call_details, request) - if logging_enabled: # pragma: NO COVER - response_metadata = response.trailing_metadata() - # Convert gRPC metadata `` to list of tuples - metadata = ( - dict([(k, str(v)) for k, v in response_metadata]) - if response_metadata - else None - ) - result = response.result() - if isinstance(result, proto.Message): - response_payload = type(result).to_json(result) - elif isinstance(result, google.protobuf.message.Message): - response_payload = MessageToJson(result) - else: - response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" - grpc_response = { - "payload": response_payload, - "metadata": metadata, - "status": "OK", - } - _LOGGER.debug( - f"Received response for {client_call_details.method}.", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": client_call_details.method, - "response": grpc_response, - "metadata": grpc_response["metadata"], - }, - ) - return response - - -class CapacityPlanningServiceGrpcTransport(CapacityPlanningServiceTransport): - """gRPC backend transport for CapacityPlanningService. - - This API allows users to plan for GCP capacity associated - with their projects. Users can request additional capacity for - GCP resources such as VMs, PDs, etc. - - 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 = "capacityplanner.googleapis.com", - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[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 (default: 'capacityplanner.googleapis.com'). - 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 a ``channel`` instance 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 a ``channel`` instance is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if a ``channel`` instance is provided. - channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]): - A ``Channel`` instance through which to make calls, or a Callable - that constructs and returns one. If set to None, ``self.create_channel`` - is used to create the channel. If a Callable is given, it will be called - with the same arguments as used in ``self.create_channel``. - 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 a ``channel`` instance 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 a ``channel`` instance 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 isinstance(channel, grpc.Channel): - # Ignore credentials if a channel was passed. - credentials = None - self._ignore_credentials = True - # 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: - # initialize with the provided callable or the default channel - channel_init = channel or type(self).create_channel - self._grpc_channel = channel_init( - 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), - ], - ) - - self._interceptor = _LoggingClientInterceptor() - self._logged_channel = grpc.intercept_channel( - self._grpc_channel, self._interceptor - ) - - # Wrap messages. This must be done after self._logged_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel( - cls, - host: str = "capacityplanner.googleapis.com", - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[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 get_capacity_plan( - self, - ) -> Callable[ - [capacity_planning_service.GetCapacityPlanRequest], - capacity_planning_service.CapacityPlan, - ]: - r"""Return a callable for the get capacity plan method over gRPC. - - Returns information about the capacity plan. - - Returns: - Callable[[~.GetCapacityPlanRequest], - ~.CapacityPlan]: - 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_capacity_plan" not in self._stubs: - self._stubs["get_capacity_plan"] = self._logged_channel.unary_unary( - "/google.cloud.capacityplanner.v1beta.CapacityPlanningService/GetCapacityPlan", - request_serializer=capacity_planning_service.GetCapacityPlanRequest.serialize, - response_deserializer=capacity_planning_service.CapacityPlan.deserialize, - ) - return self._stubs["get_capacity_plan"] - - @property - def query_capacity_plans( - self, - ) -> Callable[ - [capacity_planning_service.QueryCapacityPlansRequest], - capacity_planning_service.QueryCapacityPlansResponse, - ]: - r"""Return a callable for the query capacity plans method over gRPC. - - Returns a list of the capacity plans that are in the - parent parameter and match your specified filters. (The - maximum list length is limited by the pageSize - parameter.) - - Returns: - Callable[[~.QueryCapacityPlansRequest], - ~.QueryCapacityPlansResponse]: - 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 "query_capacity_plans" not in self._stubs: - self._stubs["query_capacity_plans"] = self._logged_channel.unary_unary( - "/google.cloud.capacityplanner.v1beta.CapacityPlanningService/QueryCapacityPlans", - request_serializer=capacity_planning_service.QueryCapacityPlansRequest.serialize, - response_deserializer=capacity_planning_service.QueryCapacityPlansResponse.deserialize, - ) - return self._stubs["query_capacity_plans"] - - @property - def query_capacity_plan_insights( - self, - ) -> Callable[ - [capacity_planning_service.QueryCapacityPlanInsightsRequest], - capacity_planning_service.QueryCapacityPlanInsightsResponse, - ]: - r"""Return a callable for the query capacity plan insights method over gRPC. - - Query capacity plan insights that are in the parent - parameter and match your specified filters. - - Returns: - Callable[[~.QueryCapacityPlanInsightsRequest], - ~.QueryCapacityPlanInsightsResponse]: - 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 "query_capacity_plan_insights" not in self._stubs: - self._stubs[ - "query_capacity_plan_insights" - ] = self._logged_channel.unary_unary( - "/google.cloud.capacityplanner.v1beta.CapacityPlanningService/QueryCapacityPlanInsights", - request_serializer=capacity_planning_service.QueryCapacityPlanInsightsRequest.serialize, - response_deserializer=capacity_planning_service.QueryCapacityPlanInsightsResponse.deserialize, - ) - return self._stubs["query_capacity_plan_insights"] - - def close(self): - self._logged_channel.close() - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ("CapacityPlanningServiceGrpcTransport",) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/grpc_asyncio.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/grpc_asyncio.py deleted file mode 100644 index 24f26775d2ff..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,491 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 inspect -import json -import logging as std_logging -import pickle -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -import warnings - -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1, grpc_helpers_async -from google.api_core import retry_async as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.protobuf.json_format import MessageToJson -import google.protobuf.message -import grpc # type: ignore -from grpc.experimental import aio # type: ignore -import proto # type: ignore - -from google.cloud.capacityplanner_v1beta.types import capacity_planning_service - -from .base import DEFAULT_CLIENT_INFO, CapacityPlanningServiceTransport -from .grpc import CapacityPlanningServiceGrpcTransport - -try: - from google.api_core import client_logging # type: ignore - - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - - -class _LoggingClientAIOInterceptor( - grpc.aio.UnaryUnaryClientInterceptor -): # pragma: NO COVER - async def intercept_unary_unary(self, continuation, client_call_details, request): - logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - std_logging.DEBUG - ) - if logging_enabled: # pragma: NO COVER - request_metadata = client_call_details.metadata - if isinstance(request, proto.Message): - request_payload = type(request).to_json(request) - elif isinstance(request, google.protobuf.message.Message): - request_payload = MessageToJson(request) - else: - request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" - - request_metadata = { - key: value.decode("utf-8") if isinstance(value, bytes) else value - for key, value in request_metadata - } - grpc_request = { - "payload": request_payload, - "requestMethod": "grpc", - "metadata": dict(request_metadata), - } - _LOGGER.debug( - f"Sending request for {client_call_details.method}", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": str(client_call_details.method), - "request": grpc_request, - "metadata": grpc_request["metadata"], - }, - ) - response = await continuation(client_call_details, request) - if logging_enabled: # pragma: NO COVER - response_metadata = await response.trailing_metadata() - # Convert gRPC metadata `` to list of tuples - metadata = ( - dict([(k, str(v)) for k, v in response_metadata]) - if response_metadata - else None - ) - result = await response - if isinstance(result, proto.Message): - response_payload = type(result).to_json(result) - elif isinstance(result, google.protobuf.message.Message): - response_payload = MessageToJson(result) - else: - response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" - grpc_response = { - "payload": response_payload, - "metadata": metadata, - "status": "OK", - } - _LOGGER.debug( - f"Received response to rpc {client_call_details.method}.", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": str(client_call_details.method), - "response": grpc_response, - "metadata": grpc_response["metadata"], - }, - ) - return response - - -class CapacityPlanningServiceGrpcAsyncIOTransport(CapacityPlanningServiceTransport): - """gRPC AsyncIO backend transport for CapacityPlanningService. - - This API allows users to plan for GCP capacity associated - with their projects. Users can request additional capacity for - GCP resources such as VMs, PDs, etc. - - 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 = "capacityplanner.googleapis.com", - credentials: Optional[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`. - 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 = "capacityplanner.googleapis.com", - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[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 (default: 'capacityplanner.googleapis.com'). - 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 a ``channel`` instance 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 a ``channel`` instance 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[Union[aio.Channel, Callable[..., aio.Channel]]]): - A ``Channel`` instance through which to make calls, or a Callable - that constructs and returns one. If set to None, ``self.create_channel`` - is used to create the channel. If a Callable is given, it will be called - with the same arguments as used in ``self.create_channel``. - 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 a ``channel`` instance 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 a ``channel`` instance 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 isinstance(channel, aio.Channel): - # Ignore credentials if a channel was passed. - credentials = None - self._ignore_credentials = True - # 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: - # initialize with the provided callable or the default channel - channel_init = channel or type(self).create_channel - self._grpc_channel = channel_init( - 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), - ], - ) - - self._interceptor = _LoggingClientAIOInterceptor() - self._grpc_channel._unary_unary_interceptors.append(self._interceptor) - self._logged_channel = self._grpc_channel - self._wrap_with_kind = ( - "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters - ) - # Wrap messages. This must be done after self._logged_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 get_capacity_plan( - self, - ) -> Callable[ - [capacity_planning_service.GetCapacityPlanRequest], - Awaitable[capacity_planning_service.CapacityPlan], - ]: - r"""Return a callable for the get capacity plan method over gRPC. - - Returns information about the capacity plan. - - Returns: - Callable[[~.GetCapacityPlanRequest], - Awaitable[~.CapacityPlan]]: - 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_capacity_plan" not in self._stubs: - self._stubs["get_capacity_plan"] = self._logged_channel.unary_unary( - "/google.cloud.capacityplanner.v1beta.CapacityPlanningService/GetCapacityPlan", - request_serializer=capacity_planning_service.GetCapacityPlanRequest.serialize, - response_deserializer=capacity_planning_service.CapacityPlan.deserialize, - ) - return self._stubs["get_capacity_plan"] - - @property - def query_capacity_plans( - self, - ) -> Callable[ - [capacity_planning_service.QueryCapacityPlansRequest], - Awaitable[capacity_planning_service.QueryCapacityPlansResponse], - ]: - r"""Return a callable for the query capacity plans method over gRPC. - - Returns a list of the capacity plans that are in the - parent parameter and match your specified filters. (The - maximum list length is limited by the pageSize - parameter.) - - Returns: - Callable[[~.QueryCapacityPlansRequest], - Awaitable[~.QueryCapacityPlansResponse]]: - 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 "query_capacity_plans" not in self._stubs: - self._stubs["query_capacity_plans"] = self._logged_channel.unary_unary( - "/google.cloud.capacityplanner.v1beta.CapacityPlanningService/QueryCapacityPlans", - request_serializer=capacity_planning_service.QueryCapacityPlansRequest.serialize, - response_deserializer=capacity_planning_service.QueryCapacityPlansResponse.deserialize, - ) - return self._stubs["query_capacity_plans"] - - @property - def query_capacity_plan_insights( - self, - ) -> Callable[ - [capacity_planning_service.QueryCapacityPlanInsightsRequest], - Awaitable[capacity_planning_service.QueryCapacityPlanInsightsResponse], - ]: - r"""Return a callable for the query capacity plan insights method over gRPC. - - Query capacity plan insights that are in the parent - parameter and match your specified filters. - - Returns: - Callable[[~.QueryCapacityPlanInsightsRequest], - Awaitable[~.QueryCapacityPlanInsightsResponse]]: - 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 "query_capacity_plan_insights" not in self._stubs: - self._stubs[ - "query_capacity_plan_insights" - ] = self._logged_channel.unary_unary( - "/google.cloud.capacityplanner.v1beta.CapacityPlanningService/QueryCapacityPlanInsights", - request_serializer=capacity_planning_service.QueryCapacityPlanInsightsRequest.serialize, - response_deserializer=capacity_planning_service.QueryCapacityPlanInsightsResponse.deserialize, - ) - return self._stubs["query_capacity_plan_insights"] - - def _prep_wrapped_messages(self, client_info): - """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" - self._wrapped_methods = { - self.get_capacity_plan: self._wrap_method( - self.get_capacity_plan, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.InternalServerError, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.query_capacity_plans: self._wrap_method( - self.query_capacity_plans, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.InternalServerError, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.query_capacity_plan_insights: self._wrap_method( - self.query_capacity_plan_insights, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.InternalServerError, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - } - - def _wrap_method(self, func, *args, **kwargs): - if self._wrap_with_kind: # pragma: NO COVER - kwargs["kind"] = self.kind - return gapic_v1.method_async.wrap_method(func, *args, **kwargs) - - def close(self): - return self._logged_channel.close() - - @property - def kind(self) -> str: - return "grpc_asyncio" - - -__all__ = ("CapacityPlanningServiceGrpcAsyncIOTransport",) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/rest.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/rest.py deleted file mode 100644 index 15b6043ec66e..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/rest.py +++ /dev/null @@ -1,859 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 dataclasses -import json # type: ignore -import logging -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -import warnings - -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1, rest_helpers, rest_streaming -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.requests import AuthorizedSession # type: ignore -import google.protobuf -from google.protobuf import json_format -from requests import __version__ as requests_version - -from google.cloud.capacityplanner_v1beta.types import capacity_planning_service - -from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO -from .rest_base import _BaseCapacityPlanningServiceRestTransport - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - -try: - from google.api_core import client_logging # type: ignore - - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = logging.getLogger(__name__) - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, - grpc_version=None, - rest_version=f"requests@{requests_version}", -) - -if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER - DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ - - -class CapacityPlanningServiceRestInterceptor: - """Interceptor for CapacityPlanningService. - - Interceptors are used to manipulate requests, request metadata, and responses - in arbitrary ways. - Example use cases include: - * Logging - * Verifying requests according to service or custom semantics - * Stripping extraneous information from responses - - These use cases and more can be enabled by injecting an - instance of a custom subclass when constructing the CapacityPlanningServiceRestTransport. - - .. code-block:: python - class MyCustomCapacityPlanningServiceInterceptor(CapacityPlanningServiceRestInterceptor): - def pre_get_capacity_plan(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_capacity_plan(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_query_capacity_plan_insights(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_query_capacity_plan_insights(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_query_capacity_plans(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_query_capacity_plans(self, response): - logging.log(f"Received response: {response}") - return response - - transport = CapacityPlanningServiceRestTransport(interceptor=MyCustomCapacityPlanningServiceInterceptor()) - client = CapacityPlanningServiceClient(transport=transport) - - - """ - - def pre_get_capacity_plan( - self, - request: capacity_planning_service.GetCapacityPlanRequest, - metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - capacity_planning_service.GetCapacityPlanRequest, - Sequence[Tuple[str, Union[str, bytes]]], - ]: - """Pre-rpc interceptor for get_capacity_plan - - Override in a subclass to manipulate the request or metadata - before they are sent to the CapacityPlanningService server. - """ - return request, metadata - - def post_get_capacity_plan( - self, response: capacity_planning_service.CapacityPlan - ) -> capacity_planning_service.CapacityPlan: - """Post-rpc interceptor for get_capacity_plan - - DEPRECATED. Please use the `post_get_capacity_plan_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the CapacityPlanningService server but before - it is returned to user code. This `post_get_capacity_plan` interceptor runs - before the `post_get_capacity_plan_with_metadata` interceptor. - """ - return response - - def post_get_capacity_plan_with_metadata( - self, - response: capacity_planning_service.CapacityPlan, - metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - capacity_planning_service.CapacityPlan, Sequence[Tuple[str, Union[str, bytes]]] - ]: - """Post-rpc interceptor for get_capacity_plan - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the CapacityPlanningService server but before it is returned to user code. - - We recommend only using this `post_get_capacity_plan_with_metadata` - interceptor in new development instead of the `post_get_capacity_plan` interceptor. - When both interceptors are used, this `post_get_capacity_plan_with_metadata` interceptor runs after the - `post_get_capacity_plan` interceptor. The (possibly modified) response returned by - `post_get_capacity_plan` will be passed to - `post_get_capacity_plan_with_metadata`. - """ - return response, metadata - - def pre_query_capacity_plan_insights( - self, - request: capacity_planning_service.QueryCapacityPlanInsightsRequest, - metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - capacity_planning_service.QueryCapacityPlanInsightsRequest, - Sequence[Tuple[str, Union[str, bytes]]], - ]: - """Pre-rpc interceptor for query_capacity_plan_insights - - Override in a subclass to manipulate the request or metadata - before they are sent to the CapacityPlanningService server. - """ - return request, metadata - - def post_query_capacity_plan_insights( - self, response: capacity_planning_service.QueryCapacityPlanInsightsResponse - ) -> capacity_planning_service.QueryCapacityPlanInsightsResponse: - """Post-rpc interceptor for query_capacity_plan_insights - - DEPRECATED. Please use the `post_query_capacity_plan_insights_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the CapacityPlanningService server but before - it is returned to user code. This `post_query_capacity_plan_insights` interceptor runs - before the `post_query_capacity_plan_insights_with_metadata` interceptor. - """ - return response - - def post_query_capacity_plan_insights_with_metadata( - self, - response: capacity_planning_service.QueryCapacityPlanInsightsResponse, - metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - capacity_planning_service.QueryCapacityPlanInsightsResponse, - Sequence[Tuple[str, Union[str, bytes]]], - ]: - """Post-rpc interceptor for query_capacity_plan_insights - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the CapacityPlanningService server but before it is returned to user code. - - We recommend only using this `post_query_capacity_plan_insights_with_metadata` - interceptor in new development instead of the `post_query_capacity_plan_insights` interceptor. - When both interceptors are used, this `post_query_capacity_plan_insights_with_metadata` interceptor runs after the - `post_query_capacity_plan_insights` interceptor. The (possibly modified) response returned by - `post_query_capacity_plan_insights` will be passed to - `post_query_capacity_plan_insights_with_metadata`. - """ - return response, metadata - - def pre_query_capacity_plans( - self, - request: capacity_planning_service.QueryCapacityPlansRequest, - metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - capacity_planning_service.QueryCapacityPlansRequest, - Sequence[Tuple[str, Union[str, bytes]]], - ]: - """Pre-rpc interceptor for query_capacity_plans - - Override in a subclass to manipulate the request or metadata - before they are sent to the CapacityPlanningService server. - """ - return request, metadata - - def post_query_capacity_plans( - self, response: capacity_planning_service.QueryCapacityPlansResponse - ) -> capacity_planning_service.QueryCapacityPlansResponse: - """Post-rpc interceptor for query_capacity_plans - - DEPRECATED. Please use the `post_query_capacity_plans_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the CapacityPlanningService server but before - it is returned to user code. This `post_query_capacity_plans` interceptor runs - before the `post_query_capacity_plans_with_metadata` interceptor. - """ - return response - - def post_query_capacity_plans_with_metadata( - self, - response: capacity_planning_service.QueryCapacityPlansResponse, - metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - capacity_planning_service.QueryCapacityPlansResponse, - Sequence[Tuple[str, Union[str, bytes]]], - ]: - """Post-rpc interceptor for query_capacity_plans - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the CapacityPlanningService server but before it is returned to user code. - - We recommend only using this `post_query_capacity_plans_with_metadata` - interceptor in new development instead of the `post_query_capacity_plans` interceptor. - When both interceptors are used, this `post_query_capacity_plans_with_metadata` interceptor runs after the - `post_query_capacity_plans` interceptor. The (possibly modified) response returned by - `post_query_capacity_plans` will be passed to - `post_query_capacity_plans_with_metadata`. - """ - return response, metadata - - -@dataclasses.dataclass -class CapacityPlanningServiceRestStub: - _session: AuthorizedSession - _host: str - _interceptor: CapacityPlanningServiceRestInterceptor - - -class CapacityPlanningServiceRestTransport(_BaseCapacityPlanningServiceRestTransport): - """REST backend synchronous transport for CapacityPlanningService. - - This API allows users to plan for GCP capacity associated - with their projects. Users can request additional capacity for - GCP resources such as VMs, PDs, etc. - - 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 JSON representations of protocol buffers over HTTP/1.1 - """ - - def __init__( - self, - *, - host: str = "capacityplanner.googleapis.com", - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - client_cert_source_for_mtls: Optional[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, - url_scheme: str = "https", - interceptor: Optional[CapacityPlanningServiceRestInterceptor] = None, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'capacityplanner.googleapis.com'). - 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 ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client - certificate to configure mutual TLS HTTP channel. It is ignored - if ``channel`` 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 are developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - url_scheme: the protocol scheme for the API endpoint. Normally - "https", but for testing or local servers, - "http" can be specified. - """ - # Run the base constructor - # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. - # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the - # credentials object - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - url_scheme=url_scheme, - api_audience=api_audience, - ) - self._session = AuthorizedSession( - self._credentials, default_host=self.DEFAULT_HOST - ) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or CapacityPlanningServiceRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _GetCapacityPlan( - _BaseCapacityPlanningServiceRestTransport._BaseGetCapacityPlan, - CapacityPlanningServiceRestStub, - ): - def __hash__(self): - return hash("CapacityPlanningServiceRestTransport.GetCapacityPlan") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None, - ): - uri = transcoded_request["uri"] - method = transcoded_request["method"] - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__( - self, - request: capacity_planning_service.GetCapacityPlanRequest, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> capacity_planning_service.CapacityPlan: - r"""Call the get capacity plan method over HTTP. - - Args: - request (~.capacity_planning_service.GetCapacityPlanRequest): - The request object. Request for getting a capacity plan. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.capacity_planning_service.CapacityPlan: - A plan for additional capacity needed - by a Google Cloud Platform project. This - is synonymous with CapacityDemand, - CapacityRequest, and - CapacityDemandRequest. - - """ - - http_options = ( - _BaseCapacityPlanningServiceRestTransport._BaseGetCapacityPlan._get_http_options() - ) - - request, metadata = self._interceptor.pre_get_capacity_plan( - request, metadata - ) - transcoded_request = _BaseCapacityPlanningServiceRestTransport._BaseGetCapacityPlan._get_transcoded_request( - http_options, request - ) - - # Jsonify the query params - query_params = _BaseCapacityPlanningServiceRestTransport._BaseGetCapacityPlan._get_query_params_json( - transcoded_request - ) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - logging.DEBUG - ): # pragma: NO COVER - request_url = "{host}{uri}".format( - host=self._host, uri=transcoded_request["uri"] - ) - method = transcoded_request["method"] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient.GetCapacityPlan", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": "GetCapacityPlan", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = ( - CapacityPlanningServiceRestTransport._GetCapacityPlan._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - ) - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = capacity_planning_service.CapacityPlan() - pb_resp = capacity_planning_service.CapacityPlan.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_capacity_plan(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_capacity_plan_with_metadata( - resp, response_metadata - ) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - logging.DEBUG - ): # pragma: NO COVER - try: - response_payload = capacity_planning_service.CapacityPlan.to_json( - response - ) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient.get_capacity_plan", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": "GetCapacityPlan", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _QueryCapacityPlanInsights( - _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlanInsights, - CapacityPlanningServiceRestStub, - ): - def __hash__(self): - return hash( - "CapacityPlanningServiceRestTransport.QueryCapacityPlanInsights" - ) - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None, - ): - uri = transcoded_request["uri"] - method = transcoded_request["method"] - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__( - self, - request: capacity_planning_service.QueryCapacityPlanInsightsRequest, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> capacity_planning_service.QueryCapacityPlanInsightsResponse: - r"""Call the query capacity plan - insights method over HTTP. - - Args: - request (~.capacity_planning_service.QueryCapacityPlanInsightsRequest): - The request object. Request for capacity plan insights. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.capacity_planning_service.QueryCapacityPlanInsightsResponse: - Response for capacity plan insights. - """ - - http_options = ( - _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlanInsights._get_http_options() - ) - - request, metadata = self._interceptor.pre_query_capacity_plan_insights( - request, metadata - ) - transcoded_request = _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlanInsights._get_transcoded_request( - http_options, request - ) - - body = _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlanInsights._get_request_body_json( - transcoded_request - ) - - # Jsonify the query params - query_params = _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlanInsights._get_query_params_json( - transcoded_request - ) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - logging.DEBUG - ): # pragma: NO COVER - request_url = "{host}{uri}".format( - host=self._host, uri=transcoded_request["uri"] - ) - method = transcoded_request["method"] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient.QueryCapacityPlanInsights", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": "QueryCapacityPlanInsights", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = CapacityPlanningServiceRestTransport._QueryCapacityPlanInsights._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = capacity_planning_service.QueryCapacityPlanInsightsResponse() - pb_resp = capacity_planning_service.QueryCapacityPlanInsightsResponse.pb( - resp - ) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_query_capacity_plan_insights(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_query_capacity_plan_insights_with_metadata( - resp, response_metadata - ) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - logging.DEBUG - ): # pragma: NO COVER - try: - response_payload = capacity_planning_service.QueryCapacityPlanInsightsResponse.to_json( - response - ) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient.query_capacity_plan_insights", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": "QueryCapacityPlanInsights", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _QueryCapacityPlans( - _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlans, - CapacityPlanningServiceRestStub, - ): - def __hash__(self): - return hash("CapacityPlanningServiceRestTransport.QueryCapacityPlans") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None, - ): - uri = transcoded_request["uri"] - method = transcoded_request["method"] - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__( - self, - request: capacity_planning_service.QueryCapacityPlansRequest, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> capacity_planning_service.QueryCapacityPlansResponse: - r"""Call the query capacity plans method over HTTP. - - Args: - request (~.capacity_planning_service.QueryCapacityPlansRequest): - The request object. Request for querying capacity plans. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.capacity_planning_service.QueryCapacityPlansResponse: - Response of querying capacity plans. - """ - - http_options = ( - _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlans._get_http_options() - ) - - request, metadata = self._interceptor.pre_query_capacity_plans( - request, metadata - ) - transcoded_request = _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlans._get_transcoded_request( - http_options, request - ) - - # Jsonify the query params - query_params = _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlans._get_query_params_json( - transcoded_request - ) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - logging.DEBUG - ): # pragma: NO COVER - request_url = "{host}{uri}".format( - host=self._host, uri=transcoded_request["uri"] - ) - method = transcoded_request["method"] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient.QueryCapacityPlans", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": "QueryCapacityPlans", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = ( - CapacityPlanningServiceRestTransport._QueryCapacityPlans._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - ) - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = capacity_planning_service.QueryCapacityPlansResponse() - pb_resp = capacity_planning_service.QueryCapacityPlansResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_query_capacity_plans(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_query_capacity_plans_with_metadata( - resp, response_metadata - ) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( - logging.DEBUG - ): # pragma: NO COVER - try: - response_payload = ( - capacity_planning_service.QueryCapacityPlansResponse.to_json( - response - ) - ) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient.query_capacity_plans", - extra={ - "serviceName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "rpcName": "QueryCapacityPlans", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - @property - def get_capacity_plan( - self, - ) -> Callable[ - [capacity_planning_service.GetCapacityPlanRequest], - capacity_planning_service.CapacityPlan, - ]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetCapacityPlan(self._session, self._host, self._interceptor) # type: ignore - - @property - def query_capacity_plan_insights( - self, - ) -> Callable[ - [capacity_planning_service.QueryCapacityPlanInsightsRequest], - capacity_planning_service.QueryCapacityPlanInsightsResponse, - ]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._QueryCapacityPlanInsights(self._session, self._host, self._interceptor) # type: ignore - - @property - def query_capacity_plans( - self, - ) -> Callable[ - [capacity_planning_service.QueryCapacityPlansRequest], - capacity_planning_service.QueryCapacityPlansResponse, - ]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._QueryCapacityPlans(self._session, self._host, self._interceptor) # type: ignore - - @property - def kind(self) -> str: - return "rest" - - def close(self): - self._session.close() - - -__all__ = ("CapacityPlanningServiceRestTransport",) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/rest_base.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/rest_base.py deleted file mode 100644 index 81b67e41456a..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/capacity_planning_service/transports/rest_base.py +++ /dev/null @@ -1,252 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 json # type: ignore -import re -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1, path_template -from google.protobuf import json_format - -from google.cloud.capacityplanner_v1beta.types import capacity_planning_service - -from .base import DEFAULT_CLIENT_INFO, CapacityPlanningServiceTransport - - -class _BaseCapacityPlanningServiceRestTransport(CapacityPlanningServiceTransport): - """Base REST backend transport for CapacityPlanningService. - - Note: This class is not meant to be used directly. Use its sync and - async sub-classes instead. - - 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 JSON representations of protocol buffers over HTTP/1.1 - """ - - def __init__( - self, - *, - host: str = "capacityplanner.googleapis.com", - credentials: Optional[Any] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - url_scheme: str = "https", - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - Args: - host (Optional[str]): - The hostname to connect to (default: 'capacityplanner.googleapis.com'). - credentials (Optional[Any]): 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. - 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 are developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - url_scheme: the protocol scheme for the API endpoint. Normally - "https", but for testing or local servers, - "http" can be specified. - """ - # Run the base constructor - maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) - if maybe_url_match is None: - raise ValueError( - f"Unexpected hostname structure: {host}" - ) # pragma: NO COVER - - url_match_items = maybe_url_match.groupdict() - - host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host - - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience, - ) - - class _BaseGetCapacityPlan: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return { - k: v - for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() - if k not in message_dict - } - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1beta/{name=projects/*/capacityPlans/*}", - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = capacity_planning_service.GetCapacityPlanRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads( - json_format.MessageToJson( - transcoded_request["query_params"], - use_integers_for_enums=True, - ) - ) - query_params.update( - _BaseCapacityPlanningServiceRestTransport._BaseGetCapacityPlan._get_unset_required_fields( - query_params - ) - ) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseQueryCapacityPlanInsights: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return { - k: v - for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() - if k not in message_dict - } - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [ - { - "method": "post", - "uri": "/v1beta/{parent=projects/*}/capacityPlanInsights:query", - "body": "*", - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = capacity_planning_service.QueryCapacityPlanInsightsRequest.pb( - request - ) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True - ) - return body - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads( - json_format.MessageToJson( - transcoded_request["query_params"], - use_integers_for_enums=True, - ) - ) - query_params.update( - _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlanInsights._get_unset_required_fields( - query_params - ) - ) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseQueryCapacityPlans: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return { - k: v - for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() - if k not in message_dict - } - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1beta/{parent=organizations/*}/capacityPlans:query", - }, - { - "method": "get", - "uri": "/v1beta/{parent=folders/*}/capacityPlans:query", - }, - { - "method": "get", - "uri": "/v1beta/{parent=projects/*}/capacityPlans:query", - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = capacity_planning_service.QueryCapacityPlansRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads( - json_format.MessageToJson( - transcoded_request["query_params"], - use_integers_for_enums=True, - ) - ) - query_params.update( - _BaseCapacityPlanningServiceRestTransport._BaseQueryCapacityPlans._get_unset_required_fields( - query_params - ) - ) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - -__all__ = ("_BaseCapacityPlanningServiceRestTransport",) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/async_client.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/async_client.py index 7d34dfcc6f1e..7f0477d154ac 100644 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/async_client.py +++ b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/async_client.py @@ -316,6 +316,7 @@ async def sample_query_usage_histories(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryUsageHistoriesRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", ) # Make the request @@ -400,6 +401,7 @@ async def sample_query_forecasts(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryForecastsRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", ) # Make the request @@ -485,6 +487,9 @@ async def sample_query_reservations(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryReservationsRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", + reservation_type="RESERVATION_TYPE_ALL", + reservation_data_level="RESERVATION_DATA_LEVEL_PER_RESERVATION", ) # Make the request diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/client.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/client.py index 51d49cec24c2..069283554ecd 100644 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/client.py +++ b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/client.py @@ -760,6 +760,7 @@ def sample_query_usage_histories(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryUsageHistoriesRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", ) # Make the request @@ -842,6 +843,7 @@ def sample_query_forecasts(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryForecastsRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", ) # Make the request @@ -925,6 +927,9 @@ def sample_query_reservations(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryReservationsRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", + reservation_type="RESERVATION_TYPE_ALL", + reservation_data_level="RESERVATION_DATA_LEVEL_PER_RESERVATION", ) # Make the request diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/transports/rest_base.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/transports/rest_base.py index 988c0131e14f..1caf41b57c88 100644 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/transports/rest_base.py +++ b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/services/usage_service/transports/rest_base.py @@ -360,7 +360,11 @@ class _BaseQueryReservations: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "cloudResourceType": "", + "reservationType": {}, + "reservationDataLevel": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/__init__.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/__init__.py index 25d8ef8ba78f..1d75a7a9d3d1 100644 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/__init__.py +++ b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/__init__.py @@ -14,29 +14,6 @@ # limitations under the License. # from .allocation import Allocation -from .capacity_planning_service import ( - CapacityPlan, - CapacityPlanFilters, - CapacityPlanKey, - CapacityPlanView, - CapacityType, - ChildResourceDemand, - DemandMetadata, - DemandPreference, - DemandValue, - DemandValues, - GetCapacityPlanRequest, - QueryCapacityPlanInsightsRequest, - QueryCapacityPlanInsightsResponse, - QueryCapacityPlansRequest, - QueryCapacityPlansResponse, - ResourceDemand, - ServiceDemand, - State, - TimeSeriesView, - TimeValue, - User, -) from .future_reservation import FutureReservation from .location import LocationIdentifier, LocationLevel from .resource import ( @@ -75,27 +52,6 @@ __all__ = ( "Allocation", - "CapacityPlan", - "CapacityPlanFilters", - "CapacityPlanKey", - "CapacityPlanView", - "ChildResourceDemand", - "DemandMetadata", - "DemandPreference", - "DemandValue", - "DemandValues", - "GetCapacityPlanRequest", - "QueryCapacityPlanInsightsRequest", - "QueryCapacityPlanInsightsResponse", - "QueryCapacityPlansRequest", - "QueryCapacityPlansResponse", - "ResourceDemand", - "ServiceDemand", - "TimeSeriesView", - "TimeValue", - "User", - "CapacityType", - "State", "FutureReservation", "LocationIdentifier", "LocationLevel", diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/capacity_planning_service.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/capacity_planning_service.py deleted file mode 100644 index cbd454a6f753..000000000000 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/capacity_planning_service.py +++ /dev/null @@ -1,703 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -from google.protobuf import timestamp_pb2 # type: ignore -import proto # type: ignore - -from google.cloud.capacityplanner_v1beta.types import location as gcc_location -from google.cloud.capacityplanner_v1beta.types import resource - -__protobuf__ = proto.module( - package="google.cloud.capacityplanner.v1beta", - manifest={ - "State", - "CapacityType", - "GetCapacityPlanRequest", - "QueryCapacityPlansRequest", - "QueryCapacityPlansResponse", - "QueryCapacityPlanInsightsRequest", - "QueryCapacityPlanInsightsResponse", - "CapacityPlanFilters", - "CapacityPlanKey", - "CapacityPlanView", - "TimeSeriesView", - "CapacityPlan", - "DemandMetadata", - "DemandPreference", - "ServiceDemand", - "ResourceDemand", - "User", - "DemandValues", - "DemandValue", - "TimeValue", - "ChildResourceDemand", - }, -) - - -class State(proto.Enum): - r"""The state of a capacity demand. - - Values: - STATE_UNSPECIFIED (0): - The state is unspecified. - PENDING_REVIEW (1): - The demand is pending review. - IN_REVIEW (3): - The demand is in review. - APPROVED_PROVISIONAL (8): - The demand is provisionally approved. - OBSOLETE (5): - The demand is obsolete. - CANNOT_BE_FULFILLED (7): - The demand cannot be fulfilled. - ON_HOLD_CONTACT_SALES (9): - The demand is on hold, contact sales. - IN_FULFILLMENT (10): - The demand is in fulfillment. - """ - STATE_UNSPECIFIED = 0 - PENDING_REVIEW = 1 - IN_REVIEW = 3 - APPROVED_PROVISIONAL = 8 - OBSOLETE = 5 - CANNOT_BE_FULFILLED = 7 - ON_HOLD_CONTACT_SALES = 9 - IN_FULFILLMENT = 10 - - -class CapacityType(proto.Enum): - r"""CapacityType is the type of the capacity plan. - - Values: - CAPACITY_TYPE_UNKNOWN (0): - Default value. - CAPACITY_TYPE_INORGANIC_DRAFT (1): - Latest inorganic data stored in horizon DB - that is in draft state. - CAPACITY_TYPE_INORGANIC_PENDING (2): - Latest inorganic data stored in horizon DB - that are pending i.e. submitted or assessment. - CAPACITY_TYPE_INORGANIC_APPROVED (3): - Latest inorganic data stored in horizon DB - that has been approved. - """ - CAPACITY_TYPE_UNKNOWN = 0 - CAPACITY_TYPE_INORGANIC_DRAFT = 1 - CAPACITY_TYPE_INORGANIC_PENDING = 2 - CAPACITY_TYPE_INORGANIC_APPROVED = 3 - - -class GetCapacityPlanRequest(proto.Message): - r"""Request for getting a capacity plan. - - Attributes: - name (str): - Required. The name of the capacity plan to retrieve. Format: - projects/{project}/capacityPlans/{capacity_plan} - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class QueryCapacityPlansRequest(proto.Message): - r"""Request for querying capacity plans. - - Attributes: - parent (str): - Required. The parent resource container. - Format: - - projects/{project} or - folders/{folder} or - organizations/{organization} - page_size (int): - Optional. The maximum number of plans to - return per page. The service may return fewer - than this value. If unspecified, the server will - use a sensible default. The maximum value is - 1000; values above 1000 will be coerced to 1000. - page_token (str): - Optional. A page token, received from a previous - ``QueryCapacityPlans`` call. Provide this to retrieve the - subsequent page. - location (str): - Optional. The Google Cloud Platform location - of capacity plans. If unspecified, all locations - will be included. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - location: str = proto.Field( - proto.STRING, - number=4, - ) - - -class QueryCapacityPlansResponse(proto.Message): - r"""Response of querying capacity plans. - - Attributes: - capacity_plans (MutableSequence[google.cloud.capacityplanner_v1beta.types.CapacityPlan]): - List of capacity plans. - next_page_token (str): - Token to retrieve the next page of results. - This will be empty if there are no more pages. - """ - - @property - def raw_page(self): - return self - - capacity_plans: MutableSequence["CapacityPlan"] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message="CapacityPlan", - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class QueryCapacityPlanInsightsRequest(proto.Message): - r"""Request for capacity plan insights. - - Attributes: - parent (str): - Required. The parent resource container. - Format: projects/{project} - capacity_plan_filters (google.cloud.capacityplanner_v1beta.types.CapacityPlanFilters): - Required. The filters to apply to the - capacity plan. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - capacity_plan_filters: "CapacityPlanFilters" = proto.Field( - proto.MESSAGE, - number=2, - message="CapacityPlanFilters", - ) - - -class QueryCapacityPlanInsightsResponse(proto.Message): - r"""Response for capacity plan insights. - - Attributes: - aggregated_capacity_plan_view (google.cloud.capacityplanner_v1beta.types.CapacityPlanView): - Optional. The aggregated capacity plan view. - This is the aggregated view of all the capacity - plans that match the filters. - """ - - aggregated_capacity_plan_view: "CapacityPlanView" = proto.Field( - proto.MESSAGE, - number=1, - message="CapacityPlanView", - ) - - -class CapacityPlanFilters(proto.Message): - r"""CapacityPlanFilters is a set of filters to apply to the - capacity plan. - - Attributes: - keys (MutableSequence[google.cloud.capacityplanner_v1beta.types.CapacityPlanKey]): - Required. The capacity plan keys to include - in the response. - capacity_types (MutableSequence[google.cloud.capacityplanner_v1beta.types.CapacityType]): - Required. The capacity types to include in - the response. - capacity_plan_id (str): - Optional. Optional capacity plan id. Should - be populated for request page to lock based on - the same capacity plan. - """ - - keys: MutableSequence["CapacityPlanKey"] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message="CapacityPlanKey", - ) - capacity_types: MutableSequence["CapacityType"] = proto.RepeatedField( - proto.ENUM, - number=2, - enum="CapacityType", - ) - capacity_plan_id: str = proto.Field( - proto.STRING, - number=3, - ) - - -class CapacityPlanKey(proto.Message): - r"""CapacityPlanKey is a the unique identifier for each Capacity - Plan. - - Attributes: - resource_container (google.cloud.capacityplanner_v1beta.types.ResourceContainer): - Required. The resource container associated - with the capacity plan. - resource_id_key (google.cloud.capacityplanner_v1beta.types.ResourceIdKey): - Required. The resource id key associated with - the capacity plan. - location_id (google.cloud.capacityplanner_v1beta.types.LocationIdentifier): - Required. Identifier of location. - """ - - resource_container: resource.ResourceContainer = proto.Field( - proto.MESSAGE, - number=1, - message=resource.ResourceContainer, - ) - resource_id_key: resource.ResourceIdKey = proto.Field( - proto.MESSAGE, - number=2, - message=resource.ResourceIdKey, - ) - location_id: gcc_location.LocationIdentifier = proto.Field( - proto.MESSAGE, - number=3, - message=gcc_location.LocationIdentifier, - ) - - -class CapacityPlanView(proto.Message): - r"""CapacityPlanView contains the capacity plan key and the time - series views. - - Attributes: - key (google.cloud.capacityplanner_v1beta.types.CapacityPlanKey): - Required. The capacity plan key associated - with the capacity plan view. - time_series_views (MutableSequence[google.cloud.capacityplanner_v1beta.types.TimeSeriesView]): - Required. The time series views associated - with the capacity plan view. - """ - - key: "CapacityPlanKey" = proto.Field( - proto.MESSAGE, - number=1, - message="CapacityPlanKey", - ) - time_series_views: MutableSequence["TimeSeriesView"] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message="TimeSeriesView", - ) - - -class TimeSeriesView(proto.Message): - r"""TimeSeriesView contains capacity_value which has the timeseries for - a given type. Each type as a single timeseries associated with it. - - Attributes: - type_ (google.cloud.capacityplanner_v1beta.types.CapacityType): - Required. The capacity type associated with - the time series view. - capacity_value (google.cloud.capacityplanner_v1beta.types.DemandValue): - Required. The capacity value associated with - the time series view. - """ - - type_: "CapacityType" = proto.Field( - proto.ENUM, - number=1, - enum="CapacityType", - ) - capacity_value: "DemandValue" = proto.Field( - proto.MESSAGE, - number=2, - message="DemandValue", - ) - - -class CapacityPlan(proto.Message): - r"""A plan for additional capacity needed by a Google Cloud - Platform project. This is synonymous with CapacityDemand, - CapacityRequest, and CapacityDemandRequest. - - Attributes: - name (str): - Identifier. The name of the capacity plan. - - Format: projects/{project}/capacityPlans/{capacity_plan_id} - capacity_demand_metadata (google.cloud.capacityplanner_v1beta.types.DemandMetadata): - Optional. The metadata associated with a - capacity demand. - service_demands (MutableSequence[google.cloud.capacityplanner_v1beta.types.ServiceDemand]): - Required. The capacity demand associated with - a service. - reporter (google.cloud.capacityplanner_v1beta.types.User): - Output only. User who created the capacity - plan. - state (google.cloud.capacityplanner_v1beta.types.State): - Output only. State of the plan. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Timestamp when the plan was - created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Timestamp when the plan was last - updated. - description (str): - Optional. Description of the plan. - title (str): - Optional. Title of the plan. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - capacity_demand_metadata: "DemandMetadata" = proto.Field( - proto.MESSAGE, - number=2, - message="DemandMetadata", - ) - service_demands: MutableSequence["ServiceDemand"] = proto.RepeatedField( - proto.MESSAGE, - number=3, - message="ServiceDemand", - ) - reporter: "User" = proto.Field( - proto.MESSAGE, - number=4, - message="User", - ) - state: "State" = proto.Field( - proto.ENUM, - number=5, - enum="State", - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - description: str = proto.Field( - proto.STRING, - number=8, - ) - title: str = proto.Field( - proto.STRING, - number=9, - ) - - -class DemandMetadata(proto.Message): - r"""The metadata associated with a capacity demand. - - Attributes: - demand_preferences (MutableSequence[google.cloud.capacityplanner_v1beta.types.DemandPreference]): - Optional. The preferences associated with a - capacity demand. - """ - - demand_preferences: MutableSequence["DemandPreference"] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message="DemandPreference", - ) - - -class DemandPreference(proto.Message): - r"""Preference associated with a request, such as flexibility - with alternate resource type. - - Attributes: - preference_id (str): - Output only. The preference id. - value (google.cloud.capacityplanner_v1beta.types.Value): - Required. The value of demand preference. - """ - - preference_id: str = proto.Field( - proto.STRING, - number=1, - ) - value: resource.Value = proto.Field( - proto.MESSAGE, - number=2, - message=resource.Value, - ) - - -class ServiceDemand(proto.Message): - r"""Capacity demand for a service. - - Attributes: - service (str): - Required. Name of the service. - demand_metadata (google.cloud.capacityplanner_v1beta.types.DemandMetadata): - Optional. The metadata associated with a - service demand. - resource_demands (MutableSequence[google.cloud.capacityplanner_v1beta.types.ResourceDemand]): - Required. The demand associated with the - resources. - """ - - service: str = proto.Field( - proto.STRING, - number=1, - ) - demand_metadata: "DemandMetadata" = proto.Field( - proto.MESSAGE, - number=2, - message="DemandMetadata", - ) - resource_demands: MutableSequence["ResourceDemand"] = proto.RepeatedField( - proto.MESSAGE, - number=3, - message="ResourceDemand", - ) - - -class ResourceDemand(proto.Message): - r"""Capacity demand for a resource. - - Attributes: - id (str): - Output only. Identifier of resource demand. - resource_container (google.cloud.capacityplanner_v1beta.types.ResourceContainer): - Required. The resource container associated - with the demand. - resource_id (google.cloud.capacityplanner_v1beta.types.ResourceIdentifier): - Required. Identifier of resource. - location_id (google.cloud.capacityplanner_v1beta.types.LocationIdentifier): - Required. Identifier of location. - state (google.cloud.capacityplanner_v1beta.types.State): - Output only. State of the resource demand. - reporter (google.cloud.capacityplanner_v1beta.types.User): - Output only. User who reported the demand. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Timestamp when the demand was - created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Timestamp when the demand was - last updated. - demand_values (google.cloud.capacityplanner_v1beta.types.DemandValues): - Required. The demand values associated with - the resource. - demand_metadata (google.cloud.capacityplanner_v1beta.types.DemandMetadata): - Optional. The metadata associated with the - demand. - child_resource_demands (MutableSequence[google.cloud.capacityplanner_v1beta.types.ChildResourceDemand]): - Optional. The child resource demands - associated with the resource. - """ - - id: str = proto.Field( - proto.STRING, - number=1, - ) - resource_container: resource.ResourceContainer = proto.Field( - proto.MESSAGE, - number=2, - message=resource.ResourceContainer, - ) - resource_id: resource.ResourceIdentifier = proto.Field( - proto.MESSAGE, - number=3, - message=resource.ResourceIdentifier, - ) - location_id: gcc_location.LocationIdentifier = proto.Field( - proto.MESSAGE, - number=4, - message=gcc_location.LocationIdentifier, - ) - state: "State" = proto.Field( - proto.ENUM, - number=5, - enum="State", - ) - reporter: "User" = proto.Field( - proto.MESSAGE, - number=6, - message="User", - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - demand_values: "DemandValues" = proto.Field( - proto.MESSAGE, - number=9, - message="DemandValues", - ) - demand_metadata: "DemandMetadata" = proto.Field( - proto.MESSAGE, - number=10, - message="DemandMetadata", - ) - child_resource_demands: MutableSequence[ - "ChildResourceDemand" - ] = proto.RepeatedField( - proto.MESSAGE, - number=11, - message="ChildResourceDemand", - ) - - -class User(proto.Message): - r"""A user who created or updated a capacity demand. - - Attributes: - email (str): - Required. Email of the user. - """ - - email: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DemandValues(proto.Message): - r"""The capacity demand values for a resource. - - Attributes: - values (MutableSequence[google.cloud.capacityplanner_v1beta.types.DemandValue]): - Required. The demand values. - """ - - values: MutableSequence["DemandValue"] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message="DemandValue", - ) - - -class DemandValue(proto.Message): - r"""Capacity demand value for a single resource attribute such as - CPU count, vertex AI peak QPM, etc. - - Attributes: - name (str): - Required. The name of the demand value such - as CPU count. - time_values (MutableSequence[google.cloud.capacityplanner_v1beta.types.TimeValue]): - Required. The demand values at different time - points. - unit (google.cloud.capacityplanner_v1beta.types.Unit): - Required. Unit of measurement. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - time_values: MutableSequence["TimeValue"] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message="TimeValue", - ) - unit: resource.Unit = proto.Field( - proto.ENUM, - number=3, - enum=resource.Unit, - ) - - -class TimeValue(proto.Message): - r"""Capacity demand value for a single time point. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - time (google.protobuf.timestamp_pb2.Timestamp): - Required. The time point. If this demand - value is non-temporal, set time to -1. - value (float): - Required. The demand value at the time point. - - This field is a member of `oneof`_ ``_value``. - """ - - time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - value: float = proto.Field( - proto.DOUBLE, - number=2, - optional=True, - ) - - -class ChildResourceDemand(proto.Message): - r"""Capacity demand for a child resource such as shapes. - - Attributes: - resource_id (google.cloud.capacityplanner_v1beta.types.ResourceIdentifier): - Required. Identifier of resource. - demand_values (google.cloud.capacityplanner_v1beta.types.DemandValues): - Required. The demand values associated with - the child resource. - demand_metadata (google.cloud.capacityplanner_v1beta.types.DemandMetadata): - Optional. The metadata associated with the - child resource demand. - """ - - resource_id: resource.ResourceIdentifier = proto.Field( - proto.MESSAGE, - number=1, - message=resource.ResourceIdentifier, - ) - demand_values: "DemandValues" = proto.Field( - proto.MESSAGE, - number=2, - message="DemandValues", - ) - demand_metadata: "DemandMetadata" = proto.Field( - proto.MESSAGE, - number=3, - message="DemandMetadata", - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/usage_service.py b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/usage_service.py index 1165ab01451f..0d11e29a888b 100644 --- a/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/usage_service.py +++ b/packages/google-cloud-capacityplanner/google/cloud/capacityplanner_v1beta/types/usage_service.py @@ -97,8 +97,8 @@ class QueryUsageHistoriesRequest(proto.Message): return. Empty tpu_type will return results matching all TPUs. cloud_resource_type (str): - The resource for the ``UsageHistory`` values to return. - Possible values include "gce-vcpus", "gce-ram", + Required. The resource for the ``UsageHistory`` values to + return. Possible values include "gce-vcpus", "gce-ram", "gce-local-ssd", "gce-persistent-disk", "gce-gpu" and "gce-tpu". Empty cloud_resource_type will return results matching all resources. @@ -225,11 +225,11 @@ class QueryForecastsRequest(proto.Message): return. Empty tpu_type will return results matching all TPUs. cloud_resource_type (str): - The resource for the ``Forecast`` values to return. Possible - values include "gce-vcpus", "gce-ram", "gce-local-ssd", - "gce-persistent-disk", "gce-gpu" and "gce-tpu". Empty - cloud_resource_type will return results matching all - resources. + Required. The resource for the ``Forecast`` values to + return. Possible values include "gce-vcpus", "gce-ram", + "gce-local-ssd", "gce-persistent-disk", "gce-gpu" and + "gce-tpu". Empty cloud_resource_type will return results + matching all resources. forecast_type (google.cloud.capacityplanner_v1beta.types.Forecast.ForecastType): The type of forecast to use to select the ``Forecast`` values to return. FORECAST_TYPE_UNSPECIFIED will return @@ -338,12 +338,12 @@ class QueryReservationsRequest(proto.Message): https://cloud.google.com/compute/docs/gpus for a list. Empty gpu_type will return results matching all GPUs. cloud_resource_type (str): - Optional. The resource for the reserved + Required. The resource for the reserved values to return. Possible values include "gce-vcpus", "gce-ram", "gce-local-ssd", "gce-gpu" and "gce-vm". reservation_type (google.cloud.capacityplanner_v1beta.types.QueryReservationsRequest.ReservationType): - Optional. The Reservation type for example, + Required. The Reservation type for example, future reservation request and allocation. If unspecified, all types are included. share_type (google.cloud.capacityplanner_v1beta.types.QueryReservationsRequest.ShareType): @@ -357,7 +357,7 @@ class QueryReservationsRequest(proto.Message): parent project/folder/organization. If unspecified, all types are included. reservation_data_level (google.cloud.capacityplanner_v1beta.types.QueryReservationsRequest.ReservationDataLevel): - Optional. Reservations output data format. + Required. Reservations output data format. include_unapproved_reservations (bool): Optional. Whether to include pending for approval reservations in the response. This diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_async.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_async.py deleted file mode 100644 index 71ebabd5fb41..000000000000 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 GetCapacityPlan -# 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-capacityplanner - - -# [START capacityplanner_v1beta_generated_CapacityPlanningService_GetCapacityPlan_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 capacityplanner_v1beta - - -async def sample_get_capacity_plan(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceAsyncClient() - - # Initialize request argument(s) - request = capacityplanner_v1beta.GetCapacityPlanRequest( - name="name_value", - ) - - # Make the request - response = await client.get_capacity_plan(request=request) - - # Handle the response - print(response) - -# [END capacityplanner_v1beta_generated_CapacityPlanningService_GetCapacityPlan_async] diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_sync.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_sync.py deleted file mode 100644 index 198a2d0f7a3b..000000000000 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 GetCapacityPlan -# 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-capacityplanner - - -# [START capacityplanner_v1beta_generated_CapacityPlanningService_GetCapacityPlan_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 capacityplanner_v1beta - - -def sample_get_capacity_plan(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceClient() - - # Initialize request argument(s) - request = capacityplanner_v1beta.GetCapacityPlanRequest( - name="name_value", - ) - - # Make the request - response = client.get_capacity_plan(request=request) - - # Handle the response - print(response) - -# [END capacityplanner_v1beta_generated_CapacityPlanningService_GetCapacityPlan_sync] diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_async.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_async.py deleted file mode 100644 index 181eedba5549..000000000000 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_async.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 QueryCapacityPlanInsights -# 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-capacityplanner - - -# [START capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlanInsights_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 capacityplanner_v1beta - - -async def sample_query_capacity_plan_insights(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceAsyncClient() - - # Initialize request argument(s) - capacity_plan_filters = capacityplanner_v1beta.CapacityPlanFilters() - capacity_plan_filters.keys.resource_container.id = "id_value" - capacity_plan_filters.keys.resource_id_key.resource_code = "resource_code_value" - capacity_plan_filters.keys.location_id.source = "source_value" - capacity_plan_filters.capacity_types = ['CAPACITY_TYPE_INORGANIC_APPROVED'] - - request = capacityplanner_v1beta.QueryCapacityPlanInsightsRequest( - parent="parent_value", - capacity_plan_filters=capacity_plan_filters, - ) - - # Make the request - response = await client.query_capacity_plan_insights(request=request) - - # Handle the response - print(response) - -# [END capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlanInsights_async] diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_sync.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_sync.py deleted file mode 100644 index eac39c47b9d0..000000000000 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_sync.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 QueryCapacityPlanInsights -# 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-capacityplanner - - -# [START capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlanInsights_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 capacityplanner_v1beta - - -def sample_query_capacity_plan_insights(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceClient() - - # Initialize request argument(s) - capacity_plan_filters = capacityplanner_v1beta.CapacityPlanFilters() - capacity_plan_filters.keys.resource_container.id = "id_value" - capacity_plan_filters.keys.resource_id_key.resource_code = "resource_code_value" - capacity_plan_filters.keys.location_id.source = "source_value" - capacity_plan_filters.capacity_types = ['CAPACITY_TYPE_INORGANIC_APPROVED'] - - request = capacityplanner_v1beta.QueryCapacityPlanInsightsRequest( - parent="parent_value", - capacity_plan_filters=capacity_plan_filters, - ) - - # Make the request - response = client.query_capacity_plan_insights(request=request) - - # Handle the response - print(response) - -# [END capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlanInsights_sync] diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_async.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_async.py deleted file mode 100644 index 785064f1392b..000000000000 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 QueryCapacityPlans -# 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-capacityplanner - - -# [START capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlans_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 capacityplanner_v1beta - - -async def sample_query_capacity_plans(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceAsyncClient() - - # Initialize request argument(s) - request = capacityplanner_v1beta.QueryCapacityPlansRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.query_capacity_plans(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlans_async] diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_sync.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_sync.py deleted file mode 100644 index c11cb966ce45..000000000000 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 QueryCapacityPlans -# 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-capacityplanner - - -# [START capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlans_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 capacityplanner_v1beta - - -def sample_query_capacity_plans(): - # Create a client - client = capacityplanner_v1beta.CapacityPlanningServiceClient() - - # Initialize request argument(s) - request = capacityplanner_v1beta.QueryCapacityPlansRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.query_capacity_plans(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlans_sync] diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_forecasts_async.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_forecasts_async.py index 0619aff3d0b6..8a07fe6d00cc 100644 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_forecasts_async.py +++ b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_forecasts_async.py @@ -41,6 +41,7 @@ async def sample_query_forecasts(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryForecastsRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", ) # Make the request diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_forecasts_sync.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_forecasts_sync.py index 92168e05e374..8dca05815c56 100644 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_forecasts_sync.py +++ b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_forecasts_sync.py @@ -41,6 +41,7 @@ def sample_query_forecasts(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryForecastsRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", ) # Make the request diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_reservations_async.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_reservations_async.py index df41431e985d..f110c92f04ab 100644 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_reservations_async.py +++ b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_reservations_async.py @@ -41,6 +41,9 @@ async def sample_query_reservations(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryReservationsRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", + reservation_type="RESERVATION_TYPE_ALL", + reservation_data_level="RESERVATION_DATA_LEVEL_PER_RESERVATION", ) # Make the request diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_reservations_sync.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_reservations_sync.py index 4330d2f7b051..fcb0f1e5c1fb 100644 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_reservations_sync.py +++ b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_reservations_sync.py @@ -41,6 +41,9 @@ def sample_query_reservations(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryReservationsRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", + reservation_type="RESERVATION_TYPE_ALL", + reservation_data_level="RESERVATION_DATA_LEVEL_PER_RESERVATION", ) # Make the request diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_usage_histories_async.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_usage_histories_async.py index ea397b458b61..c38eba2e0145 100644 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_usage_histories_async.py +++ b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_usage_histories_async.py @@ -41,6 +41,7 @@ async def sample_query_usage_histories(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryUsageHistoriesRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", ) # Make the request diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_usage_histories_sync.py b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_usage_histories_sync.py index 9d2513a092d7..aabacc3696f7 100644 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_usage_histories_sync.py +++ b/packages/google-cloud-capacityplanner/samples/generated_samples/capacityplanner_v1beta_generated_usage_service_query_usage_histories_sync.py @@ -41,6 +41,7 @@ def sample_query_usage_histories(): # Initialize request argument(s) request = capacityplanner_v1beta.QueryUsageHistoriesRequest( parent="parent_value", + cloud_resource_type="cloud_resource_type_value", ) # Make the request diff --git a/packages/google-cloud-capacityplanner/samples/generated_samples/snippet_metadata_google.cloud.capacityplanner.v1beta.json b/packages/google-cloud-capacityplanner/samples/generated_samples/snippet_metadata_google.cloud.capacityplanner.v1beta.json index c1882c55de25..be805a4416bd 100644 --- a/packages/google-cloud-capacityplanner/samples/generated_samples/snippet_metadata_google.cloud.capacityplanner.v1beta.json +++ b/packages/google-cloud-capacityplanner/samples/generated_samples/snippet_metadata_google.cloud.capacityplanner.v1beta.json @@ -11,497 +11,6 @@ "version": "0.1.0" }, "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceAsyncClient", - "shortName": "CapacityPlanningServiceAsyncClient" - }, - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceAsyncClient.get_capacity_plan", - "method": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService.GetCapacityPlan", - "service": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "shortName": "CapacityPlanningService" - }, - "shortName": "GetCapacityPlan" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.capacityplanner_v1beta.types.GetCapacityPlanRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.capacityplanner_v1beta.types.CapacityPlan", - "shortName": "get_capacity_plan" - }, - "description": "Sample for GetCapacityPlan", - "file": "capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "capacityplanner_v1beta_generated_CapacityPlanningService_GetCapacityPlan_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": "capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient", - "shortName": "CapacityPlanningServiceClient" - }, - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient.get_capacity_plan", - "method": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService.GetCapacityPlan", - "service": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "shortName": "CapacityPlanningService" - }, - "shortName": "GetCapacityPlan" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.capacityplanner_v1beta.types.GetCapacityPlanRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.capacityplanner_v1beta.types.CapacityPlan", - "shortName": "get_capacity_plan" - }, - "description": "Sample for GetCapacityPlan", - "file": "capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "capacityplanner_v1beta_generated_CapacityPlanningService_GetCapacityPlan_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": "capacityplanner_v1beta_generated_capacity_planning_service_get_capacity_plan_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceAsyncClient", - "shortName": "CapacityPlanningServiceAsyncClient" - }, - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceAsyncClient.query_capacity_plan_insights", - "method": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService.QueryCapacityPlanInsights", - "service": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "shortName": "CapacityPlanningService" - }, - "shortName": "QueryCapacityPlanInsights" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.capacityplanner_v1beta.types.QueryCapacityPlanInsightsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "capacity_plan_filters", - "type": "google.cloud.capacityplanner_v1beta.types.CapacityPlanFilters" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.capacityplanner_v1beta.types.QueryCapacityPlanInsightsResponse", - "shortName": "query_capacity_plan_insights" - }, - "description": "Sample for QueryCapacityPlanInsights", - "file": "capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlanInsights_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": "capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient", - "shortName": "CapacityPlanningServiceClient" - }, - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient.query_capacity_plan_insights", - "method": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService.QueryCapacityPlanInsights", - "service": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "shortName": "CapacityPlanningService" - }, - "shortName": "QueryCapacityPlanInsights" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.capacityplanner_v1beta.types.QueryCapacityPlanInsightsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "capacity_plan_filters", - "type": "google.cloud.capacityplanner_v1beta.types.CapacityPlanFilters" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.capacityplanner_v1beta.types.QueryCapacityPlanInsightsResponse", - "shortName": "query_capacity_plan_insights" - }, - "description": "Sample for QueryCapacityPlanInsights", - "file": "capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlanInsights_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": "capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plan_insights_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceAsyncClient", - "shortName": "CapacityPlanningServiceAsyncClient" - }, - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceAsyncClient.query_capacity_plans", - "method": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService.QueryCapacityPlans", - "service": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "shortName": "CapacityPlanningService" - }, - "shortName": "QueryCapacityPlans" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.capacityplanner_v1beta.services.capacity_planning_service.pagers.QueryCapacityPlansAsyncPager", - "shortName": "query_capacity_plans" - }, - "description": "Sample for QueryCapacityPlans", - "file": "capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlans_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": "capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient", - "shortName": "CapacityPlanningServiceClient" - }, - "fullName": "google.cloud.capacityplanner_v1beta.CapacityPlanningServiceClient.query_capacity_plans", - "method": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService.QueryCapacityPlans", - "service": { - "fullName": "google.cloud.capacityplanner.v1beta.CapacityPlanningService", - "shortName": "CapacityPlanningService" - }, - "shortName": "QueryCapacityPlans" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.capacityplanner_v1beta.types.QueryCapacityPlansRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.capacityplanner_v1beta.services.capacity_planning_service.pagers.QueryCapacityPlansPager", - "shortName": "query_capacity_plans" - }, - "description": "Sample for QueryCapacityPlans", - "file": "capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "capacityplanner_v1beta_generated_CapacityPlanningService_QueryCapacityPlans_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": "capacityplanner_v1beta_generated_capacity_planning_service_query_capacity_plans_sync.py" - }, { "canonical": true, "clientMethod": { @@ -1006,12 +515,12 @@ "regionTag": "capacityplanner_v1beta_generated_UsageService_QueryForecasts_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -1021,18 +530,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], @@ -1082,12 +591,12 @@ "regionTag": "capacityplanner_v1beta_generated_UsageService_QueryForecasts_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -1097,18 +606,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], @@ -1163,12 +672,12 @@ "regionTag": "capacityplanner_v1beta_generated_UsageService_QueryReservations_async", "segments": [ { - "end": 51, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 54, "start": 27, "type": "SHORT" }, @@ -1178,18 +687,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], @@ -1243,12 +752,12 @@ "regionTag": "capacityplanner_v1beta_generated_UsageService_QueryReservations_sync", "segments": [ { - "end": 51, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 54, "start": 27, "type": "SHORT" }, @@ -1258,18 +767,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], @@ -1320,12 +829,12 @@ "regionTag": "capacityplanner_v1beta_generated_UsageService_QueryUsageHistories_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -1335,18 +844,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], @@ -1396,12 +905,12 @@ "regionTag": "capacityplanner_v1beta_generated_UsageService_QueryUsageHistories_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -1411,18 +920,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], diff --git a/packages/google-cloud-capacityplanner/scripts/fixup_capacityplanner_v1beta_keywords.py b/packages/google-cloud-capacityplanner/scripts/fixup_capacityplanner_v1beta_keywords.py index 0424db0de5f4..b711120828ba 100644 --- a/packages/google-cloud-capacityplanner/scripts/fixup_capacityplanner_v1beta_keywords.py +++ b/packages/google-cloud-capacityplanner/scripts/fixup_capacityplanner_v1beta_keywords.py @@ -42,12 +42,9 @@ class capacityplannerCallTransformer(cst.CSTTransformer): 'export_forecasts': ('parent', 'resource_type', 'output_config', 'machine_family', 'machine_shape', 'disk_type', 'gpu_type', 'tpu_type', 'prediction_interval', 'aggregation_method', 'start_date', 'end_date', ), 'export_reservations_usage': ('parent', 'cloud_resource_type', 'usage_aggregation_method', 'output_config', 'machine_family', 'machine_shape', 'gpu_type', 'location_level', 'share_type', 'start_date', 'end_date', ), 'export_usage_histories': ('parent', 'resource_type', 'output_config', 'is_spot', 'machine_family', 'machine_shape', 'disk_type', 'gpu_type', 'tpu_type', 'usage_aggregation_method', 'start_date', 'end_date', ), - 'get_capacity_plan': ('name', ), - 'query_capacity_plan_insights': ('parent', 'capacity_plan_filters', ), - 'query_capacity_plans': ('parent', 'page_size', 'page_token', 'location', ), - 'query_forecasts': ('parent', 'machine_family', 'machine_shape', 'disk_type', 'confidential_mode', 'gpu_type', 'tpu_type', 'cloud_resource_type', 'forecast_type', 'prediction_interval', 'aggregation_method', ), - 'query_reservations': ('parent', 'location_level', 'machine_family', 'machine_shape', 'gpu_type', 'cloud_resource_type', 'reservation_type', 'share_type', 'ownership_type', 'reservation_data_level', 'include_unapproved_reservations', 'aggregation_method', 'start_date', 'end_date', ), - 'query_usage_histories': ('parent', 'location_level', 'is_spot', 'machine_family', 'machine_shape', 'disk_type', 'confidential_mode', 'gpu_type', 'tpu_type', 'cloud_resource_type', 'usage_aggregation_method', 'start_date', 'end_date', ), + 'query_forecasts': ('parent', 'cloud_resource_type', 'machine_family', 'machine_shape', 'disk_type', 'confidential_mode', 'gpu_type', 'tpu_type', 'forecast_type', 'prediction_interval', 'aggregation_method', ), + 'query_reservations': ('parent', 'cloud_resource_type', 'reservation_type', 'reservation_data_level', 'location_level', 'machine_family', 'machine_shape', 'gpu_type', 'share_type', 'ownership_type', 'include_unapproved_reservations', 'aggregation_method', 'start_date', 'end_date', ), + 'query_usage_histories': ('parent', 'cloud_resource_type', 'location_level', 'is_spot', 'machine_family', 'machine_shape', 'disk_type', 'confidential_mode', 'gpu_type', 'tpu_type', 'usage_aggregation_method', 'start_date', 'end_date', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: diff --git a/packages/google-cloud-capacityplanner/tests/unit/gapic/capacityplanner_v1beta/test_capacity_planning_service.py b/packages/google-cloud-capacityplanner/tests/unit/gapic/capacityplanner_v1beta/test_capacity_planning_service.py deleted file mode 100644 index 35b91de70447..000000000000 --- a/packages/google-cloud-capacityplanner/tests/unit/gapic/capacityplanner_v1beta/test_capacity_planning_service.py +++ /dev/null @@ -1,4619 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 # pragma: NO COVER -except ImportError: # pragma: NO COVER - import mock - -from collections.abc import AsyncIterable, Iterable -import json -import math - -from google.api_core import api_core_version -from google.protobuf import json_format -import grpc -from grpc.experimental import aio -from proto.marshal.rules import wrappers -from proto.marshal.rules.dates import DurationRule, TimestampRule -import pytest -from requests import PreparedRequest, Request, Response -from requests.sessions import Session - -try: - from google.auth.aio import credentials as ga_credentials_async - - HAS_GOOGLE_AUTH_AIO = True -except ImportError: # pragma: NO COVER - HAS_GOOGLE_AUTH_AIO = False - -from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import retry as retries -import google.auth -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.oauth2 import service_account -from google.protobuf import timestamp_pb2 # type: ignore - -from google.cloud.capacityplanner_v1beta.services.capacity_planning_service import ( - CapacityPlanningServiceAsyncClient, - CapacityPlanningServiceClient, - pagers, - transports, -) -from google.cloud.capacityplanner_v1beta.types import ( - capacity_planning_service, - location, - resource, -) - -CRED_INFO_JSON = { - "credential_source": "/path/to/file", - "credential_type": "service account credentials", - "principal": "service-account@example.com", -} -CRED_INFO_STRING = json.dumps(CRED_INFO_JSON) - - -async def mock_async_gen(data, chunk_size=1): - for i in range(0, len(data)): # pragma: NO COVER - chunk = data[i : i + chunk_size] - yield chunk.encode("utf-8") - - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# TODO: use async auth anon credentials by default once the minimum version of google-auth is upgraded. -# See related issue: https://github.com/googleapis/gapic-generator-python/issues/2107. -def async_anonymous_credentials(): - if HAS_GOOGLE_AUTH_AIO: - return ga_credentials_async.AnonymousCredentials() - return ga_credentials.AnonymousCredentials() - - -# 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 - ) - - -# If default endpoint template is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint template so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint_template(client): - return ( - "test.{UNIVERSE_DOMAIN}" - if ("localhost" in client._DEFAULT_ENDPOINT_TEMPLATE) - else client._DEFAULT_ENDPOINT_TEMPLATE - ) - - -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 CapacityPlanningServiceClient._get_default_mtls_endpoint(None) is None - assert ( - CapacityPlanningServiceClient._get_default_mtls_endpoint(api_endpoint) - == api_mtls_endpoint - ) - assert ( - CapacityPlanningServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) - == api_mtls_endpoint - ) - assert ( - CapacityPlanningServiceClient._get_default_mtls_endpoint(sandbox_endpoint) - == sandbox_mtls_endpoint - ) - assert ( - CapacityPlanningServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) - == sandbox_mtls_endpoint - ) - assert ( - CapacityPlanningServiceClient._get_default_mtls_endpoint(non_googleapi) - == non_googleapi - ) - - -def test__read_environment_variables(): - assert CapacityPlanningServiceClient._read_environment_variables() == ( - False, - "auto", - None, - ) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - assert CapacityPlanningServiceClient._read_environment_variables() == ( - True, - "auto", - None, - ) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - assert CapacityPlanningServiceClient._read_environment_variables() == ( - False, - "auto", - None, - ) - - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} - ): - with pytest.raises(ValueError) as excinfo: - CapacityPlanningServiceClient._read_environment_variables() - assert ( - str(excinfo.value) - == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - assert CapacityPlanningServiceClient._read_environment_variables() == ( - False, - "never", - None, - ) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - assert CapacityPlanningServiceClient._read_environment_variables() == ( - False, - "always", - None, - ) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}): - assert CapacityPlanningServiceClient._read_environment_variables() == ( - False, - "auto", - None, - ) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - CapacityPlanningServiceClient._read_environment_variables() - assert ( - str(excinfo.value) - == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - ) - - with mock.patch.dict(os.environ, {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": "foo.com"}): - assert CapacityPlanningServiceClient._read_environment_variables() == ( - False, - "auto", - "foo.com", - ) - - -def test__get_client_cert_source(): - mock_provided_cert_source = mock.Mock() - mock_default_cert_source = mock.Mock() - - assert CapacityPlanningServiceClient._get_client_cert_source(None, False) is None - assert ( - CapacityPlanningServiceClient._get_client_cert_source( - mock_provided_cert_source, False - ) - is None - ) - assert ( - CapacityPlanningServiceClient._get_client_cert_source( - mock_provided_cert_source, True - ) - == mock_provided_cert_source - ) - - 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_default_cert_source, - ): - assert ( - CapacityPlanningServiceClient._get_client_cert_source(None, True) - is mock_default_cert_source - ) - assert ( - CapacityPlanningServiceClient._get_client_cert_source( - mock_provided_cert_source, "true" - ) - is mock_provided_cert_source - ) - - -@mock.patch.object( - CapacityPlanningServiceClient, - "_DEFAULT_ENDPOINT_TEMPLATE", - modify_default_endpoint_template(CapacityPlanningServiceClient), -) -@mock.patch.object( - CapacityPlanningServiceAsyncClient, - "_DEFAULT_ENDPOINT_TEMPLATE", - modify_default_endpoint_template(CapacityPlanningServiceAsyncClient), -) -def test__get_api_endpoint(): - api_override = "foo.com" - mock_client_cert_source = mock.Mock() - default_universe = CapacityPlanningServiceClient._DEFAULT_UNIVERSE - default_endpoint = CapacityPlanningServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format( - UNIVERSE_DOMAIN=default_universe - ) - mock_universe = "bar.com" - mock_endpoint = CapacityPlanningServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format( - UNIVERSE_DOMAIN=mock_universe - ) - - assert ( - CapacityPlanningServiceClient._get_api_endpoint( - api_override, mock_client_cert_source, default_universe, "always" - ) - == api_override - ) - assert ( - CapacityPlanningServiceClient._get_api_endpoint( - None, mock_client_cert_source, default_universe, "auto" - ) - == CapacityPlanningServiceClient.DEFAULT_MTLS_ENDPOINT - ) - assert ( - CapacityPlanningServiceClient._get_api_endpoint( - None, None, default_universe, "auto" - ) - == default_endpoint - ) - assert ( - CapacityPlanningServiceClient._get_api_endpoint( - None, None, default_universe, "always" - ) - == CapacityPlanningServiceClient.DEFAULT_MTLS_ENDPOINT - ) - assert ( - CapacityPlanningServiceClient._get_api_endpoint( - None, mock_client_cert_source, default_universe, "always" - ) - == CapacityPlanningServiceClient.DEFAULT_MTLS_ENDPOINT - ) - assert ( - CapacityPlanningServiceClient._get_api_endpoint( - None, None, mock_universe, "never" - ) - == mock_endpoint - ) - assert ( - CapacityPlanningServiceClient._get_api_endpoint( - None, None, default_universe, "never" - ) - == default_endpoint - ) - - with pytest.raises(MutualTLSChannelError) as excinfo: - CapacityPlanningServiceClient._get_api_endpoint( - None, mock_client_cert_source, mock_universe, "auto" - ) - assert ( - str(excinfo.value) - == "mTLS is not supported in any universe other than googleapis.com." - ) - - -def test__get_universe_domain(): - client_universe_domain = "foo.com" - universe_domain_env = "bar.com" - - assert ( - CapacityPlanningServiceClient._get_universe_domain( - client_universe_domain, universe_domain_env - ) - == client_universe_domain - ) - assert ( - CapacityPlanningServiceClient._get_universe_domain(None, universe_domain_env) - == universe_domain_env - ) - assert ( - CapacityPlanningServiceClient._get_universe_domain(None, None) - == CapacityPlanningServiceClient._DEFAULT_UNIVERSE - ) - - with pytest.raises(ValueError) as excinfo: - CapacityPlanningServiceClient._get_universe_domain("", None) - assert str(excinfo.value) == "Universe Domain cannot be an empty string." - - -@pytest.mark.parametrize( - "error_code,cred_info_json,show_cred_info", - [ - (401, CRED_INFO_JSON, True), - (403, CRED_INFO_JSON, True), - (404, CRED_INFO_JSON, True), - (500, CRED_INFO_JSON, False), - (401, None, False), - (403, None, False), - (404, None, False), - (500, None, False), - ], -) -def test__add_cred_info_for_auth_errors(error_code, cred_info_json, show_cred_info): - cred = mock.Mock(["get_cred_info"]) - cred.get_cred_info = mock.Mock(return_value=cred_info_json) - client = CapacityPlanningServiceClient(credentials=cred) - client._transport._credentials = cred - - error = core_exceptions.GoogleAPICallError("message", details=["foo"]) - error.code = error_code - - client._add_cred_info_for_auth_errors(error) - if show_cred_info: - assert error.details == ["foo", CRED_INFO_STRING] - else: - assert error.details == ["foo"] - - -@pytest.mark.parametrize("error_code", [401, 403, 404, 500]) -def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code): - cred = mock.Mock([]) - assert not hasattr(cred, "get_cred_info") - client = CapacityPlanningServiceClient(credentials=cred) - client._transport._credentials = cred - - error = core_exceptions.GoogleAPICallError("message", details=[]) - error.code = error_code - - client._add_cred_info_for_auth_errors(error) - assert error.details == [] - - -@pytest.mark.parametrize( - "client_class,transport_name", - [ - (CapacityPlanningServiceClient, "grpc"), - (CapacityPlanningServiceAsyncClient, "grpc_asyncio"), - (CapacityPlanningServiceClient, "rest"), - ], -) -def test_capacity_planning_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 == ( - "capacityplanner.googleapis.com:443" - if transport_name in ["grpc", "grpc_asyncio"] - else "https://capacityplanner.googleapis.com" - ) - - -@pytest.mark.parametrize( - "transport_class,transport_name", - [ - (transports.CapacityPlanningServiceGrpcTransport, "grpc"), - (transports.CapacityPlanningServiceGrpcAsyncIOTransport, "grpc_asyncio"), - (transports.CapacityPlanningServiceRestTransport, "rest"), - ], -) -def test_capacity_planning_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", - [ - (CapacityPlanningServiceClient, "grpc"), - (CapacityPlanningServiceAsyncClient, "grpc_asyncio"), - (CapacityPlanningServiceClient, "rest"), - ], -) -def test_capacity_planning_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 == ( - "capacityplanner.googleapis.com:443" - if transport_name in ["grpc", "grpc_asyncio"] - else "https://capacityplanner.googleapis.com" - ) - - -def test_capacity_planning_service_client_get_transport_class(): - transport = CapacityPlanningServiceClient.get_transport_class() - available_transports = [ - transports.CapacityPlanningServiceGrpcTransport, - transports.CapacityPlanningServiceRestTransport, - ] - assert transport in available_transports - - transport = CapacityPlanningServiceClient.get_transport_class("grpc") - assert transport == transports.CapacityPlanningServiceGrpcTransport - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceGrpcTransport, - "grpc", - ), - ( - CapacityPlanningServiceAsyncClient, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - "grpc_asyncio", - ), - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceRestTransport, - "rest", - ), - ], -) -@mock.patch.object( - CapacityPlanningServiceClient, - "_DEFAULT_ENDPOINT_TEMPLATE", - modify_default_endpoint_template(CapacityPlanningServiceClient), -) -@mock.patch.object( - CapacityPlanningServiceAsyncClient, - "_DEFAULT_ENDPOINT_TEMPLATE", - modify_default_endpoint_template(CapacityPlanningServiceAsyncClient), -) -def test_capacity_planning_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(CapacityPlanningServiceClient, "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(CapacityPlanningServiceClient, "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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ), - 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) as excinfo: - client = client_class(transport=transport_name) - assert ( - str(excinfo.value) - == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - ) - - # 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) as excinfo: - client = client_class(transport=transport_name) - assert ( - str(excinfo.value) - == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - - # 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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ), - 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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ), - 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", - [ - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceGrpcTransport, - "grpc", - "true", - ), - ( - CapacityPlanningServiceAsyncClient, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - "grpc_asyncio", - "true", - ), - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceGrpcTransport, - "grpc", - "false", - ), - ( - CapacityPlanningServiceAsyncClient, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - "grpc_asyncio", - "false", - ), - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceRestTransport, - "rest", - "true", - ), - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceRestTransport, - "rest", - "false", - ), - ], -) -@mock.patch.object( - CapacityPlanningServiceClient, - "_DEFAULT_ENDPOINT_TEMPLATE", - modify_default_endpoint_template(CapacityPlanningServiceClient), -) -@mock.patch.object( - CapacityPlanningServiceAsyncClient, - "_DEFAULT_ENDPOINT_TEMPLATE", - modify_default_endpoint_template(CapacityPlanningServiceAsyncClient), -) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_capacity_planning_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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ) - 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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ) - 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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ), - 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", [CapacityPlanningServiceClient, CapacityPlanningServiceAsyncClient] -) -@mock.patch.object( - CapacityPlanningServiceClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(CapacityPlanningServiceClient), -) -@mock.patch.object( - CapacityPlanningServiceAsyncClient, - "DEFAULT_ENDPOINT", - modify_default_endpoint(CapacityPlanningServiceAsyncClient), -) -def test_capacity_planning_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 - - # 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) as excinfo: - client_class.get_mtls_endpoint_and_cert_source() - - assert ( - str(excinfo.value) - == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - ) - - # 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) as excinfo: - client_class.get_mtls_endpoint_and_cert_source() - - assert ( - str(excinfo.value) - == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - - -@pytest.mark.parametrize( - "client_class", [CapacityPlanningServiceClient, CapacityPlanningServiceAsyncClient] -) -@mock.patch.object( - CapacityPlanningServiceClient, - "_DEFAULT_ENDPOINT_TEMPLATE", - modify_default_endpoint_template(CapacityPlanningServiceClient), -) -@mock.patch.object( - CapacityPlanningServiceAsyncClient, - "_DEFAULT_ENDPOINT_TEMPLATE", - modify_default_endpoint_template(CapacityPlanningServiceAsyncClient), -) -def test_capacity_planning_service_client_client_api_endpoint(client_class): - mock_client_cert_source = client_cert_source_callback - api_override = "foo.com" - default_universe = CapacityPlanningServiceClient._DEFAULT_UNIVERSE - default_endpoint = CapacityPlanningServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format( - UNIVERSE_DOMAIN=default_universe - ) - mock_universe = "bar.com" - mock_endpoint = CapacityPlanningServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format( - UNIVERSE_DOMAIN=mock_universe - ) - - # If ClientOptions.api_endpoint is set and GOOGLE_API_USE_CLIENT_CERTIFICATE="true", - # use ClientOptions.api_endpoint as the api endpoint regardless. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch( - "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel" - ): - options = client_options.ClientOptions( - client_cert_source=mock_client_cert_source, api_endpoint=api_override - ) - client = client_class( - client_options=options, - credentials=ga_credentials.AnonymousCredentials(), - ) - assert client.api_endpoint == api_override - - # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="never", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - client = client_class(credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == default_endpoint - - # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="always", - # use the DEFAULT_MTLS_ENDPOINT as the api endpoint. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - client = client_class(credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - - # If ClientOptions.api_endpoint is not set, GOOGLE_API_USE_MTLS_ENDPOINT="auto" (default), - # GOOGLE_API_USE_CLIENT_CERTIFICATE="false" (default), default cert source doesn't exist, - # and ClientOptions.universe_domain="bar.com", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with universe domain as the api endpoint. - options = client_options.ClientOptions() - universe_exists = hasattr(options, "universe_domain") - if universe_exists: - options = client_options.ClientOptions(universe_domain=mock_universe) - client = client_class( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) - else: - client = client_class( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) - assert client.api_endpoint == ( - mock_endpoint if universe_exists else default_endpoint - ) - assert client.universe_domain == ( - mock_universe if universe_exists else default_universe - ) - - # If ClientOptions does not have a universe domain attribute and GOOGLE_API_USE_MTLS_ENDPOINT="never", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. - options = client_options.ClientOptions() - if hasattr(options, "universe_domain"): - delattr(options, "universe_domain") - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - client = client_class( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) - assert client.api_endpoint == default_endpoint - - -@pytest.mark.parametrize( - "client_class,transport_class,transport_name", - [ - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceGrpcTransport, - "grpc", - ), - ( - CapacityPlanningServiceAsyncClient, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - "grpc_asyncio", - ), - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceRestTransport, - "rest", - ), - ], -) -def test_capacity_planning_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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ), - 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", - [ - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceGrpcTransport, - "grpc", - grpc_helpers, - ), - ( - CapacityPlanningServiceAsyncClient, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - "grpc_asyncio", - grpc_helpers_async, - ), - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceRestTransport, - "rest", - None, - ), - ], -) -def test_capacity_planning_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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ), - 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_capacity_planning_service_client_client_options_from_dict(): - with mock.patch( - "google.cloud.capacityplanner_v1beta.services.capacity_planning_service.transports.CapacityPlanningServiceGrpcTransport.__init__" - ) as grpc_transport: - grpc_transport.return_value = None - client = CapacityPlanningServiceClient( - 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", - [ - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceGrpcTransport, - "grpc", - grpc_helpers, - ), - ( - CapacityPlanningServiceAsyncClient, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - "grpc_asyncio", - grpc_helpers_async, - ), - ], -) -def test_capacity_planning_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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ), - 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( - "capacityplanner.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/devstorage.full_control", - ), - scopes=None, - default_host="capacityplanner.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "request_type", - [ - capacity_planning_service.GetCapacityPlanRequest, - dict, - ], -) -def test_get_capacity_plan(request_type, transport: str = "grpc"): - client = CapacityPlanningServiceClient( - 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_capacity_plan), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = capacity_planning_service.CapacityPlan( - name="name_value", - state=capacity_planning_service.State.PENDING_REVIEW, - description="description_value", - title="title_value", - ) - response = client.get_capacity_plan(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = capacity_planning_service.GetCapacityPlanRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, capacity_planning_service.CapacityPlan) - assert response.name == "name_value" - assert response.state == capacity_planning_service.State.PENDING_REVIEW - assert response.description == "description_value" - assert response.title == "title_value" - - -def test_get_capacity_plan_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = capacity_planning_service.GetCapacityPlanRequest( - name="name_value", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_capacity_plan), "__call__" - ) as call: - call.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client.get_capacity_plan(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == capacity_planning_service.GetCapacityPlanRequest( - name="name_value", - ) - - -def test_get_capacity_plan_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_capacity_plan in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.get_capacity_plan - ] = mock_rpc - request = {} - client.get_capacity_plan(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_capacity_plan(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -@pytest.mark.asyncio -async def test_get_capacity_plan_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._client._transport.get_capacity_plan - in client._client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[ - client._client._transport.get_capacity_plan - ] = mock_rpc - - request = {} - await client.get_capacity_plan(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_capacity_plan(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -@pytest.mark.asyncio -async def test_get_capacity_plan_async( - transport: str = "grpc_asyncio", - request_type=capacity_planning_service.GetCapacityPlanRequest, -): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - 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_capacity_plan), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.CapacityPlan( - name="name_value", - state=capacity_planning_service.State.PENDING_REVIEW, - description="description_value", - title="title_value", - ) - ) - response = await client.get_capacity_plan(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = capacity_planning_service.GetCapacityPlanRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, capacity_planning_service.CapacityPlan) - assert response.name == "name_value" - assert response.state == capacity_planning_service.State.PENDING_REVIEW - assert response.description == "description_value" - assert response.title == "title_value" - - -@pytest.mark.asyncio -async def test_get_capacity_plan_async_from_dict(): - await test_get_capacity_plan_async(request_type=dict) - - -def test_get_capacity_plan_field_headers(): - client = CapacityPlanningServiceClient( - 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 = capacity_planning_service.GetCapacityPlanRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_capacity_plan), "__call__" - ) as call: - call.return_value = capacity_planning_service.CapacityPlan() - client.get_capacity_plan(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_capacity_plan_field_headers_async(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = capacity_planning_service.GetCapacityPlanRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_capacity_plan), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.CapacityPlan() - ) - await client.get_capacity_plan(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_capacity_plan_flattened(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_capacity_plan), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = capacity_planning_service.CapacityPlan() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_capacity_plan( - 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_capacity_plan_flattened_error(): - client = CapacityPlanningServiceClient( - 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_capacity_plan( - capacity_planning_service.GetCapacityPlanRequest(), - name="name_value", - ) - - -@pytest.mark.asyncio -async def test_get_capacity_plan_flattened_async(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_capacity_plan), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = capacity_planning_service.CapacityPlan() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.CapacityPlan() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_capacity_plan( - 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_capacity_plan_flattened_error_async(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_capacity_plan( - capacity_planning_service.GetCapacityPlanRequest(), - name="name_value", - ) - - -@pytest.mark.parametrize( - "request_type", - [ - capacity_planning_service.QueryCapacityPlansRequest, - dict, - ], -) -def test_query_capacity_plans(request_type, transport: str = "grpc"): - client = CapacityPlanningServiceClient( - 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.query_capacity_plans), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = capacity_planning_service.QueryCapacityPlansResponse( - next_page_token="next_page_token_value", - ) - response = client.query_capacity_plans(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = capacity_planning_service.QueryCapacityPlansRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.QueryCapacityPlansPager) - assert response.next_page_token == "next_page_token_value" - - -def test_query_capacity_plans_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = capacity_planning_service.QueryCapacityPlansRequest( - parent="parent_value", - page_token="page_token_value", - location="location_value", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), "__call__" - ) as call: - call.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client.query_capacity_plans(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == capacity_planning_service.QueryCapacityPlansRequest( - parent="parent_value", - page_token="page_token_value", - location="location_value", - ) - - -def test_query_capacity_plans_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.query_capacity_plans in client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.query_capacity_plans - ] = mock_rpc - request = {} - client.query_capacity_plans(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.query_capacity_plans(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -@pytest.mark.asyncio -async def test_query_capacity_plans_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._client._transport.query_capacity_plans - in client._client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[ - client._client._transport.query_capacity_plans - ] = mock_rpc - - request = {} - await client.query_capacity_plans(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.query_capacity_plans(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -@pytest.mark.asyncio -async def test_query_capacity_plans_async( - transport: str = "grpc_asyncio", - request_type=capacity_planning_service.QueryCapacityPlansRequest, -): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - 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.query_capacity_plans), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.QueryCapacityPlansResponse( - next_page_token="next_page_token_value", - ) - ) - response = await client.query_capacity_plans(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = capacity_planning_service.QueryCapacityPlansRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.QueryCapacityPlansAsyncPager) - assert response.next_page_token == "next_page_token_value" - - -@pytest.mark.asyncio -async def test_query_capacity_plans_async_from_dict(): - await test_query_capacity_plans_async(request_type=dict) - - -def test_query_capacity_plans_field_headers(): - client = CapacityPlanningServiceClient( - 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 = capacity_planning_service.QueryCapacityPlansRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), "__call__" - ) as call: - call.return_value = capacity_planning_service.QueryCapacityPlansResponse() - client.query_capacity_plans(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_query_capacity_plans_field_headers_async(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = capacity_planning_service.QueryCapacityPlansRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.QueryCapacityPlansResponse() - ) - await client.query_capacity_plans(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_query_capacity_plans_flattened(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = capacity_planning_service.QueryCapacityPlansResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.query_capacity_plans( - 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_query_capacity_plans_flattened_error(): - client = CapacityPlanningServiceClient( - 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.query_capacity_plans( - capacity_planning_service.QueryCapacityPlansRequest(), - parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_query_capacity_plans_flattened_async(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = capacity_planning_service.QueryCapacityPlansResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.QueryCapacityPlansResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.query_capacity_plans( - 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_query_capacity_plans_flattened_error_async(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.query_capacity_plans( - capacity_planning_service.QueryCapacityPlansRequest(), - parent="parent_value", - ) - - -def test_query_capacity_plans_pager(transport_name: str = "grpc"): - client = CapacityPlanningServiceClient( - 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.query_capacity_plans), "__call__" - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - next_page_token="abc", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[], - next_page_token="def", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - ], - next_page_token="ghi", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.query_capacity_plans(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all( - isinstance(i, capacity_planning_service.CapacityPlan) for i in results - ) - - -def test_query_capacity_plans_pages(transport_name: str = "grpc"): - client = CapacityPlanningServiceClient( - 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.query_capacity_plans), "__call__" - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - next_page_token="abc", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[], - next_page_token="def", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - ], - next_page_token="ghi", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - ), - RuntimeError, - ) - pages = list(client.query_capacity_plans(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_query_capacity_plans_async_pager(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - next_page_token="abc", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[], - next_page_token="def", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - ], - next_page_token="ghi", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - ), - RuntimeError, - ) - async_pager = await client.query_capacity_plans( - 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, capacity_planning_service.CapacityPlan) for i in responses - ) - - -@pytest.mark.asyncio -async def test_query_capacity_plans_async_pages(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - next_page_token="abc", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[], - next_page_token="def", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - ], - next_page_token="ghi", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.query_capacity_plans(request={}) - ).pages: - 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", - [ - capacity_planning_service.QueryCapacityPlanInsightsRequest, - dict, - ], -) -def test_query_capacity_plan_insights(request_type, transport: str = "grpc"): - client = CapacityPlanningServiceClient( - 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.query_capacity_plan_insights), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = ( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - response = client.query_capacity_plan_insights(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = capacity_planning_service.QueryCapacityPlanInsightsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance( - response, capacity_planning_service.QueryCapacityPlanInsightsResponse - ) - - -def test_query_capacity_plan_insights_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = capacity_planning_service.QueryCapacityPlanInsightsRequest( - parent="parent_value", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plan_insights), "__call__" - ) as call: - call.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client.query_capacity_plan_insights(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == capacity_planning_service.QueryCapacityPlanInsightsRequest( - parent="parent_value", - ) - - -def test_query_capacity_plan_insights_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.query_capacity_plan_insights - in client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.query_capacity_plan_insights - ] = mock_rpc - request = {} - client.query_capacity_plan_insights(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.query_capacity_plan_insights(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -@pytest.mark.asyncio -async def test_query_capacity_plan_insights_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._client._transport.query_capacity_plan_insights - in client._client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[ - client._client._transport.query_capacity_plan_insights - ] = mock_rpc - - request = {} - await client.query_capacity_plan_insights(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.query_capacity_plan_insights(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -@pytest.mark.asyncio -async def test_query_capacity_plan_insights_async( - transport: str = "grpc_asyncio", - request_type=capacity_planning_service.QueryCapacityPlanInsightsRequest, -): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - 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.query_capacity_plan_insights), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - response = await client.query_capacity_plan_insights(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = capacity_planning_service.QueryCapacityPlanInsightsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance( - response, capacity_planning_service.QueryCapacityPlanInsightsResponse - ) - - -@pytest.mark.asyncio -async def test_query_capacity_plan_insights_async_from_dict(): - await test_query_capacity_plan_insights_async(request_type=dict) - - -def test_query_capacity_plan_insights_field_headers(): - client = CapacityPlanningServiceClient( - 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 = capacity_planning_service.QueryCapacityPlanInsightsRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plan_insights), "__call__" - ) as call: - call.return_value = ( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - client.query_capacity_plan_insights(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_query_capacity_plan_insights_field_headers_async(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = capacity_planning_service.QueryCapacityPlanInsightsRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plan_insights), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - await client.query_capacity_plan_insights(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_query_capacity_plan_insights_flattened(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plan_insights), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = ( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.query_capacity_plan_insights( - parent="parent_value", - capacity_plan_filters=capacity_planning_service.CapacityPlanFilters( - keys=[ - capacity_planning_service.CapacityPlanKey( - resource_container=resource.ResourceContainer( - type_=resource.ResourceContainer.Type.PROJECT - ) - ) - ] - ), - ) - - # 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].capacity_plan_filters - mock_val = capacity_planning_service.CapacityPlanFilters( - keys=[ - capacity_planning_service.CapacityPlanKey( - resource_container=resource.ResourceContainer( - type_=resource.ResourceContainer.Type.PROJECT - ) - ) - ] - ) - assert arg == mock_val - - -def test_query_capacity_plan_insights_flattened_error(): - client = CapacityPlanningServiceClient( - 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.query_capacity_plan_insights( - capacity_planning_service.QueryCapacityPlanInsightsRequest(), - parent="parent_value", - capacity_plan_filters=capacity_planning_service.CapacityPlanFilters( - keys=[ - capacity_planning_service.CapacityPlanKey( - resource_container=resource.ResourceContainer( - type_=resource.ResourceContainer.Type.PROJECT - ) - ) - ] - ), - ) - - -@pytest.mark.asyncio -async def test_query_capacity_plan_insights_flattened_async(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plan_insights), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = ( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.query_capacity_plan_insights( - parent="parent_value", - capacity_plan_filters=capacity_planning_service.CapacityPlanFilters( - keys=[ - capacity_planning_service.CapacityPlanKey( - resource_container=resource.ResourceContainer( - type_=resource.ResourceContainer.Type.PROJECT - ) - ) - ] - ), - ) - - # 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].capacity_plan_filters - mock_val = capacity_planning_service.CapacityPlanFilters( - keys=[ - capacity_planning_service.CapacityPlanKey( - resource_container=resource.ResourceContainer( - type_=resource.ResourceContainer.Type.PROJECT - ) - ) - ] - ) - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_query_capacity_plan_insights_flattened_error_async(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.query_capacity_plan_insights( - capacity_planning_service.QueryCapacityPlanInsightsRequest(), - parent="parent_value", - capacity_plan_filters=capacity_planning_service.CapacityPlanFilters( - keys=[ - capacity_planning_service.CapacityPlanKey( - resource_container=resource.ResourceContainer( - type_=resource.ResourceContainer.Type.PROJECT - ) - ) - ] - ), - ) - - -def test_get_capacity_plan_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_capacity_plan in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.get_capacity_plan - ] = mock_rpc - - request = {} - client.get_capacity_plan(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_capacity_plan(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_capacity_plan_rest_required_fields( - request_type=capacity_planning_service.GetCapacityPlanRequest, -): - transport_class = transports.CapacityPlanningServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_capacity_plan._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = "name_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_capacity_plan._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" - - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = capacity_planning_service.CapacityPlan() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = capacity_planning_service.CapacityPlan.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_capacity_plan(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_get_capacity_plan_rest_unset_required_fields(): - transport = transports.CapacityPlanningServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.get_capacity_plan._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) - - -def test_get_capacity_plan_rest_flattened(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = capacity_planning_service.CapacityPlan() - - # get arguments that satisfy an http rule for this method - sample_request = {"name": "projects/sample1/capacityPlans/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = capacity_planning_service.CapacityPlan.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_capacity_plan(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1beta/{name=projects/*/capacityPlans/*}" % client.transport._host, - args[1], - ) - - -def test_get_capacity_plan_rest_flattened_error(transport: str = "rest"): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_capacity_plan( - capacity_planning_service.GetCapacityPlanRequest(), - name="name_value", - ) - - -def test_query_capacity_plans_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.query_capacity_plans in client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.query_capacity_plans - ] = mock_rpc - - request = {} - client.query_capacity_plans(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.query_capacity_plans(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_query_capacity_plans_rest_required_fields( - request_type=capacity_planning_service.QueryCapacityPlansRequest, -): - transport_class = transports.CapacityPlanningServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).query_capacity_plans._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).query_capacity_plans._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "location", - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = capacity_planning_service.QueryCapacityPlansResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = capacity_planning_service.QueryCapacityPlansResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.query_capacity_plans(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_query_capacity_plans_rest_unset_required_fields(): - transport = transports.CapacityPlanningServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.query_capacity_plans._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "location", - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) - - -def test_query_capacity_plans_rest_flattened(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = capacity_planning_service.QueryCapacityPlansResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "organizations/sample1"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = capacity_planning_service.QueryCapacityPlansResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.query_capacity_plans(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1beta/{parent=organizations/*}/capacityPlans:query" - % client.transport._host, - args[1], - ) - - -def test_query_capacity_plans_rest_flattened_error(transport: str = "rest"): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.query_capacity_plans( - capacity_planning_service.QueryCapacityPlansRequest(), - parent="parent_value", - ) - - -def test_query_capacity_plans_rest_pager(transport: str = "rest"): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - next_page_token="abc", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[], - next_page_token="def", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - ], - next_page_token="ghi", - ), - capacity_planning_service.QueryCapacityPlansResponse( - capacity_plans=[ - capacity_planning_service.CapacityPlan(), - capacity_planning_service.CapacityPlan(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - capacity_planning_service.QueryCapacityPlansResponse.to_json(x) - for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "organizations/sample1"} - - pager = client.query_capacity_plans(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all( - isinstance(i, capacity_planning_service.CapacityPlan) for i in results - ) - - pages = list(client.query_capacity_plans(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -def test_query_capacity_plan_insights_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.query_capacity_plan_insights - in client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.query_capacity_plan_insights - ] = mock_rpc - - request = {} - client.query_capacity_plan_insights(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.query_capacity_plan_insights(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_query_capacity_plan_insights_rest_required_fields( - request_type=capacity_planning_service.QueryCapacityPlanInsightsRequest, -): - transport_class = transports.CapacityPlanningServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).query_capacity_plan_insights._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).query_capacity_plan_insights._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = capacity_planning_service.QueryCapacityPlanInsightsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = ( - capacity_planning_service.QueryCapacityPlanInsightsResponse.pb( - return_value - ) - ) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.query_capacity_plan_insights(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_query_capacity_plan_insights_rest_unset_required_fields(): - transport = transports.CapacityPlanningServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.query_capacity_plan_insights._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "capacityPlanFilters", - ) - ) - ) - - -def test_query_capacity_plan_insights_rest_flattened(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = capacity_planning_service.QueryCapacityPlanInsightsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - capacity_plan_filters=capacity_planning_service.CapacityPlanFilters( - keys=[ - capacity_planning_service.CapacityPlanKey( - resource_container=resource.ResourceContainer( - type_=resource.ResourceContainer.Type.PROJECT - ) - ) - ] - ), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = capacity_planning_service.QueryCapacityPlanInsightsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.query_capacity_plan_insights(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1beta/{parent=projects/*}/capacityPlanInsights:query" - % client.transport._host, - args[1], - ) - - -def test_query_capacity_plan_insights_rest_flattened_error(transport: str = "rest"): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.query_capacity_plan_insights( - capacity_planning_service.QueryCapacityPlanInsightsRequest(), - parent="parent_value", - capacity_plan_filters=capacity_planning_service.CapacityPlanFilters( - keys=[ - capacity_planning_service.CapacityPlanKey( - resource_container=resource.ResourceContainer( - type_=resource.ResourceContainer.Type.PROJECT - ) - ) - ] - ), - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.CapacityPlanningServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.CapacityPlanningServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CapacityPlanningServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.CapacityPlanningServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CapacityPlanningServiceClient( - client_options=options, - transport=transport, - ) - - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CapacityPlanningServiceClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.CapacityPlanningServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CapacityPlanningServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CapacityPlanningServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = CapacityPlanningServiceClient(transport=transport) - assert client.transport is transport - - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CapacityPlanningServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.CapacityPlanningServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CapacityPlanningServiceGrpcTransport, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - transports.CapacityPlanningServiceRestTransport, - ], -) -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() - - -def test_transport_kind_grpc(): - transport = CapacityPlanningServiceClient.get_transport_class("grpc")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" - - -def test_initialize_client_w_grpc(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc" - ) - assert client is not None - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_capacity_plan_empty_call_grpc(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_capacity_plan), "__call__" - ) as call: - call.return_value = capacity_planning_service.CapacityPlan() - client.get_capacity_plan(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = capacity_planning_service.GetCapacityPlanRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_query_capacity_plans_empty_call_grpc(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), "__call__" - ) as call: - call.return_value = capacity_planning_service.QueryCapacityPlansResponse() - client.query_capacity_plans(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = capacity_planning_service.QueryCapacityPlansRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_query_capacity_plan_insights_empty_call_grpc(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plan_insights), "__call__" - ) as call: - call.return_value = ( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - client.query_capacity_plan_insights(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = capacity_planning_service.QueryCapacityPlanInsightsRequest() - - assert args[0] == request_msg - - -def test_transport_kind_grpc_asyncio(): - transport = CapacityPlanningServiceAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() - ) - assert transport.kind == "grpc_asyncio" - - -def test_initialize_client_w_grpc_asyncio(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), transport="grpc_asyncio" - ) - assert client is not None - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_capacity_plan_empty_call_grpc_asyncio(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_capacity_plan), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.CapacityPlan( - name="name_value", - state=capacity_planning_service.State.PENDING_REVIEW, - description="description_value", - title="title_value", - ) - ) - await client.get_capacity_plan(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = capacity_planning_service.GetCapacityPlanRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_query_capacity_plans_empty_call_grpc_asyncio(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.QueryCapacityPlansResponse( - next_page_token="next_page_token_value", - ) - ) - await client.query_capacity_plans(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = capacity_planning_service.QueryCapacityPlansRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_query_capacity_plan_insights_empty_call_grpc_asyncio(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plan_insights), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - await client.query_capacity_plan_insights(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = capacity_planning_service.QueryCapacityPlanInsightsRequest() - - assert args[0] == request_msg - - -def test_transport_kind_rest(): - transport = CapacityPlanningServiceClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" - - -def test_get_capacity_plan_rest_bad_request( - request_type=capacity_planning_service.GetCapacityPlanRequest, -): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/capacityPlans/sample2"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_capacity_plan(request) - - -@pytest.mark.parametrize( - "request_type", - [ - capacity_planning_service.GetCapacityPlanRequest, - dict, - ], -) -def test_get_capacity_plan_rest_call_success(request_type): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/capacityPlans/sample2"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = capacity_planning_service.CapacityPlan( - name="name_value", - state=capacity_planning_service.State.PENDING_REVIEW, - description="description_value", - title="title_value", - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = capacity_planning_service.CapacityPlan.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_capacity_plan(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, capacity_planning_service.CapacityPlan) - assert response.name == "name_value" - assert response.state == capacity_planning_service.State.PENDING_REVIEW - assert response.description == "description_value" - assert response.title == "title_value" - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_capacity_plan_rest_interceptors(null_interceptor): - transport = transports.CapacityPlanningServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.CapacityPlanningServiceRestInterceptor(), - ) - client = CapacityPlanningServiceClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.CapacityPlanningServiceRestInterceptor, "post_get_capacity_plan" - ) as post, mock.patch.object( - transports.CapacityPlanningServiceRestInterceptor, - "post_get_capacity_plan_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.CapacityPlanningServiceRestInterceptor, "pre_get_capacity_plan" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = capacity_planning_service.GetCapacityPlanRequest.pb( - capacity_planning_service.GetCapacityPlanRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = capacity_planning_service.CapacityPlan.to_json( - capacity_planning_service.CapacityPlan() - ) - req.return_value.content = return_value - - request = capacity_planning_service.GetCapacityPlanRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = capacity_planning_service.CapacityPlan() - post_with_metadata.return_value = ( - capacity_planning_service.CapacityPlan(), - metadata, - ) - - client.get_capacity_plan( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_query_capacity_plans_rest_bad_request( - request_type=capacity_planning_service.QueryCapacityPlansRequest, -): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"parent": "organizations/sample1"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.query_capacity_plans(request) - - -@pytest.mark.parametrize( - "request_type", - [ - capacity_planning_service.QueryCapacityPlansRequest, - dict, - ], -) -def test_query_capacity_plans_rest_call_success(request_type): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {"parent": "organizations/sample1"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = capacity_planning_service.QueryCapacityPlansResponse( - next_page_token="next_page_token_value", - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = capacity_planning_service.QueryCapacityPlansResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.query_capacity_plans(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.QueryCapacityPlansPager) - assert response.next_page_token == "next_page_token_value" - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_query_capacity_plans_rest_interceptors(null_interceptor): - transport = transports.CapacityPlanningServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.CapacityPlanningServiceRestInterceptor(), - ) - client = CapacityPlanningServiceClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.CapacityPlanningServiceRestInterceptor, "post_query_capacity_plans" - ) as post, mock.patch.object( - transports.CapacityPlanningServiceRestInterceptor, - "post_query_capacity_plans_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.CapacityPlanningServiceRestInterceptor, "pre_query_capacity_plans" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = capacity_planning_service.QueryCapacityPlansRequest.pb( - capacity_planning_service.QueryCapacityPlansRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = capacity_planning_service.QueryCapacityPlansResponse.to_json( - capacity_planning_service.QueryCapacityPlansResponse() - ) - req.return_value.content = return_value - - request = capacity_planning_service.QueryCapacityPlansRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = capacity_planning_service.QueryCapacityPlansResponse() - post_with_metadata.return_value = ( - capacity_planning_service.QueryCapacityPlansResponse(), - metadata, - ) - - client.query_capacity_plans( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_query_capacity_plan_insights_rest_bad_request( - request_type=capacity_planning_service.QueryCapacityPlanInsightsRequest, -): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.query_capacity_plan_insights(request) - - -@pytest.mark.parametrize( - "request_type", - [ - capacity_planning_service.QueryCapacityPlanInsightsRequest, - dict, - ], -) -def test_query_capacity_plan_insights_rest_call_success(request_type): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = capacity_planning_service.QueryCapacityPlanInsightsResponse() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = capacity_planning_service.QueryCapacityPlanInsightsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.query_capacity_plan_insights(request) - - # Establish that the response is the type that we expect. - assert isinstance( - response, capacity_planning_service.QueryCapacityPlanInsightsResponse - ) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_query_capacity_plan_insights_rest_interceptors(null_interceptor): - transport = transports.CapacityPlanningServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.CapacityPlanningServiceRestInterceptor(), - ) - client = CapacityPlanningServiceClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.CapacityPlanningServiceRestInterceptor, - "post_query_capacity_plan_insights", - ) as post, mock.patch.object( - transports.CapacityPlanningServiceRestInterceptor, - "post_query_capacity_plan_insights_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.CapacityPlanningServiceRestInterceptor, - "pre_query_capacity_plan_insights", - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = capacity_planning_service.QueryCapacityPlanInsightsRequest.pb( - capacity_planning_service.QueryCapacityPlanInsightsRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = ( - capacity_planning_service.QueryCapacityPlanInsightsResponse.to_json( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - ) - req.return_value.content = return_value - - request = capacity_planning_service.QueryCapacityPlanInsightsRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = ( - capacity_planning_service.QueryCapacityPlanInsightsResponse() - ) - post_with_metadata.return_value = ( - capacity_planning_service.QueryCapacityPlanInsightsResponse(), - metadata, - ) - - client.query_capacity_plan_insights( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_initialize_client_w_rest(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - assert client is not None - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_capacity_plan_empty_call_rest(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_capacity_plan), "__call__" - ) as call: - client.get_capacity_plan(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = capacity_planning_service.GetCapacityPlanRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_query_capacity_plans_empty_call_rest(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plans), "__call__" - ) as call: - client.query_capacity_plans(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = capacity_planning_service.QueryCapacityPlansRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_query_capacity_plan_insights_empty_call_rest(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.query_capacity_plan_insights), "__call__" - ) as call: - client.query_capacity_plan_insights(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = capacity_planning_service.QueryCapacityPlanInsightsRequest() - - assert args[0] == request_msg - - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CapacityPlanningServiceGrpcTransport, - ) - - -def test_capacity_planning_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CapacityPlanningServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", - ) - - -def test_capacity_planning_service_base_transport(): - # Instantiate the base transport. - with mock.patch( - "google.cloud.capacityplanner_v1beta.services.capacity_planning_service.transports.CapacityPlanningServiceTransport.__init__" - ) as Transport: - Transport.return_value = None - transport = transports.CapacityPlanningServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - "get_capacity_plan", - "query_capacity_plans", - "query_capacity_plan_insights", - ) - 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_capacity_planning_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.capacityplanner_v1beta.services.capacity_planning_service.transports.CapacityPlanningServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CapacityPlanningServiceTransport( - 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/devstorage.full_control", - ), - quota_project_id="octopus", - ) - - -def test_capacity_planning_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.capacityplanner_v1beta.services.capacity_planning_service.transports.CapacityPlanningServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CapacityPlanningServiceTransport() - adc.assert_called_once() - - -def test_capacity_planning_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) - CapacityPlanningServiceClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/devstorage.full_control", - ), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CapacityPlanningServiceGrpcTransport, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - ], -) -def test_capacity_planning_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/devstorage.full_control", - ), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CapacityPlanningServiceGrpcTransport, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - transports.CapacityPlanningServiceRestTransport, - ], -) -def test_capacity_planning_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.CapacityPlanningServiceGrpcTransport, grpc_helpers), - (transports.CapacityPlanningServiceGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -def test_capacity_planning_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( - "capacityplanner.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/devstorage.full_control", - ), - scopes=["1", "2"], - default_host="capacityplanner.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CapacityPlanningServiceGrpcTransport, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - ], -) -def test_capacity_planning_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 - ) - - -def test_capacity_planning_service_http_transport_client_cert_source_for_mtls(): - cred = ga_credentials.AnonymousCredentials() - with mock.patch( - "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel" - ) as mock_configure_mtls_channel: - transports.CapacityPlanningServiceRestTransport( - credentials=cred, client_cert_source_for_mtls=client_cert_source_callback - ) - mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) - - -@pytest.mark.parametrize( - "transport_name", - [ - "grpc", - "grpc_asyncio", - "rest", - ], -) -def test_capacity_planning_service_host_no_port(transport_name): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="capacityplanner.googleapis.com" - ), - transport=transport_name, - ) - assert client.transport._host == ( - "capacityplanner.googleapis.com:443" - if transport_name in ["grpc", "grpc_asyncio"] - else "https://capacityplanner.googleapis.com" - ) - - -@pytest.mark.parametrize( - "transport_name", - [ - "grpc", - "grpc_asyncio", - "rest", - ], -) -def test_capacity_planning_service_host_with_port(transport_name): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions( - api_endpoint="capacityplanner.googleapis.com:8000" - ), - transport=transport_name, - ) - assert client.transport._host == ( - "capacityplanner.googleapis.com:8000" - if transport_name in ["grpc", "grpc_asyncio"] - else "https://capacityplanner.googleapis.com:8000" - ) - - -@pytest.mark.parametrize( - "transport_name", - [ - "rest", - ], -) -def test_capacity_planning_service_client_transport_session_collision(transport_name): - creds1 = ga_credentials.AnonymousCredentials() - creds2 = ga_credentials.AnonymousCredentials() - client1 = CapacityPlanningServiceClient( - credentials=creds1, - transport=transport_name, - ) - client2 = CapacityPlanningServiceClient( - credentials=creds2, - transport=transport_name, - ) - session1 = client1.transport.get_capacity_plan._session - session2 = client2.transport.get_capacity_plan._session - assert session1 != session2 - session1 = client1.transport.query_capacity_plans._session - session2 = client2.transport.query_capacity_plans._session - assert session1 != session2 - session1 = client1.transport.query_capacity_plan_insights._session - session2 = client2.transport.query_capacity_plan_insights._session - assert session1 != session2 - - -def test_capacity_planning_service_grpc_transport_channel(): - channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CapacityPlanningServiceGrpcTransport( - 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_capacity_planning_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CapacityPlanningServiceGrpcAsyncIOTransport( - 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.CapacityPlanningServiceGrpcTransport, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - ], -) -def test_capacity_planning_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.CapacityPlanningServiceGrpcTransport, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - ], -) -def test_capacity_planning_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_capacity_plan_path(): - project = "squid" - capacity_plan = "clam" - expected = "projects/{project}/capacityPlans/{capacity_plan}".format( - project=project, - capacity_plan=capacity_plan, - ) - actual = CapacityPlanningServiceClient.capacity_plan_path(project, capacity_plan) - assert expected == actual - - -def test_parse_capacity_plan_path(): - expected = { - "project": "whelk", - "capacity_plan": "octopus", - } - path = CapacityPlanningServiceClient.capacity_plan_path(**expected) - - # Check that the path construction is reversible. - actual = CapacityPlanningServiceClient.parse_capacity_plan_path(path) - assert expected == actual - - -def test_common_billing_account_path(): - billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format( - billing_account=billing_account, - ) - actual = CapacityPlanningServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "nudibranch", - } - path = CapacityPlanningServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = CapacityPlanningServiceClient.parse_common_billing_account_path(path) - assert expected == actual - - -def test_common_folder_path(): - folder = "cuttlefish" - expected = "folders/{folder}".format( - folder=folder, - ) - actual = CapacityPlanningServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "mussel", - } - path = CapacityPlanningServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = CapacityPlanningServiceClient.parse_common_folder_path(path) - assert expected == actual - - -def test_common_organization_path(): - organization = "winkle" - expected = "organizations/{organization}".format( - organization=organization, - ) - actual = CapacityPlanningServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nautilus", - } - path = CapacityPlanningServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = CapacityPlanningServiceClient.parse_common_organization_path(path) - assert expected == actual - - -def test_common_project_path(): - project = "scallop" - expected = "projects/{project}".format( - project=project, - ) - actual = CapacityPlanningServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "abalone", - } - path = CapacityPlanningServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = CapacityPlanningServiceClient.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 = CapacityPlanningServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "whelk", - "location": "octopus", - } - path = CapacityPlanningServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = CapacityPlanningServiceClient.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.CapacityPlanningServiceTransport, "_prep_wrapped_messages" - ) as prep: - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object( - transports.CapacityPlanningServiceTransport, "_prep_wrapped_messages" - ) as prep: - transport_class = CapacityPlanningServiceClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - -def test_transport_close_grpc(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc" - ) - with mock.patch.object( - type(getattr(client.transport, "_grpc_channel")), "close" - ) as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -@pytest.mark.asyncio -async def test_transport_close_grpc_asyncio(): - client = CapacityPlanningServiceAsyncClient( - credentials=async_anonymous_credentials(), 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_rest(): - client = CapacityPlanningServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - with mock.patch.object( - type(getattr(client.transport, "_session")), "close" - ) as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -def test_client_ctx(): - transports = [ - "rest", - "grpc", - ] - for transport in transports: - client = CapacityPlanningServiceClient( - 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", - [ - ( - CapacityPlanningServiceClient, - transports.CapacityPlanningServiceGrpcTransport, - ), - ( - CapacityPlanningServiceAsyncClient, - transports.CapacityPlanningServiceGrpcAsyncIOTransport, - ), - ], -) -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_TEMPLATE.format( - UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE - ), - 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/packages/google-cloud-capacityplanner/tests/unit/gapic/capacityplanner_v1beta/test_usage_service.py b/packages/google-cloud-capacityplanner/tests/unit/gapic/capacityplanner_v1beta/test_usage_service.py index 40863f712c09..96dcec552a32 100644 --- a/packages/google-cloud-capacityplanner/tests/unit/gapic/capacityplanner_v1beta/test_usage_service.py +++ b/packages/google-cloud-capacityplanner/tests/unit/gapic/capacityplanner_v1beta/test_usage_service.py @@ -2790,6 +2790,7 @@ def test_query_usage_histories_rest_required_fields( request_init = {} request_init["parent"] = "" + request_init["cloud_resource_type"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -2806,6 +2807,7 @@ def test_query_usage_histories_rest_required_fields( # verify required fields with default values are now present jsonified_request["parent"] = "parent_value" + jsonified_request["cloudResourceType"] = "cloud_resource_type_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() @@ -2815,6 +2817,8 @@ def test_query_usage_histories_rest_required_fields( # verify required fields with non-default values are left alone assert "parent" in jsonified_request assert jsonified_request["parent"] == "parent_value" + assert "cloudResourceType" in jsonified_request + assert jsonified_request["cloudResourceType"] == "cloud_resource_type_value" client = UsageServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -2865,7 +2869,15 @@ def test_query_usage_histories_rest_unset_required_fields(): ) unset_fields = transport.query_usage_histories._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "cloudResourceType", + ) + ) + ) def test_query_forecasts_rest_use_cached_wrapped_rpc(): @@ -2911,6 +2923,7 @@ def test_query_forecasts_rest_required_fields( request_init = {} request_init["parent"] = "" + request_init["cloud_resource_type"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -2927,6 +2940,7 @@ def test_query_forecasts_rest_required_fields( # verify required fields with default values are now present jsonified_request["parent"] = "parent_value" + jsonified_request["cloudResourceType"] = "cloud_resource_type_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() @@ -2936,6 +2950,8 @@ def test_query_forecasts_rest_required_fields( # verify required fields with non-default values are left alone assert "parent" in jsonified_request assert jsonified_request["parent"] == "parent_value" + assert "cloudResourceType" in jsonified_request + assert jsonified_request["cloudResourceType"] == "cloud_resource_type_value" client = UsageServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -2986,7 +3002,15 @@ def test_query_forecasts_rest_unset_required_fields(): ) unset_fields = transport.query_forecasts._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "cloudResourceType", + ) + ) + ) def test_query_reservations_rest_use_cached_wrapped_rpc(): @@ -3036,6 +3060,7 @@ def test_query_reservations_rest_required_fields( request_init = {} request_init["parent"] = "" + request_init["cloud_resource_type"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -3043,6 +3068,7 @@ def test_query_reservations_rest_required_fields( ) # verify fields with default values are dropped + assert "cloudResourceType" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() @@ -3050,8 +3076,11 @@ def test_query_reservations_rest_required_fields( jsonified_request.update(unset_fields) # verify required fields with default values are now present + assert "cloudResourceType" in jsonified_request + assert jsonified_request["cloudResourceType"] == request_init["cloud_resource_type"] jsonified_request["parent"] = "parent_value" + jsonified_request["cloudResourceType"] = "cloud_resource_type_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() @@ -3079,6 +3108,8 @@ def test_query_reservations_rest_required_fields( # verify required fields with non-default values are left alone assert "parent" in jsonified_request assert jsonified_request["parent"] == "parent_value" + assert "cloudResourceType" in jsonified_request + assert jsonified_request["cloudResourceType"] == "cloud_resource_type_value" client = UsageServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -3117,7 +3148,13 @@ def test_query_reservations_rest_required_fields( response = client.query_reservations(request) - expected_params = [("$alt", "json;enum-encoding=int")] + expected_params = [ + ( + "cloudResourceType", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params @@ -3146,7 +3183,14 @@ def test_query_reservations_rest_unset_required_fields(): "startDate", ) ) - & set(("parent",)) + & set( + ( + "parent", + "cloudResourceType", + "reservationType", + "reservationDataLevel", + ) + ) )